diff options
| author | Jonas Smedegaard <dr@jones.dk> | 2025-03-26 08:25:45 +0100 |
|---|---|---|
| committer | Jonas Smedegaard <dr@jones.dk> | 2025-03-26 09:00:21 +0100 |
| commit | 23415d515ad239d6f0db462dfb4dee0b710b87b7 (patch) | |
| tree | 32f5221768e2121713808843dd134270ebc2cdd8 | |
| parent | 94a7fd070556d8a740f3e82a47c672c7128a6e18 (diff) | |
rename position tracking variables
| -rw-r--r-- | _extensions/ruc-play/semantic-markdown/semantic-markdown.lua | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua b/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua index 53f64d7..06b3c7f 100644 --- a/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua +++ b/_extensions/ruc-play/semantic-markdown/semantic-markdown.lua @@ -148,10 +148,14 @@ end function Statements (blocks) -- positions of enclosure markers - local bracket_begin, bracket_end, brace_begin, brace_end + local pos_bracket_begin, pos_brace_begin, pos_brace_end + + -- positions of beginning of enclosed content + -- usable as flags, since it is always preceded by a marker + local pos_bracketed, pos_braced -- maintain states across inlines - local bracketed, braced, has_hints + local has_hints local new_inlines = {} @@ -164,20 +168,20 @@ function Statements (blocks) end -- unenclosed - if not (bracketed or braced) then - _, bracket_begin = string.find(el.text, "%[") - if bracket_begin then - bracketed = true + if not (pos_bracketed or pos_braced) then + _, pos_bracket_begin = string.find(el.text, "%[") + if pos_bracket_begin then + pos_bracketed = pos_bracket_begin + 1 end end -- enters a bracket enclosure -- TODO: maybe support nested bracket enclosure - if bracketed and not braced then - _, bracket_end, s = string.find(el.text, "^([^%[%]}]*)%]{", - bracket_begin) - if bracket_end then - braced = true + if pos_bracketed and not pos_braced then + _, pos_brace_begin, s = string.find(el.text, "^([^%[%]}]*)%]{", + pos_bracketed) + if pos_brace_begin then + pos_braced = pos_brace_begin + 1 table.insert(new_inlines, pandoc.Str(s)) end end @@ -187,10 +191,10 @@ function Statements (blocks) -- completes a brace enclosure -- TODO: support mixed-use enclosure -- TODO: cover curie_prefix and curie_local and curie_default - if braced then - _, brace_end = string.find(el.text, "^"..curie_long.."}", - bracket_end) - if brace_end then + if pos_braced then + _, pos_brace_end = string.find(el.text, "^"..curie_long.."}", + pos_braced) + if pos_brace_end then has_hints = true -- TODO: call same function with remains of Str end |
