progress on <pre>

This commit is contained in:
sejo 2021-12-13 22:07:36 -06:00
parent 383aa09ba0
commit 1c89aaf9a4
1 changed files with 24 additions and 8 deletions

32
g2e.awk
View File

@ -85,6 +85,11 @@ ARGIND==1 && /^=>/{
content = content " <item id=\"" id "\" href=\"" id ".xhtml\" media-type=\"application/xhtml+xml\"/>\n"
spinetoc = spinetoc " <itemref idref=\"" id "\" />\n"
toc = toc write_template( "toc-navmap.ncx", ch )
next
}
ARGIND==1{ # skip other lines of the index
next
}
# when finished reading the index:
@ -106,12 +111,10 @@ function append(line){
out = out "\t\t" line "\n"
}
ARGIND>2 && FNR==1{
finishfile()
}
# setup the writing for this content file
ARGIND>1 && FNR==1 {
FNR==1 {
if(ARGIND>2) finishfile()
id=FILENAME
match(id,/[^/]+.gmi$/)
filenamestart = RSTART
@ -122,12 +125,25 @@ ARGIND>1 && FNR==1 {
sub(/#{1,3}\s+/,"", $0)
m["title"] = $0
out = write_template("header.xhtml",m)
is_pre = 0
is_list = 0
next
}
ARGIND>1 && match($0,/^#{1,3}+/){
sub(/^#{1,3}[[:space:]]+/,"",$0)
append( "<h" RLENGTH ">" $0 "</h" RLENGTH ">")
/^```/{
is_pre = !is_pre
if(is_pre) append("<pre>")
else append("</pre>")
next
}
# headers
match($0,/^#{1,3}+/){
if(!is_pre){
sub(/^#{1,3}[[:space:]]+/,"",$0)
append( "<h" RLENGTH ">" $0 "</h" RLENGTH ">")
}
else append($0)
next
}