I normally include code with ~~~
in my Markdown files, but sometimes use the highlight
function for the line numbers. But I noticed that on Hugo 0.55.6 (Extended, Windows 64-bit) the output differs.
Behaviour of ~
Example:
~~~tv
//@version=3
study(title="Pivot indicator", overlay=true)
// Input options
pivOffsetA = input(title="Pivot Offset A", type=integer, defval=7)
pivOffsetB = input(title="Pivot Offset B", type=integer, defval=15)
~~~
Generates this HTML:
<div class="highlight"><pre class="chroma"><code class="language-tv" data-lang="tv"><span class="c1">//@version=3</span>
<span class="nf">study</span>(title<span class="kp">=</span><span class="s">"Pivot indicator"</span><span class="p">,</span> overlay<span class="kp">=</span><span class="kc">true</span>)
<span class="c1">// Input options</span>
pivOffsetA <span class="kp">=</span> <span class="nf">input</span>(title<span class="kp">=</span><span class="s">"Pivot Offset A"</span><span class="p">,</span> type<span class="kp">=</span><span class="nv">integer</span><span class="p">,</span> defval<span class="kp">=</span><span class="m">7</span>)
pivOffsetB <span class="kp">=</span> <span class="nf">input</span>(title<span class="kp">=</span><span class="s">"Pivot Offset B"</span><span class="p">,</span> type<span class="kp">=</span><span class="nv">integer</span><span class="p">,</span> defval<span class="kp">=</span><span class="m">15</span>)
</code></pre></div>
Notice how the // Input options
comment is rendered as a single line.
Here’s how it looks on the webpage:
Totally good looking .
Behaviour with highlight
{{<highlight tv>}}
//@version=3
study(title="Pivot indicator", overlay=true)
// Input options
pivOffsetA = input(title="Pivot Offset A", type=integer, defval=7)
pivOffsetB = input(title="Pivot Offset B", type=integer, defval=15)
{{</highlight>}}
Generates this HTML:
<div class="highlight"><pre class="chroma"><code class="language-tv" data-lang="tv"><span class="c1">//@version=3
</span>
<span class="nf">study</span>(title<span class="kp">=</span><span class="s">"Pivot indicator"</span><span class="p">,</span> overlay<span class="kp">=</span><span class="kc">true</span>)
<span class="c1">// Input options
</span>
pivOffsetA <span class="kp">=</span> <span class="nf">input</span>(title<span class="kp">=</span><span class="s">"Pivot Offset A"</span><span class="p">,</span> type<span class="kp">=</span><span class="nv">integer</span><span class="p">,</span> defval<span class="kp">=</span><span class="m">7</span>)
pivOffsetB <span class="kp">=</span> <span class="nf">input</span>(title<span class="kp">=</span><span class="s">"Pivot Offset B"</span><span class="p">,</span> type<span class="kp">=</span><span class="nv">integer</span><span class="p">,</span> defval<span class="kp">=</span><span class="m">15</span>)
</code></pre></div>
Notice how the comments now have an implicit newline character after them.
As a result, the output on the webpage is also incorrect:
Question: How do I change/fix this behaviour?
(I looked at the docs and seem to be using highlight
correctly.)