Skip to content

Commit

Permalink
rope_htmlrender: remove nested caption tags
Browse files Browse the repository at this point in the history
Before this commit:

    <caption>

    <caption>
    Commands
    </caption>

    </caption>

With this commit:

    <caption>
    Commands
    </caption>
  • Loading branch information
ee7 committed Feb 21, 2024
1 parent a275429 commit 55f6acb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nimutils/rope_htmlrender.nim
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ proc toHtml*(r: Rope, indent = 0): string =
caption = element("caption", title)
title = ""
elif caption != "":
caption = element("caption", caption)
let i = caption.find('<')
if not caption.continuesWith("<caption>", i):
caption = element("caption", caption)

result = nobreak("table", caption & thead & tbody & tfoot)

Expand Down
5 changes: 5 additions & 0 deletions tests/tests.nim
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ suite "ropes":
test "rope_htmlrender":
const s = """
<table>
<caption>Commands</caption>
<tbody>
<tr>
<th>Command Name</th>
Expand All @@ -237,6 +238,10 @@ suite "ropes":
<div>
<table>
<caption>
Commands
</caption>
<tbody>
<tr>
Expand Down

0 comments on commit 55f6acb

Please sign in to comment.