From fcd12a155985ea415fcd7ba574cc9dfbd6137acb Mon Sep 17 00:00:00 2001 From: Omikhleia Date: Wed, 28 Dec 2022 12:27:50 +0100 Subject: [PATCH 1/4] test: add single blockquote in a fenced div test case --- tests/lunamark/ext_fenced_divs.test | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/lunamark/ext_fenced_divs.test b/tests/lunamark/ext_fenced_divs.test index 2a2d53895..6c71670dd 100644 --- a/tests/lunamark/ext_fenced_divs.test +++ b/tests/lunamark/ext_fenced_divs.test @@ -66,6 +66,11 @@ This is the beginning of a div This is the end of a div ::: +::: {#another-identifier} +> This is a blockquote immediately in a +> div +::: + Here are some extra colons that will be shown as just text: :::: @@ -144,6 +149,10 @@ several paragraphs of text This is the end of a div +
+
This is a blockquote immediately in a div
+
+

Here are some extra colons that will be shown as just text:

::::

From 7da01a30eae228ac2de9a9a4feacc4d6cebd44d1 Mon Sep 17 00:00:00 2001 From: Omikhleia Date: Wed, 28 Dec 2022 12:56:05 +0100 Subject: [PATCH 2/4] fix: closing fenced div shall break out blockquote continuation lines --- lunamark/reader/markdown.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lunamark/reader/markdown.lua b/lunamark/reader/markdown.lua index b3dea7f49..8a3ca86d4 100644 --- a/lunamark/reader/markdown.lua +++ b/lunamark/reader/markdown.lua @@ -1136,10 +1136,14 @@ function M.new(writer, options) local is_inside_div = Cmt(Cb("div_level"), check_div_level) + larsers.fenced_div_out = is_inside_div -- break out of a paragraph when we + -- are inside a div and see a closing tag + * parsers.fenced_div_end + larsers.fencestart = larsers.fencestart - + is_inside_div -- break out of a paragraph when we - -- are inside a div and see a closing tag - * parsers.fenced_div_end + + larsers.fenced_div_out + else + larsers.fenced_div_out = parsers.fail end larsers.Endline = parsers.newline * -( -- newline, but not before... @@ -1359,7 +1363,7 @@ function M.new(writer, options) larsers.Blockquote = Cs((((parsers.leader * parsers.more * parsers.space^-1)/"" * parsers.linechar^0 * parsers.newline)^1 * (-(parsers.leader * parsers.more - + parsers.blankline) * parsers.linechar^1 + + parsers.blankline + larsers.fenced_div_out) * parsers.linechar^1 * parsers.newline)^0 * parsers.blankline^0 )^1) / parse_blocks / writer.blockquote From e6a228f780f164a4eae323e56ebac61d0a503811 Mon Sep 17 00:00:00 2001 From: Omikhleia Date: Tue, 9 May 2023 13:17:13 +0200 Subject: [PATCH 3/4] chore: apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Vít Novotný --- lunamark/reader/markdown.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lunamark/reader/markdown.lua b/lunamark/reader/markdown.lua index 8a3ca86d4..d6e0e9c75 100644 --- a/lunamark/reader/markdown.lua +++ b/lunamark/reader/markdown.lua @@ -1363,7 +1363,8 @@ function M.new(writer, options) larsers.Blockquote = Cs((((parsers.leader * parsers.more * parsers.space^-1)/"" * parsers.linechar^0 * parsers.newline)^1 * (-(parsers.leader * parsers.more - + parsers.blankline + larsers.fenced_div_out) * parsers.linechar^1 + + parsers.blankline + + larsers.fenced_div_out) * parsers.linechar^1 * parsers.newline)^0 * parsers.blankline^0 )^1) / parse_blocks / writer.blockquote From 38040ee382feea7ae0840a0d19297ab8bbae2f05 Mon Sep 17 00:00:00 2001 From: Omikhleia Date: Tue, 9 May 2023 20:54:35 +0200 Subject: [PATCH 4/4] test: move blockquote in div test earlier --- tests/lunamark/ext_fenced_divs.test | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/lunamark/ext_fenced_divs.test b/tests/lunamark/ext_fenced_divs.test index 6c71670dd..d6318a382 100644 --- a/tests/lunamark/ext_fenced_divs.test +++ b/tests/lunamark/ext_fenced_divs.test @@ -66,11 +66,6 @@ This is the beginning of a div This is the end of a div ::: -::: {#another-identifier} -> This is a blockquote immediately in a -> div -::: - Here are some extra colons that will be shown as just text: :::: @@ -88,6 +83,11 @@ This is a div with a fenced code inside ``` ::: +::: {#another-identifier} +> This is a blockquote immediately in a +> div +::: + ::: {.cit custom-style=raggedleft} I am a _fenced_ div ::: @@ -149,10 +149,6 @@ several paragraphs of text This is the end of a div -
-
This is a blockquote immediately in a div
-
-

Here are some extra colons that will be shown as just text:

::::

@@ -164,6 +160,10 @@ This is the end of a div +
+
This is a blockquote immediately in a div
+
+
I am a fenced div