Skip to content

Commit

Permalink
Merge pull request #61 from Omikhleia/fix-immediate-blocquote-in-fenc…
Browse files Browse the repository at this point in the history
…ed-div

Fix immediate blockquote in fenced div
  • Loading branch information
Witiko authored May 15, 2023
2 parents ae3091a + 38040ee commit 104d7fa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lunamark/reader/markdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down Expand Up @@ -1359,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) * parsers.linechar^1
+ parsers.blankline
+ larsers.fenced_div_out) * parsers.linechar^1
* parsers.newline)^0 * parsers.blankline^0
)^1) / parse_blocks / writer.blockquote

Expand Down
9 changes: 9 additions & 0 deletions tests/lunamark/ext_fenced_divs.test
Original file line number Diff line number Diff line change
Expand Up @@ -83,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
:::
Expand Down Expand Up @@ -155,6 +160,10 @@ This is the end of a div</div>
</code></pre>
</div>

<div id="another-identifier">
<blockquote>This is a blockquote immediately in a div</blockquote>
</div>

<div class="cit">I am a <em>fenced</em> div</div>

<div class="cit">
Expand Down

0 comments on commit 104d7fa

Please sign in to comment.