Skip to content

Commit

Permalink
fix(core): Handle empty content in macros using \process
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Jul 3, 2020
1 parent 53a3a19 commit 2dc6d66
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions core/baseclass.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,24 @@ SILE.registerCommand("define", function (options, content)
SU.warn("Did you mean to re-definine the `\\process` macro? That probably won't go well.")
end
SILE.registerCommand(options["command"], function (_, _content)
SU.debug("macros", "Processing a "..options["command"].."\n")
SU.debug("macros", "Processing macro \\" .. options["command"])
local macroArg
if type(_content) == "function" then
macroArg = _content
else
elseif type(_content) == "table" then
macroArg = pl.tablex.copy(_content)
macroArg.command = nil
macroArg.id = nil
elseif _content == nil then
macroArg = {}
else
SU.error("Unhandled content type " .. type(_content) .. " passed to macro \\" .. options["command"], true)
end
-- Replace every occurrence of \process in `content` (the macro
-- body) with `macroArg`, then have SILE go through the new `content`.
local newContent = replaceProcessBy(macroArg, content)
SILE.process(newContent)
SU.debug("macros", "Finished processing "..options["command"].."\n")
SU.debug("macros", "Finished processing \\" .. options["command"])
end, options.help, SILE.currentlyProcessingFile)
end, "Define a new macro. \\define[command=example]{ ... \\process }")

Expand Down

0 comments on commit 2dc6d66

Please sign in to comment.