# Allow raw HTML in LaTeX code with Pandoc

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.
• escape the characters – var firstName Jan 11 at 20:12
• 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:

\begin{verbatim}
%%%html
<aside>Embedding raw HTML can be helpful</aside>
\end{verbatim}


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)
end
end


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

• 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