diff options
Diffstat (limited to '')
| -rw-r--r-- | custom/extensions/about-render.lua | 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -rw-r--r-- | tests/extensions/test-about-render.lua | 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 files changed, 29 insertions, 8 deletions
diff --git a/custom/extensions/about-render.lua b/custom/extensions/about-render.lua index ed7e340..cc0892f 100644 --- a/custom/extensions/about-render.lua +++ b/custom/extensions/about-render.lua @@ -201,6 +201,15 @@ local function shows_something(lines) return false end +local function emit_lines(lines) + for i, line in ipairs(lines) do + if i > 1 then + html("\n") + end + emit_inline(line) + end +end + local emit_blocks emit_blocks = function(blocks) @@ -249,18 +258,13 @@ emit_blocks = function(blocks) html("<" .. tag .. ">") for _, item in ipairs(block.items) do html("<li>") - emit_inline(item) + emit_lines(item) html("</li>") end html("</" .. tag .. ">") elseif kind == "para" and shows_something(block.lines) then html("<p>") - for i, line in ipairs(block.lines) do - if i > 1 then - html("\n") - end - emit_inline(line) - end + emit_lines(block.lines) html("</p>") end end @@ -496,8 +500,16 @@ if has_lpeg then if not item_mark or ordered(item_mark) ~= is_ordered then break end - items[#items + 1] = parse_inline(content) + local item = { content } i = i + 1 + -- A wrapped line carries the item on, whatever its + -- indent, while a rule still ends the list. + while i <= n and not ends_paragraph(lines, i) + and not break_line:match(lines[i]) do + item[#item + 1] = lines[i] + i = i + 1 + end + items[#items + 1] = paragraph_lines(item) end blocks[#blocks + 1] = { kind = "list", diff --git a/tests/extensions/test-about-render.lua b/tests/extensions/test-about-render.lua index 6644664..eb62a89 100644 --- a/tests/extensions/test-about-render.lua +++ b/tests/extensions/test-about-render.lua @@ -228,6 +228,15 @@ h.contains("dashes render an unordered list", out, "<ul><li>first</li><li>second out = render("README.md", "1. first\n2. second") h.contains("numbers render an ordered list", out, "<ol><li>first</li><li>second</li></ol>") +out = render("README.md", "- one\n wrapped\n- two") +h.contains("a wrapped item stays one item", out, "<ul><li>one\nwrapped</li><li>two</li></ul>") + +out = render("README.md", "1. step\nlazy line\n2. next") +h.contains("an unindented line carries the item on", out, "<ol><li>step\nlazy line</li><li>next</li></ol>") + +out = render("README.md", "- item\n---") +h.contains("a rule still ends the list", out, "<ul><li>item</li></ul><hr>") + out = render("README.md", "- plain\n1. numbered") h.contains("a change of marker splits the list", out, "</ul><ol>") |
