Fix HTML renderer inserting extra </ul>s

This commit is contained in:
Shadowfacts 2021-10-02 10:49:41 -04:00
parent d6ff2141dc
commit 0d85c6f6ea
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
2 changed files with 12 additions and 0 deletions

View File

@ -27,6 +27,7 @@ public class GeminiHTMLRenderer {
for (index, line) in doc.lines.enumerated() {
if inList && !line.isListItem {
str += "</ul>"
inList = false
}
switch line {

View File

@ -97,5 +97,16 @@ class GeminiHTMLRendererTests: XCTestCase {
let html = GeminiHTMLRenderer().renderDocumentToHTML(doc)
XCTAssertEqual(html, "<blockquote>quoted</blockquote>")
}
func testStuffAfterList() {
doc.lines = [
.unorderedListItem("a"),
.unorderedListItem("b"),
.text("c"),
.text("d"),
]
let html = GeminiHTMLRenderer().renderDocumentToHTML(doc)
XCTAssertEqual(html, "<ul><li>a</li><li>b</li></ul><p>c</p><p>d</p>")
}
}