0

I use minted and I try to format twig-Code. But when I select twig as the code-language, it does highlight the twig code but it doesn't highlight html-code!

This looks like this:

enter image description here

Is there any way to select two (multiple) languages or is there any way to have the minted package highlight html also, when twig is selected?

2

pygments provides two different lexers for Twig code. The first one is a simple regex lexer twig which only parses the Twig parts of the code. The second one html+twig is a delegating lexer which uses the twig lexer for the Twig parts and the html lexer for the HTML parts of the code:

\documentclass{article}

\usepackage{minted}

\parindent=0pt
\begin{document}

\texttt{twig}:
\begin{minted}{twig}
{% for message in app %}
    <div class="message">
        <b>{{message}}</b>
    </div>
{% endfor %}
\end{minted}

\texttt{html+twig}:
\begin{minted}{html+twig}
{% for message in app %}
    <div class="message">
        <b>{{message}}</b>
    </div>
{% endfor %}
\end{minted}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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