diff options
author | John Ankarström <john@ankarstrom.se> | 2021-01-29 23:58:05 +0000 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-01-29 23:58:05 +0000 |
commit | 1eaa4590ceee74ca82162cfbcd7f417d35dacd35 (patch) | |
tree | 46fb4c2d2c30654d15192e378135a9b5e2178f75 /aux | |
parent | a9b6311209593b5a5955048e124fc45a9d4a108e (diff) | |
download | em-1eaa4590ceee74ca82162cfbcd7f417d35dacd35.tar.gz |
Add support for mixed nested lists
That is, <ul> within <ol> or vice versa.
Diffstat (limited to 'aux')
-rwxr-xr-x | aux/emparse | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/aux/emparse b/aux/emparse index 73fdd5c..e59487d 100755 --- a/aux/emparse +++ b/aux/emparse @@ -15,7 +15,7 @@ function escape(s) { } function beginblock(name) { - if (name == "nl") printf "<ol>\n" + if (name == "nl") printf "<ol class=\"reflist\" style=\"font-size: small;\">\n" else printf "<%s>\n", name } @@ -57,8 +57,8 @@ function heading(level, line) { function item(level, type, line) { if (openitem) printf "</li>" openitem = 1 - if (level > itemlevel) printf "<ul>\n" - if (level < itemlevel) printf "</ul>\n" + if (level > itemlevel) printf "<%s>\n", type + if (level < itemlevel) printf "</%s>\n", type itemlevel = level if (type == "ul") { sub("^ +- ", "") @@ -92,8 +92,7 @@ function term(line, t) { # t is a local variable function ref(v) { if (ENVIRON["ref" v] != "") return "(<a href=\"" ENVIRON["ref" v] "\">" linktext "</a>)" - else - return "[<a href=\"#ref" v "\">" v "</a>]" + return "[<a href=\"#ref" v "\">" v "</a>]" } function format(line) { @@ -179,15 +178,15 @@ openblock == "nl" && /^ \[[0-9a-z]\]+ [^ ]+$/ { next } # hyperlink reference openblock == "nl" && /^ \[[0-9a-z]\]+ / { item(1, "nl", line) } # text reference openblock == "dl" && /^ .*: / { term(line) } -openblock == "ul" && /^ -/ { item(2, "ul", line) } -openblock == "ol" && /^ [0-9a-z]+\./ { item(2, "ol", line) } -openblock == "ul" && /^ -/ { item(3, "ul", line) } -openblock == "ol" && /^ [0-9a-z]+\./ { item(3, "ol", line) } -openblock == "ul" && /^ -/ { item(4, "ul", line) } -openblock == "ol" && /^ [0-9a-z]+\./ { item(4, "ol", line) } -openblock == "ul" && /^ -/ { item(5, "ul", line) } -openblock == "ol" && /^ [0-9a-z]+\./ { item(5, "ol", line) } -openblock == "ul" && /^ -/ { item(6, "ul", line) } -openblock == "ol" && /^ [0-9a-z]+\./ { item(6, "ol", line) } +(openblock == "ul" || openblock == "ol") && /^ -/ { item(2, "ul", line) } +(openblock == "ul" || openblock == "ol") && /^ [0-9a-z]+\./ { item(2, "ol", line) } +(openblock == "ul" || openblock == "ol") && /^ -/ { item(3, "ul", line) } +(openblock == "ul" || openblock == "ol") && /^ [0-9a-z]+\./ { item(3, "ol", line) } +(openblock == "ul" || openblock == "ol") && /^ -/ { item(4, "ul", line) } +(openblock == "ul" || openblock == "ol") && /^ [0-9a-z]+\./ { item(4, "ol", line) } +(openblock == "ul" || openblock == "ol") && /^ -/ { item(5, "ul", line) } +(openblock == "ul" || openblock == "ol") && /^ [0-9a-z]+\./ { item(5, "ol", line) } +(openblock == "ul" || openblock == "ol") && /^ -/ { item(6, "ul", line) } +(openblock == "ul" || openblock == "ol") && /^ [0-9a-z]+\./ { item(6, "ol", line) } { format($0) } |