aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-01-30 09:55:26 +0000
committerJohn Ankarström <john@ankarstrom.se>2021-01-30 09:55:26 +0000
commit4d00aca757265010cae5626c33d186c1cb2c23b8 (patch)
tree56dd8770fc0c7523708bd7c59d06d7cb7a2aa784
parent99ac4e7f5a389898673348449e4a522a86d07f1c (diff)
downloadem-4d00aca757265010cae5626c33d186c1cb2c23b8.tar.gz
Fix nested lists
-rwxr-xr-xaux/emparse15
-rw-r--r--test.em10
-rw-r--r--test.html18
3 files changed, 25 insertions, 18 deletions
diff --git a/aux/emparse b/aux/emparse
index 929c1c7..5fb9397 100755
--- a/aux/emparse
+++ b/aux/emparse
@@ -144,6 +144,8 @@ function breakblock() {
opendef = 0
openblock = 0
openformat = ""
+ itemlevel = 1
+ delete leveltype
expectblock = 1
}
@@ -158,9 +160,16 @@ function heading(level, line) {
function item(level, type, line) {
if (openitem) printf "</li>"
openitem = 1
- if (level > itemlevel) printf "<%s>\n", type
- if (level < itemlevel) printf "</%s>\n", type
- itemlevel = level
+ if (type != "nl") {
+ for (; itemlevel < level; itemlevel++) {
+ printf "<%s>\n", type
+ leveltype[itemlevel+1] = type
+ }
+ for (; itemlevel > level; itemlevel--) {
+ printf "</%s>\n", leveltype[itemlevel]
+ leveltype[itemlevel] = ""
+ }
+ }
if (type == "ul") {
sub("^ +- ", "")
printf "<li>"
diff --git a/test.em b/test.em
index 830e4bd..4fb6997 100644
--- a/test.em
+++ b/test.em
@@ -16,11 +16,11 @@ unordered list item.
ordered list item.
2. Here is another.
- - Here is a list
- - With another list inside it [1]
-
- 1. Here is a mixed nested list
- - An unordered item
+ 1. Here is a list
+ 1. With another list inside it [1]
+ - And yet another list
+ - Inside that list
+ 2. And now we're back at the first level
[1] Reference list item
[a] http://example.com
diff --git a/test.html b/test.html
index b5bafb5..fca431b 100644
--- a/test.html
+++ b/test.html
@@ -23,19 +23,17 @@ ordered list item.
</li><li value="2">Here is another.
</li>
</ol>
-<ul>
-<li>Here is a list
-</li><ul>
-<li>With another list inside it [<a href="#ref1">1</a>]
-</li>
-</ul>
-</ul>
<ol>
-<li value="1">Here is a mixed nested list
+<li value="1">Here is a list
+</li><ol>
+<li value="1">With another list inside it [<a href="#ref1">1</a>]
</li><ul>
-<li>An unordered item
-</li>
+<li>And yet another list
+</li><li>Inside that list
+</li></ul>
</ol>
+<li value="2">And now we're back at the first level
+</li>
</ol>
<ol class="reflist" style="font-size: small;">
<li value="1" id="ref1">Reference list item