1
0
mirror of https://github.com/e621ng/dtext_rb.git synced 2025-03-04 03:03:03 -05:00

Close open tags before [table] or [code]

a7e736f005

Co-Authored-By: evazion <noizave@gmail.com>
This commit is contained in:
Earlopain 2023-04-02 13:33:18 +02:00
parent ccec0eb3c4
commit f0b016d5df
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
2 changed files with 12 additions and 5 deletions

View File

@ -684,7 +684,7 @@ main := |*
};
'[code]'i space* => {
dstack_close_before_block(sm);
dstack_close_leaf_blocks(sm);
dstack_open_block(sm, BLOCK_CODE, "<pre>");
fcall code;
};
@ -720,7 +720,7 @@ main := |*
};
'[table]'i => {
dstack_close_before_block(sm);
dstack_close_leaf_blocks(sm);
dstack_open_block(sm, BLOCK_TABLE, "<table class=\"striped\">");
fcall table;
};

View File

@ -256,6 +256,11 @@ test2[/ltable]
def test_code
assert_parse("<pre>for (i=0; i&lt;5; ++i) {\n printf(1);\n}\n\nexit(1);</pre>", "[code]for (i=0; i<5; ++i) {\n printf(1);\n}\n\nexit(1);")
assert_parse("<p>inline</p><pre>[/i]\n</pre>", "inline\n\n[code]\n[/i]\n[/code]")
assert_parse('<p>inline</p><pre>[/i]</pre>', "inline\n\n[code][/i][/code]")
assert_parse("<p><em>inline</em></p><pre>[/i]\n</pre>", "[i]inline\n\n[code]\n[/i]\n[/code]")
assert_parse('<p><em>inline</em></p><pre>[/i]</pre>', "[i]inline\n\n[code][/i][/code]")
end
def test_urls
@ -444,11 +449,13 @@ test2[/ltable]
end
def test_table
assert_parse("<table class=\"striped\"><thead><tr><th>header</th></tr></thead><tbody><tr><td><a class=\"dtext-link dtext-id-link dtext-post-id-link\" href=\"/posts/100\">post #100</a></td></tr></tbody></table>", "[table][thead][tr][th]header[/th][/tr][/thead][tbody][tr][td]post #100[/td][/tr][/tbody][/table]")
end
assert_parse("<table class=\"striped\"><tr><td>text</td></tr></table>", "[table][tr][td]text[/td][/tr][/table]")
def test_table_with_newlines
assert_parse("<table class=\"striped\"><thead><tr><th>header</th></tr></thead><tbody><tr><td><a class=\"dtext-link dtext-id-link dtext-post-id-link\" href=\"/posts/100\">post #100</a></td></tr></tbody></table>", "[table][thead][tr][th]header[/th][/tr][/thead][tbody][tr][td]post #100[/td][/tr][/tbody][/table]")
assert_parse("<table class=\"striped\"><thead><tr><th>header</th></tr></thead><tbody><tr><td><a class=\"dtext-link dtext-id-link dtext-post-id-link\" href=\"/posts/100\">post #100</a></td></tr></tbody></table>", "[table]\n[thead]\n[tr]\n[th]header[/th][/tr][/thead][tbody][tr][td]post #100[/td][/tr][/tbody][/table]")
assert_parse('<p>inline</p><table class="striped"><tr><td>text</td></tr></table>', "inline\n\n[table][tr][td]text[/td][/tr][/table]")
assert_parse("<p><em>inline</em></p><table class=\"striped\"><tr><td>text</td></tr></table>", "[i]inline\n\n[table][tr][td]text[/td][/tr][/table]")
end
def test_unclosed_th