From 6b6283bc65a05d6a111107df723f204b7f97c2f8 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Mon, 7 Apr 2025 11:05:35 +0200 Subject: fix conditionals (zero != false in Lua) --- .../semantic-markdown/semantic-markdown.lua | 22 +++++++++++++--------- 1 file changed, 13 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 4135ccb..1dc17aa 100644 --- a/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua +++ b/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua @@ -164,7 +164,7 @@ function Statements (block) if el.t == 'Str' and not (bracketed or braced) then _, a, pre = string.find(el.text, "([^\\]?)%[") if a and pre == '' then - bracketed = 1 + bracketed = true pos = a + 1 end end @@ -178,14 +178,14 @@ function Statements (block) -- entering braced enclosure if el.text:sub(c, c) == "{" then - braced = 1 + braced = true pos = c + 1 table.insert(new_inlines, pandoc.Str(s)) -- leaving non-annotation enclosure else - bracketed = 0 - braced = 0 + bracketed = false + braced = false end end end @@ -197,15 +197,19 @@ function Statements (block) _, d = string.find(el.text, "^"..curie_long.."}", pos) if d then statement_count = statement_count + 1 + bracketed = false + braced = false + pos = d + 1 + -- TODO: add any bracket-enclosed content to stack -- TODO: call same function with remains of Str end - end + else table.insert(new_inlines, el) + end + end + if statement_count > 0 then + return pandoc.Blocks {new_inlines} end --- FIXME --- if statement_count then --- return pandoc.Inlines {new_inlines} --- end end -- First resolve namespace declarations, then statements. -- cgit v1.2.3