diff options
| author | Jonas Smedegaard <dr@jones.dk> | 2025-05-10 12:41:33 +0200 |
|---|---|---|
| committer | Jonas Smedegaard <dr@jones.dk> | 2025-05-10 12:59:52 +0200 |
| commit | c2501b043355d78179cd365d6266061e7e7177e4 (patch) | |
| tree | 7ad67b80e459ec44fe7d8c74a3f8587e4293cf19 /_extensions | |
| parent | 25ba73868ce33bff393ab2ae72f19ec50791ee9f (diff) | |
cover non-Str elements representing bracket enclosure in Markdown
Diffstat (limited to '_extensions')
| -rw-r--r-- | _extensions/ruc-play/semantic-markdown/semantic-markdown.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua b/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua index 349cf2f..952c47d 100644 --- a/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua +++ b/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua @@ -66,6 +66,12 @@ local Enclosure = { BRACED = "3", } +-- element types that represents bracket enclosure in Markdown +local ElementTypeIsBracketing = { + Image = true, + Link = true, +} + -- TODO: cover non-ASCII Unicode characters -- @see <https://www.lua.org/manual/5.4/manual.html#6.5> --- curie_prefix - CURIE prefix component as set of chars @@ -224,10 +230,23 @@ function Statements (block) -- non-string element if el.t ~= 'Str' then + -- specific elements represent bracketing + if enclosure == Enclosure.NONE then + if ElementTypeIsBracketing[el.t] then + enclosure = Enclosure.BRACKETED_DONE + end + + -- disqualify bracketing not directly followed by brace + elseif enclosure == Enclosure.BRACKETED_DONE then + enclosure = Enclosure.NONE + end + + -- collect element, except in braced enclosure -- TODO: support mixed-use braced enclosure if enclosure ~= Enclosure.BRACED then table.insert(stack, el) end + goto continue end |
