Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow references and notes in fenced divs #69

Merged
merged 3 commits into from Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions lunamark/reader/markdown.lua
Expand Up @@ -1344,11 +1344,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>