From 3078c68013221248e018971dac6fe1a3e1a2e374 Mon Sep 17 00:00:00 2001 From: Omikhleia Date: Fri, 27 Sep 2024 20:17:10 +0200 Subject: [PATCH] wip(djot): Programmatic symbols (hook) --- inputters/djot.lua | 12 +++++------- packages/markdown/commands.lua | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/inputters/djot.lua b/inputters/djot.lua index 694d9fd..79ed9cc 100644 --- a/inputters/djot.lua +++ b/inputters/djot.lua @@ -778,13 +778,9 @@ function Renderer:symbol (node) end return content end - SU.warn("Symbol '" .. node.alias .. "' was not expanded (no corresponding metadata found)") - local text = ":" .. node.alias .. ":" - if node.attr then - -- Add a span for attributes - return createCommand("markdown:internal:span", node.attr, text, pos) - end - return text + -- FIXME PARTIAL EXPERIRMEN A cool idea: + -- Cannot we get rid of predefined symbols (ABOVE) and just use programmatic symbols? + return createCommand("markdown:internal:symbol", node.attr or {}, node.alias, pos) end end @@ -835,6 +831,8 @@ function inputter:parse (doc) -- Wrap it in a document structure so we can just process it, and if at -- root level, load a (default) support class. tree = createCommand("document", { class = "markdown" }, tree) + print("------------------") + --pl.pretty.dump(tree) return { tree } end diff --git a/packages/markdown/commands.lua b/packages/markdown/commands.lua index 53350d2..1bca9be 100644 --- a/packages/markdown/commands.lua +++ b/packages/markdown/commands.lua @@ -778,6 +778,20 @@ Please consider using a resilient-compatible class!]]) end end, "Definition item in Markdown (internal)") + self:registerCommand("markdown:internal:symbol", function (options, content) + -- FIXME HERE WE COULD RATHER SUPPORT PROGRAMMATIC SYMBOLS + local symbol = content[1] + SU.warn("Symbol '" .. symbol .. "' was not expanded (no corresponding metadata found)") + + local text = ":" .. symbol .. ":" + if next(options) then + -- Add a span for attributes + SILE.call("markdown:internal:span", options, { text }); + else + SILE.typesetter:typeset(text) + end + end, "Symbol in Djot (internal)") + -- B. Fallback commands self:registerCommand("markdown:fallback:blockquote", function (_, content)