#3295·zola

Svg components rendered as `<pre>` when called from markdown (When using `zola serve`)

Author: spitloCreated Oct 1, 2026Updated Oct 1, 2026

Bug Report

Environment

Zola version: 0.23.6

Expected Behavior

I'm migrating my website to the latest Zola (0.23.6). I have rewritten all my macros as components, and they all work as expected when called from an html template, no matter what kind of html element they return, no matter if running zola serve or zola build. I would expect the same to be true when the components are embedded in a markdown document, no matter if running zola serve or zola build.

Current Behavior

Components that return an <svg> get rendered as a <pre> element containing the SVG code. This only happens for components embedded in a markdown document, and only when using zola serve. When running zola build, the generated html contains only the <svg> element, not wrapped in a <pre> element. It does not help to wrap the <svg> element in another html element like <span>, the SVG code is always wrapped inside a <pre>. The <pre> is classed like this:

<pre class="giallo z-l-code z-d-code">

Perhaps it's Giallo's JavaScript(?) that doesn't recognize the <svg> element and therefore renders it as a code block? If I build the site and run a local web server from the build folder, everything works as expected, no matter if the components are embedded in an html template or a markdown document, and no matter what kind of element they return.

Step to reproduce

Create a component like this:

{% component prog(class="", type="", fail=false, percentage=0) %}
<span class="progress {{ type }} {% if class %}{{class}}{% endif %}{% if fail %} fail{% endif %}">
    <svg viewBox="0 0 36 36">
      <title>{{ percentage }}%</title>
      <path
        d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
        stroke-dasharray="{{ percentage }}, 100"
      />
      <defs>
        <pattern id="raster" x="0" y="0" width="4" height="4" patternUnits="userSpaceOnUse" >
          <line x1="0" x2="1" y1="0" y2="1" />
        </pattern>
      </defs>
    </svg>
</span>
{% endcomponent prog %}

Include it in a markdown document like this

{{ <prog type="circular" percentage={37} /> }}

In the html source created by running zola build, this renders as:

<span class="progress circular"> <svg viewbox="0 0 36 36"><title>3%</title><path d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831" stroke-dasharray="3, 100"/><defs><pattern height=4 id=raster patternunits=userSpaceOnUse width=4 x=0 y=0><line x1=0 x2=1 y1=0 y2=1 /></pattern></defs></svg> </span>

But in the DevTools elements view when running zola serve, this renders as:

<span class="progress circular"> <pre class="giallo z-l-code z-d-code"><code data-lang="plain"><span class="giallo-l"><span>&lt;svg viewBox="0 0 36 36"&gt;</span></span>
<span class="giallo-l"><span>  </span></span>
<span class="giallo-l"><span>    &lt;title&gt;3%&lt;/title&gt;</span></span>
<span class="giallo-l"><span>    &lt;path</span></span>
<span class="giallo-l"><span>      d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"</span></span>
<span class="giallo-l"><span>      stroke-dasharray="3, 100"</span></span>
<span class="giallo-l"><span>    /&gt;</span></span>
<span class="giallo-l"><span>    &lt;defs&gt;</span></span>
<span class="giallo-l"><span>      &lt;pattern id="raster" x="0" y="0" width="4" height="4" patternUnits="userSpaceOnUse" &gt;</span></span>
<span class="giallo-l"><span>        &lt;line x1="0" x2="1" y1="0" y2="1" /&gt;</span></span>
<span class="giallo-l"><span>      &lt;/pattern&gt;</span></span>
<span class="giallo-l"><span>    &lt;/defs&gt;</span></span>
<span class="giallo-l"><span>  </span></span>
<span class="giallo-l"><span>&lt;/svg&gt;</span></span></code></pre></span>