Created
May 10, 2025 07:28
-
-
Save connure/f99620c5b632924d0677210f1a1febfe to your computer and use it in GitHub Desktop.
Pandoc Lua filter that translates all definition lists as raw html (definition_lists ---> raw_html). Useful for converting from reStructuredText to GitHub Flavored Markdown (rst ---> gfm). Requires at least pandoc version >= 2.17:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Copyright 2025 connure | |
-- SPDX-License-Identifier: MIT-0 OR Apache-2.0 | |
--[[ definition_lists_as_raw_html.lua | |
Pandoc Lua filter that translates all definition lists as raw html (definition_lists ---> raw_html). | |
Useful for converting from reStructuredText to GitHub Flavored Markdown (rst ---> gfm). | |
Typical usage example (requires at least pandoc version >= 2.17): | |
pandoc --standalone \ | |
--output=README.md \ | |
--to=gfm \ | |
--lua-filter=definition_lists_as_raw_html.lua \ | |
--from=rst \ | |
-- \ | |
README.rst | |
--]] | |
function Pandoc(doc) | |
local filter = { | |
DefinitionList = function(dl) | |
local doc = pandoc.Pandoc(dl, doc.meta) | |
local html = pandoc.write(doc, 'html', PANDOC_WRITER_OPTIONS) | |
return pandoc.RawBlock('html', html) | |
end | |
} | |
return doc:walk(filter) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment