After updating hugo from v0.31.1 to v0.37 code blocks with code fences don’t get highlighted with
pygmentsCodeFences = true
in the config.toml
The highlight shortcode works as expected but code surrounded with codefences is only preformatted.
Generated HTML for the Highlight shortcode:
<div class="highlight"> ... </div>
Generated HTML for codefences:
<pre> <code class="language-html"> ... </code> </pre>
v0.31.1 surrounds the pre Tag with a highlight div:
<div class="highlight"> <pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"> <code class="language-html" data-lang="html"> </code> </pre> </div>
I’m not sure if this is a bug or a normal behaviour.
Regards
Marc
After testing some releases I found out that syntax highlighting of code blocks
worked in v0.34 and stopped working since v0.35
Can you share a test site that shows the issue?
I tried to reproduce the issue in a new hugo site and failed.
Highlighting works in both versions.
After checking my hugo configuration with “hugo config” I found out that the results depend on the position of “pygmentscodefences = true” in the config.toml
If I place the property after other configuration stuff it’s not recognized by hugo.
Example 1 (OK):
baseURL = "http://example.org/"
languageCode = "en-us"
title = "My New Hugo Site"
metaDataFormat = "toml"
pygmentsCodeFences = true
[taxonomies]
tag = "tags"
category = "categories"
Example 2 (not OK):
baseURL = "http://example.org/"
languageCode = "en-us"
title = "My New Hugo Site"
metaDataFormat = "toml"
[taxonomies]
tag = "tags"
category = "categories"
pygmentsCodeFences = true
Of course, toml is indentation agnostic, but very much position dependent.
foo = true
[bar]
is very different than:
[bar]
foo = true
Have a look at the TOML readme in its GitHub repo.
Thank you kaushalmodi!
Maybe it’s really better to read the toml readme