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

Fix [section] tag to close open tags

c0c5b57f3e

Co-Authored-By: evazion <noizave@gmail.com>
This commit is contained in:
Earlopain 2023-04-01 00:27:19 +02:00
parent 8307adcc99
commit 422e3a9bc4
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
2 changed files with 11 additions and 3 deletions

View File

@ -444,7 +444,7 @@ inline := |*
(section_open | section_open_expanded | section_open_aliased | section_open_aliased_expanded) => {
g_debug("inline [section]");
dstack_rewind(sm);
dstack_close_leaf_blocks(sm);
fexec sm->ts;
fret;
};
@ -753,19 +753,20 @@ main := |*
};
section_open space* => {
dstack_close_before_block(sm);
dstack_close_leaf_blocks(sm);
dstack_open_block(sm, BLOCK_SECTION, "<details>");
append(sm, "<summary></summary>");
};
section_open_expanded space* => {
dstack_close_before_block(sm);
dstack_close_leaf_blocks(sm);
dstack_open_block(sm, BLOCK_SECTION, "<details open>");
append(sm, "<summary></summary>");
};
section_open_aliased space* => {
g_debug("block [section=]");
dstack_close_leaf_blocks(sm);
dstack_open_block(sm, BLOCK_SECTION, "<details>");
append(sm, "<summary>");
append_html_escaped(sm, sm->a1, sm->a2 - 1);
@ -774,6 +775,7 @@ main := |*
section_open_aliased_expanded space* => {
g_debug("block expanded [section=]");
dstack_close_leaf_blocks(sm);
dstack_open_block(sm, BLOCK_SECTION, "<details open>");
append(sm, "<summary>");
append_html_escaped(sm, sm->a1, sm->a2 - 1);

View File

@ -492,6 +492,9 @@ test2[/ltable]
def test_expand
assert_parse("<details><summary></summary><p>hello world</p></details>", "[section]hello world[/section]")
assert_parse("<p>inline <em>foo </em></p><details><summary></summary><p>blah blah</p></details>", "inline [i]foo [section]blah blah[/section]")
assert_parse('<p>inline <span class="spoiler">foo </span></p><details><summary></summary><p>blah blah</p></details>', "inline [spoiler]foo [section]blah blah[/section]")
end
def test_expand_missing_close
@ -500,6 +503,9 @@ test2[/ltable]
def test_aliased_expand
assert_parse("<details><summary>hello</summary><p>blah blah</p></details>", "[section=hello]blah blah[/section]")
assert_parse("<p>inline <em>foo </em></p><details><summary>title</summary><p>blah blah</p></details>", "inline [i]foo [section=title]blah blah[/section]")
assert_parse('<p>inline <span class="spoiler">foo </span></p><details><summary>title</summary><p>blah blah</p></details>', "inline [spoiler]foo [section=title]blah blah[/section]")
end
def test_expand_with_nested_code