-
I expected that all elements would have default methods which just return a bare stringification but obviously that is not the case. So a couple of related questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I posted this to pandoc-discuss last year (and haven't looked at it since). Might it help? All, With regard to the recent discussion of pandoc 3 custom HTML writers, I've uploaded a sample writer to https://github.com/wlupton/pandoc-html-writer. Sorry for the delay in doing this. See below for the contents of the README. William Sample pandoc 3 custom writers, both of which use the scaffolding mechanism.
There might be a few missing features in the base writer. Also, I believe that there's a problem with the handling of table rowspans and colspans; in addition, please see the XXX comments in the code. There are also a sample.md file and a makefile. |
Beta Was this translation helpful? Give feedback.
-
We were trying to replicate the behavior of classical custom writers, which would error whenever they encountered an unknown element. But I'm always interested to hear ideas for improvements. Here's some code that provides default methods for elements: Writer = pandoc.scaffolding.Writer
Writer.Inline.Space = pandoc.layout.space
Writer.Block.Figure = pandoc.layout.literal '[[Figure]]'
getmetatable(Writer.Inline).__index = function (t, k)
return rawget(t, k)
and rawget(t, k)
or pandoc.utils.stringify
end
getmetatable(Writer.Block).__index = function (t, k)
return rawget(t, key)
and rawget(t, key)
or function (elem)
if pandoc.utils.type(elem.content) == 'Inlines' then
return Writer.Inlines(elem.content)
end
error("Don't know how to render " .. elem.t)
end
end |
Beta Was this translation helpful? Give feedback.
We were trying to replicate the behavior of classical custom writers, which would error whenever they encountered an unknown element. But I'm always interested to hear ideas for improvements.
Here's some code that provides default methods for elements: