From db667854e10127bf1fc39bf360836fa8ea7bc377 Mon Sep 17 00:00:00 2001 From: Omikhleia Date: Fri, 11 Aug 2023 11:19:34 +0200 Subject: [PATCH] refactor: Avoid wrapping maths in a SIL construct It was adding an additional parsing step for no good reason, and we can achieve the same thing with a direct AST construct. --- packages/markdown/commands.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/markdown/commands.lua b/packages/markdown/commands.lua index 6ef260f..f3467f2 100644 --- a/packages/markdown/commands.lua +++ b/packages/markdown/commands.lua @@ -645,9 +645,11 @@ Please consider using a resilient-compatible class!]]) self:registerCommand("markdown:internal:math", function (options, content) local mode = options.mode or "text" - -- NOTE: Not sure why the following doesn't work!!!! - -- SILE.call("math", {}, content) - SILE.processString("\\math[mode="..mode.."]{"..SU.contentToString(content).."}", "sil") + -- NOTE: The following doesn't work: SILE.call("math", {}, content) + -- Let's go for a lower-level AST construct instead. + SILE.process({ + utils.createCommand("math", { mode = mode }, SU.contentToString(content)) + }) end) self:registerCommand("markdown:internal:nbsp", function (options, _)