Use fenced code blocks in pandoc markdown output

Viewed 462

Is there a way to make pandoc output fenced code blocks (i.e. using triple backticks) when outputting markdown, rather than indenting with four spaces?

1 Answers

One can use a Lua filter to "manually" create the block output:

local fenced = '```\n%s\n```\n'
function CodeBlock (cb)
  return pandoc.RawBlock('markdown', fenced:format(cb.text))
end

Save the above to a file, then pass the file to pandoc via the --lua-filter option.

Related