Skip to content

Commit

Permalink
DRAFT: HTML support
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlcctrlv committed Nov 12, 2022
1 parent 2f69ba1 commit 86e5224
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions packages/markdown/html.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
local base = require("packages.base")
local utils = require("packages.markdown.utils")

local package = pl.class(base)
package._name = "markdown.html"

local passthroughs = {
"sup",
"sub",
"em",
"strong",
{ ["div"] = "hbox" },
{ ["b"] = "strong" },
{ ["i"] = "em" },
}

package.registerHTMLcommands = function(self)
self:registerCommand("markdown:html:br", function (_, _)
SU.debug("markdown", "warning: manual linebreak (\\cr) inserted")
SILE.call("cr")
end, "HTML <br/> in Markdown")

for _, p in pairs(passthroughs) do
local html_name, sile_name
if type(p) == "table" then
html_name, sile_name = next(p), p[next(p)]
else
html_name, sile_name = p, p
end

self:registerCommand("markdown:html:" .. html_name, function(options, content)
SU.debug("markdown", "info: " .. html_name .. " replaced by \\" .. sile_name)
return utils.createCommand(sile_name, options, content)
end)
end
end

package.documentation = [[\begin{document}
A helper package for Markdown processing, providing HTML support.
It is not intended to be used alone.
\end{document}]]

return package

0 comments on commit 86e5224

Please sign in to comment.