Extending existing writers in Lua API #10856
Replies: 3 comments 5 replies
-
There's an experimental html writer and derived writer at https://github.com/BroadbandForum/pandoc-html-writer. I haven't touched this for a while and am not currently using it, but it might be of interest? |
Beta Was this translation helpful? Give feedback.
-
Currently, the best way to do this is to use a filter. I.e., writer a filter that handles the custom things and creates raw Markdown nodes. For example: Div = function (div)
local result = div.content
if div.classes:includes 'header' then
div.content:insert(1, pandoc.RawBlock('markdown', 'This is a header div'))
end
return result
end Use the Markdown flavor of your choice and replace only those elements, that need special handling. |
Beta Was this translation helpful? Give feedback.
-
If you would like to use a Writer rather than a Filter as @tarleb sugested, there is an example in the documentation which uses a Filter inside of a Writer. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello. Currently, I am working on a project involving Markdown with custom extensions including various custom-defined tags. Pandoc really helps to convert documents using other formats to this custom Markdown but these custom extensions require custom writers.
AFAIS, there is only one way to define extensible custom writers --- via Lua. Though it seems that the
pandoc.scaffolding.Writer
interface requires a user to define every method to write the document which is kind of boilerplate: the desired format is mostly markdown but with a few extensions.Is it somehow possible to write an extension of the existing writer overriding only a few methods? It seems to me neither builtin library nor metatable magic helps with it.
I imagine the following syntax to implement this.
Beta Was this translation helpful? Give feedback.
All reactions