diff options
| author | Jonas Smedegaard <dr@jones.dk> | 2025-04-07 13:11:19 +0200 |
|---|---|---|
| committer | Jonas Smedegaard <dr@jones.dk> | 2025-04-07 13:30:19 +0200 |
| commit | d8e2cc305ec300cedd7b79721d171ea3a8fb9693 (patch) | |
| tree | 6faf8af4fed61bdc8e88289648ac4cb23540c129 /_extensions | |
| parent | 84c7e90f927eb381afa5b0131fc89c051c42389c (diff) | |
parse non-string elements early
Diffstat (limited to '_extensions')
| -rw-r--r-- | _extensions/ruc-play/semantic-markdown/semantic-markdown.lua | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua b/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua index 8e5fa2b..ca724d4 100644 --- a/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua +++ b/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua @@ -159,20 +159,34 @@ function Statements (block) for i, el in ipairs(block.content) do local pos = 0 + -- non-string element + if el.t ~= 'Str' then + + -- TODO: support mixed-use braced enclosure + if not braced then + table.insert(stack, el) + end + goto continue + end + -- unenclosed, entering bracketed enclosure -- TODO: support nested bracketed enclosure - if el.t == 'Str' and not (bracketed or braced) then + if not (bracketed or braced) then _, a, pre = string.find(el.text, "([^\\]?)%[") if a and pre == '' then bracketed = true pos = a + 1 + + -- staying unenclosed + else + table.insert(stack, el) end end -- in bracketed enclosure, entering braced enclosure -- TODO: support backslash in bracket enclosure -- TODO: support nested bracket enclosure - if el.t == 'Str' and bracketed and not braced then + if bracketed and not braced then _, c, s = string.find(el.text, "^([^%[%]}\\]*)%]{?", pos) if c then @@ -193,7 +207,7 @@ function Statements (block) -- in braced enclosure, leaving it -- TODO: support mixed-use enclosure -- TODO: cover curie_prefix and curie_local and curie_default - if el.t == 'Str' and braced then + if braced then _, d1 = string.find(el.text, "^"..curie_long.."}", pos) _, d2 = string.find(el.text, "^"..curie_no_ref.."}", pos) _, d3 = string.find(el.text, "^"..curie_local.."}", pos) @@ -211,9 +225,10 @@ function Statements (block) -- TODO: add any bracket-enclosed content to stack -- TODO: call same function with remains of Str end - else - table.insert(stack, el) end + + -- done parsing current Inline element + ::continue:: end if statement_count > 0 then return pandoc.Blocks {stack} |
