Skip to content

Commit c6ef3a4

Browse files
OmikhleiaDidier Willis
authored andcommitted
fix: Djot user-defined pseudo-symbols nesting issue
1 parent a204e93 commit c6ef3a4

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

packages/markdown/commands.lua

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- Split in a standalone package so that it can be reused and
55
-- generalized somewhat independently from the underlying parsing code.
66
--
7-
-- @copyright License: MIT (c) 2022-2024 Omikhleia, Didier Willis
7+
-- @copyright License: MIT (c) 2022-2025 Omikhleia, Didier Willis
88
-- @module packages.markdown.commands
99
--
1010
require("silex.lang") -- Compatibility layer
@@ -103,7 +103,9 @@ local function decimalFilter (input, _)
103103
end
104104

105105
local function wrapLinkContent (options, content)
106-
local passedOptions = pl.tablex.copy(options) -- shallow
106+
-- shallow copy before removing internal options
107+
-- (Content may be reused in pseudo-symbol macros or other means)
108+
local passedOptions = pl.tablex.copy(options)
107109
-- We already took care of these.
108110
passedOptions.src = nil
109111
passedOptions.id = nil
@@ -247,9 +249,12 @@ function package:registerCommands ()
247249
-- We'll want the ID to apply to the captioning environment (to potentially
248250
-- use the caption numbering)
249251
local id = image.options.id
250-
image.options.id = nil
252+
local imgOptions = pl.tablex.copy(image.options)
253+
-- Shallow copy before removing internal options
254+
-- (Content may be reused in pseudo-symbol macros or other means)
255+
imgOptions.id = nil
251256
-- We also propagate image options to the englobing environment
252-
SILE.call("markdown:internal:captioned-figure", image.options, {
257+
SILE.call("markdown:internal:captioned-figure", imgOptions, {
253258
image,
254259
createCommand("caption", {}, {
255260
createCommand("label", { marker = id }),
@@ -508,6 +513,9 @@ Please consider using a resilient-compatible class!]])
508513
if not (self.hasPackageSupport.piecharts or self.hasPackageSupport.piechart) then -- HACK Some early versions of piecharts have the wrong internal name
509514
SU.error("No piecharts package available to render CSV data ".. uri)
510515
end
516+
-- Shallow copy before removing internal options
517+
-- (Content may be reused in pseudo-symbol macros or other means)
518+
options = pl.tablex.copy(options)
511519
options.src = nil
512520
options.csvfile = uri
513521
SILE.call("piechart", options)
@@ -848,6 +856,9 @@ Please consider using a resilient-compatible class!]])
848856
local text = ":" .. symbol .. ":"
849857
content = { text }
850858
end
859+
-- Shallow copy before removing internal options
860+
-- (Content may be reused in pseudo-symbol macros or other means)
861+
options = pl.tablex.copy(options)
851862
options._symbol_ = nil
852863
options._standalone_ = nil
853864
if next(options) and not standalone then

0 commit comments

Comments
 (0)