Skip to content

Commit fe329c3

Browse files
authored
Merge pull request #141 from Omikhleia/fix-shallow-copy-issue
fix: Djot user-defined pseudo-symbols nesting issue
2 parents a204e93 + daeae9d commit fe329c3

File tree

2 files changed

+77
-4
lines changed

2 files changed

+77
-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
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
rockspec_format = "3.0"
2+
package = "markdown.sile"
3+
version = "2.3.2-1"
4+
source = {
5+
url = "git+https://github.com/Omikhleia/markdown.sile.git",
6+
tag = "v2.3.2",
7+
}
8+
description = {
9+
summary = "Native Markdown support for the SILE typesetting system.",
10+
detailed = [[
11+
This package set for the SILE typesetting system provides a complete redesign
12+
of the native Markdown support for SILE, with a great set of Pandoc-like
13+
extensions and plenty of extra goodies.
14+
]],
15+
homepage = "https://github.com/Omikhleia/markdown.sile",
16+
license = "MIT",
17+
}
18+
dependencies = {
19+
"lua >= 5.1",
20+
"embedders.sile >= 0.2.0",
21+
"labelrefs.sile >= 0.1.0",
22+
"ptable.sile >= 3.1.0",
23+
"smartquotes.sile >= 1.0.0",
24+
"textsubsuper.sile >= 1.2.0",
25+
"silex.sile >= 0.8.0, < 1.0",
26+
"lunajson",
27+
}
28+
29+
build = {
30+
type = "builtin",
31+
modules = {
32+
["sile.classes.markdown"] = "classes/markdown.lua",
33+
["sile.inputters.markdown"] = "inputters/markdown.lua",
34+
["sile.inputters.pandocast"] = "inputters/pandocast.lua",
35+
["sile.inputters.djot"] = "inputters/djot.lua",
36+
["sile.packages.markdown"] = "packages/markdown/init.lua",
37+
["sile.packages.markdown.cmbase"] = "packages/markdown/cmbase.lua",
38+
["sile.packages.markdown.commands"] = "packages/markdown/commands.lua",
39+
["sile.packages.markdown.utils"] = "packages/markdown/utils.lua",
40+
["sile.packages.pandocast"] = "packages/pandocast/init.lua",
41+
["sile.packages.djot"] = "packages/djot/init.lua",
42+
43+
["sile.lunamark"] = "lua-libraries/lunamark.lua",
44+
["sile.lunamark.entities"] = "lua-libraries/lunamark/entities.lua",
45+
["sile.lunamark.reader"] = "lua-libraries/lunamark/reader.lua",
46+
["sile.lunamark.reader.markdown"] = "lua-libraries/lunamark/reader/markdown.lua",
47+
["sile.lunamark.util"] = "lua-libraries/lunamark/util.lua",
48+
["sile.lunamark.writer"] = "lua-libraries/lunamark/writer.lua",
49+
["sile.lunamark.writer.generic"] = "lua-libraries/lunamark/writer/generic.lua",
50+
["sile.lunamark.writer.html"] = "lua-libraries/lunamark/writer/html.lua",
51+
["sile.lunamark.writer.html5"] = "lua-libraries/lunamark/writer/html5.lua",
52+
53+
["sile.djot"] = "lua-libraries/djot.lua",
54+
["sile.djot.attributes"] = "lua-libraries/djot/attributes.lua",
55+
["sile.djot.json"] = "lua-libraries/djot/json.lua",
56+
["sile.djot.block"] = "lua-libraries/djot/block.lua",
57+
["sile.djot.inline"] = "lua-libraries/djot/inline.lua",
58+
["sile.djot.html"] = "lua-libraries/djot/html.lua",
59+
["sile.djot.ast"] = "lua-libraries/djot/ast.lua",
60+
["sile.djot.filter"] = "lua-libraries/djot/filter.lua",
61+
}
62+
}

0 commit comments

Comments
 (0)