diff options
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 |
