Skip to content

Instantly share code, notes, and snippets.

@connure
Created May 10, 2025 07:28
Show Gist options
  • Save connure/f99620c5b632924d0677210f1a1febfe to your computer and use it in GitHub Desktop.
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:
-- 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