Skip to content

Commit

Permalink
Merge pull request #69 from jgm/fix/fenced-div-references
Browse files Browse the repository at this point in the history
Allow references and notes in fenced divs
  • Loading branch information
Witiko committed Sep 27, 2023
2 parents 776b04c + c9baf9a commit 75f61d0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
6 changes: 2 additions & 4 deletions lunamark/reader/markdown.lua
Expand Up @@ -1368,11 +1368,9 @@ function M.new(writer, options)
larsers.FencedDiv = parsers.fenced_div_begin * increment_div_level(1)
* parsers.skipblanklines
* Ct( (V("Block") - parsers.fenced_div_end)^-1
* (parsers.blanklines / function()
return writer.interblocksep
end
* ( V("Blank")^0 / writer.interblocksep
* (V("Block") - parsers.fenced_div_end))^0)
* parsers.skipblanklines
* V("Blank")^0
* parsers.fenced_div_end * increment_div_level(-1)
/ function (infostring, div)
local attr = lpeg.match(Cg(parsers.attributes), infostring)
Expand Down
28 changes: 25 additions & 3 deletions tests/lunamark/ext_fenced_divs.test
@@ -1,4 +1,4 @@
lunamark -Xfenced_divs,fenced_code_blocks
lunamark -Xfenced_divs,fenced_code_blocks,notes
<<<
:::
This is not a div
Expand Down Expand Up @@ -94,7 +94,17 @@ I am a _fenced_ div

::: {.cit custom-style=raggedleft}

I am a _fenced_ div
I am a _fenced_ div with [a reference][1]

[1]: https://foo.bar/

:::

::: {.cit custom-style=raggedleft}

I am a _fenced_ div with a note[^1]

[^1]: This is a note.

:::

Expand Down Expand Up @@ -167,11 +177,23 @@ This is the end of a div</div>
<div class="cit">I am a <em>fenced</em> div</div>

<div class="cit">
<p>I am a <em>fenced</em> div</p>
<p>I am a <em>fenced</em> div with <a href="https://foo.bar/">a reference</a></p>
</div>

<div class="cit">
<p>I am a <em>fenced</em> div with a note<sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup></p>
</div>

::: {.some-classname} This is not a div
<pre><code>:::
</code></pre>

<p>::: {.some-classname} This is not a div</p>

<hr>

<ol class="notes">
<li id="fn1">
<p>This is a note. <a href="#fnref1" class="footnoteBackLink">↩</a></p>
</li>
</ol>

0 comments on commit 75f61d0

Please sign in to comment.