aboutsummaryrefslogtreecommitdiff
path: root/_extensions
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2025-04-07 16:48:47 +0200
committerJonas Smedegaard <dr@jones.dk>2025-04-08 07:28:51 +0200
commitf593a53b5b4e3e7f7845bf1eca487a8160e37e08 (patch)
treedca1efbc06608925dc20bc96659d94667560f71b /_extensions
parentd8e2cc305ec300cedd7b79721d171ea3a8fb9693 (diff)
restructure bracketed enclosure parsing
Diffstat (limited to '_extensions')
-rw-r--r--_extensions/ruc-play/semantic-markdown/semantic-markdown.lua33
1 files changed, 25 insertions, 8 deletions
diff --git a/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua b/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua
index ca724d4..230f351 100644
--- a/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua
+++ b/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua
@@ -169,26 +169,40 @@ function Statements (block)
goto continue
end
- -- unenclosed, entering bracketed enclosure
- -- TODO: support nested bracketed enclosure
+ -- unenclosed
+ -- TODO: support backslash except immediately before bracket
if not (bracketed or braced) then
- _, a, pre = string.find(el.text, "([^\\]?)%[")
- if a and pre == '' then
+ _, x, s = string.find(el.text, "^([^%[\\]*)")
+ if x then
+ a = x + 1
+ else
+ a = 1
+ end
+ if el.text:sub(a, a) == "[" then
+
+ -- entering bracketed enclosure
bracketed = true
pos = a + 1
-- staying unenclosed
else
table.insert(stack, el)
+ goto continue
end
end
- -- in bracketed enclosure, entering braced enclosure
- -- TODO: support backslash in bracket enclosure
+ -- in bracketed enclosure
+ -- TODO: support backslash except immediately before bracket/brace
-- TODO: support nested bracket enclosure
if bracketed and not braced then
- _, c, s = string.find(el.text, "^([^%[%]}\\]*)%]{?", pos)
- if c then
+ _, x, s = string.find(el.text, "^([^%[%]}\\]*)", pos)
+ if x then
+ b = x + 1
+ else
+ b = pos
+ end
+ if el.text:sub(b, b) == "]" then
+ c = b + 1
-- entering braced enclosure
if el.text:sub(c, c) == "{" then
@@ -200,6 +214,9 @@ function Statements (block)
else
bracketed = false
braced = false
+
+ -- TODO: parse remains of Str
+ goto continue
end
end
end