Skip to content

Commit

Permalink
wip(djot): Programmatic symbols (hook)
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia authored and Didier Willis committed Sep 27, 2024
1 parent fa18f93 commit 3078c68
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
12 changes: 5 additions & 7 deletions inputters/djot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions packages/markdown/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3078c68

Please sign in to comment.