-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DRAFT: HTML support #18
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
-- | ||
local utils = require("packages.markdown.utils") | ||
local base = require("packages.base") | ||
local html = require("packages.markdown.html") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In |
||
|
||
local package = pl.class(base) | ||
package._name = "markdown.commands" | ||
|
@@ -364,7 +365,10 @@ function package:registerCommands () | |
SILE.call("smallskip") | ||
end, "A fallback command for Markdown to insert a captioned table") | ||
|
||
-- C. Customizable hooks | ||
-- C. HTML commands | ||
html.registerHTMLcommands(self) | ||
|
||
-- D. Customizable hooks | ||
|
||
self:registerCommand("markdown:custom-style:hook", function (options, content) | ||
-- Default implementation for the custom-style hook: | ||
|
@@ -386,7 +390,6 @@ function package:registerCommands () | |
end | ||
end | ||
end, "Default hook for custom style support in Markdown") | ||
|
||
end | ||
|
||
package.documentation = [[\begin{document} | ||
|
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", | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SILE does not have these, right? We'd need to map them
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It has them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't seem so (at least, there's no "sup"/"sub" in the base and plain class), they only exist it seems in math mode. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Heh, with all due respect, you do so much work it seems you forget some of it!
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Heh :) But in that case the commands are In the current implementation, they'd work if the content is text-only. (If it's not, they ought to fail, although we may reconsider our options) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, strange, my document still compiles though. But you're right, the text is not superscripted. |
||||
"sub", | ||||
"em", | ||||
"strong", | ||||
{ ["div"] = "hbox" }, | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A div cannot be made an hbox (or it won't be properly line broken) -- same for a span actually. But more generally, Pandoc has lots of extensions regarding HTML in Markdown, e.g. I have one more concern which comes to mind: I'd ideally like both the pandocast and markdown packages to have the same minimal set of features. This imply, for any test we write, looking at what the Pandoc AST would contain, to at least ensure reasonable parity, whichever route is taken. |
||||
{ ["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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this removed? We'd still want to support the standard Markdown linebreaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mistake during testing thanks