I know including raw HTML is possible in Markdown documents with Pandoc, so I was wondering if there was a way to allow it in LaTeX documents.

Pandoc converts lower than and greater than characters to HTML entities when included in a LaTeX document (even when inside a verbatim). it makes perfect sens but it's not what I want.

New contributor
geoffrey is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    escape the characters – var firstName Jan 11 at 20:12
  • 1
    It doesn't work. You can try it out online here : the characters are deleted altogether. – geoffrey Jan 12 at 15:19

The best way is to use a specially-marked verbatim environment, which can then be transformed into the desired target format via a Lua filter. E.g., add a %%%html tag as the first line of a verbatim environment, then insert the HTML which you'd like to preserve:

<aside>Embedding raw HTML can be helpful</aside>

Pandoc will read this as a normal code block, but we want a raw HTML block. We use a filter a filter to convert it:

function CodeBlock(cb)
  local rawHtml = cb.text:match('^%s*%%%%%%html\n(.*)')
  if rawHtml then
    return pandoc.RawBlock('html', rawHtml)

Save the above into a file and use it as the argument of pandoc's --lua-filter option.

  • 1
    This is awesome! I noticed that verbatim behaves like a block and has the tendency to close paragraphs, which is not great when I want to insert inline elements within a paragraph, but now that I know where to look I should be able to sort this out by myself. I suppose I can aso modify the behavior of \texttt. – geoffrey Jan 13 at 15:57

Your Answer

geoffrey is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.