{% extends "@Contao/content_element/_base.html.twig" %}
{% use "@Contao/component/_stylesheet.html.twig" %}

{% block content %}
    {% if as_editor_view %}
        {% block editor_view %}<pre>{{ code }}</pre>{% endblock %}
    {% else %}
        {% block highlighted %}
            {# @var \Contao\CoreBundle\Twig\Runtime\HighlightResult highlighted #}
            {% set highlighted = code|highlight(language) %}
            {% set code_attributes = attrs()
                .addClass('hljs')
                .addClass(highlighted.language)
                .mergeWith(code_attributes|default)
            %}
            <pre><code{% block code_attributes %}{{ code_attributes }}{% endblock %}>
                {{- highlighted.value|raw -}}
            </code></pre>
        {% endblock %}
    {% endif -%}
{% endblock %}

{% block style %}
    {% add "highlighter_css" to stylesheets %}
        {% with {file: highlighter_css_file|default(asset('foundation.css', 'scrivo/highlight.php'))} %}
            {{ block('stylesheet_component') }}
        {% endwith %}
    {% endadd %}
{% endblock %}
