fixed bug in scripts/html.awk
previously, gemini lists would be converted wrong. for example: * lorem * ispum would be turned into: <ul><li>lorem</li></ul> <ul><li>ispum</li></ul> instead of: <ul> <li>lorem</li> <li>ispum</li> </ul>
This commit is contained in:
parent
1cdc5c71a2
commit
e29e3a663f
|
@ -2,9 +2,10 @@ BEGIN {
|
|||
title = "techn0path - no title"
|
||||
body = ""
|
||||
subHeadings[0] = ""
|
||||
insideRange = 0
|
||||
}
|
||||
|
||||
/^[ ]*$/ { next }
|
||||
|
||||
/^#[^#]/ {
|
||||
match($0, "^#[ ]*")
|
||||
headingText = substr($0, RSTART + RLENGTH)
|
||||
|
@ -52,6 +53,7 @@ BEGIN {
|
|||
sub("\.gmi$", ".html", link)
|
||||
|
||||
if (description == "") description = link
|
||||
|
||||
gsub("&", "\\&", description)
|
||||
gsub("<", "\\<", description)
|
||||
gsub(">", "\\>", description)
|
||||
|
@ -59,29 +61,27 @@ BEGIN {
|
|||
gsub("\"", "\\"", description)
|
||||
|
||||
body = body sprintf("<a href='%s'>%s</a><br>\n", link, description)
|
||||
|
||||
next
|
||||
}
|
||||
|
||||
/^```/ {
|
||||
insideRange = !insideRange
|
||||
body = body "<pre>\n"
|
||||
|
||||
if (insideRange) {
|
||||
body = body "<pre>\n"
|
||||
} else {
|
||||
body = body "</pre>\n"
|
||||
getline
|
||||
|
||||
while (match($0, "^```") == 0) {
|
||||
gsub("&", "\\&")
|
||||
gsub("<", "\\<")
|
||||
gsub(">", "\\>")
|
||||
gsub("'", "\\'")
|
||||
gsub("\"", "\\"")
|
||||
body = body $0 "\n"
|
||||
|
||||
if (getline != 1) break
|
||||
}
|
||||
|
||||
next
|
||||
}
|
||||
|
||||
insideRange {
|
||||
gsub("&", "\\&")
|
||||
gsub("<", "\\<")
|
||||
gsub(">", "\\>")
|
||||
gsub("'", "\\'")
|
||||
gsub("\"", "\\"")
|
||||
|
||||
body = body $0 "\n"
|
||||
body = body "</pre>\n"
|
||||
|
||||
next
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ insideRange {
|
|||
/^>/ {
|
||||
body = body "<blockquote>\n"
|
||||
|
||||
while (getline == 1 && match($0, "^>[ ]*")) {
|
||||
while (match($0, /^>[ ]*/) != 0) {
|
||||
text = substr($0, RSTART + RLENGTH)
|
||||
|
||||
gsub("&", "\\&", text)
|
||||
|
@ -99,6 +99,8 @@ insideRange {
|
|||
gsub("\"", "\\"", text)
|
||||
|
||||
body = body text "<br>\n"
|
||||
|
||||
if (getline != 1) break
|
||||
}
|
||||
|
||||
body = body "</blockquote>\n"
|
||||
|
@ -108,7 +110,7 @@ insideRange {
|
|||
/^\*/ {
|
||||
body = body "<ul>\n"
|
||||
|
||||
while (getline == 1 && match($0, "^\\*[ ]*")) {
|
||||
while (match($0, /^\*[ ]*/) != 0) {
|
||||
gsub("&", "\\&")
|
||||
gsub("<", "\\<")
|
||||
gsub(">", "\\>")
|
||||
|
@ -116,12 +118,15 @@ insideRange {
|
|||
gsub("\"", "\\"")
|
||||
|
||||
body = body sprintf("<li>%s</li>\n", substr($0, RSTART + RLENGTH))
|
||||
|
||||
if (getline != 1) break
|
||||
}
|
||||
|
||||
body = body "</ul>\n"
|
||||
next
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
gsub("&", "\\&")
|
||||
gsub("<", "\\<")
|
||||
|
@ -150,14 +155,14 @@ END {
|
|||
tocText = tocText "</ol> </details>\n"
|
||||
}
|
||||
|
||||
sub(/(\.|\[|\]|\*)/, "\\&", sourcePath)
|
||||
sub(/(\.|\[|\]|\*)/, "\\&", outputPath)
|
||||
|
||||
navbarText = genNavbarHTML(FILENAME, sourcePath, outputPath)
|
||||
|
||||
stylesheetPath = getRelativePath(dirname, outputPath "/style.css")
|
||||
|
||||
dirname = getDirname(FILENAME)
|
||||
gsub(/(\.|\[|\]|\*)/, "\\&", sourcePath)
|
||||
gsub(sourcePath, outputPath, dirname)
|
||||
gsub(sourcePath, outputPath, filename)
|
||||
sub("^" sourcePath, outputPath, dirname)
|
||||
stylesheetPath = getRelativePath(dirname, outputPath "/style.css")
|
||||
|
||||
printf "<!DOCTYPE html>\n\
|
||||
<html>\n\
|
||||
|
|
Loading…
Reference in New Issue