From f83a3d6e6669cd9bfbf5ac381381878bf0d32075 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Mon, 7 Apr 2025 08:14:26 +0200 Subject: avoid backslash-escaped enclosure --- .../ruc-play/semantic-markdown/semantic-markdown.lua | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to '_extensions') diff --git a/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua b/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua index a8ef886..ef4e7e4 100644 --- a/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua +++ b/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua @@ -162,23 +162,24 @@ function Statements (block) -- unenclosed, entering bracketed enclosure -- TODO: support nested bracketed enclosure if el.t == 'Str' and not (bracketed or braced) then - _, pos = string.find(el.text, "%[") - if pos then + a, b, pre = string.find(el.text, "([^\\]?)%[") + if b and pre == '' then bracketed = 1 - pos = pos + 1 + pos = b + 1 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 - _, pos, s = string.find(el.text, "^([^%[%]}]*)%]{?", pos) - if pos then + a, b, s = string.find(el.text, "^([^%[%]}\\]*)%]{?", pos) + if b then -- entering braced enclosure - if el.text:sub(pos, pos) == "{" then + if el.text:sub(b, b) == "{" then braced = 1 - pos = pos + 1 + pos = b + 1 table.insert(new_inlines, pandoc.Str(s)) -- leaving non-annotation enclosure @@ -193,8 +194,8 @@ function Statements (block) -- TODO: support mixed-use enclosure -- TODO: cover curie_prefix and curie_local and curie_default if el.t == 'Str' and braced then - _, pos = string.find(el.text, "^"..curie_long.."}", pos) - if pos then + a, b = string.find(el.text, "^"..curie_long.."}", pos) + if b then statement_count = statement_count + 1 -- TODO: call same function with remains of Str end -- cgit v1.2.3