# Syntax highlighting broken

**URL:** <https://discourse.gohugo.io/t/syntax-highlighting-broken/10862>\
**Category:** Uncategorized\
**Created:** [March 5, 2018, 1:06pm UTC](https://discourse.gohugo.io/t/syntax-highlighting-broken/10862 "2018-03-05T13:06:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcthedark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/marcthedark/32/5408_2.png) [@marcthedark](https://discourse.gohugo.io/u/marcthedark)\
**Post date:** [March 5, 2018, 1:06pm UTC](https://discourse.gohugo.io/t/syntax-highlighting-broken/10862/1 "2018-03-05T13:06:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![marcthedark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/marcthedark/32/5408_2.png) [@marcthedark](https://discourse.gohugo.io/u/marcthedark)\
**Post date:** [March 8, 2018, 12:59pm UTC](https://discourse.gohugo.io/t/syntax-highlighting-broken/10862/2 "2018-03-08T12:59:58Z")

</div>

After testing some releases I found out that syntax highlighting of code blocks  
worked in v0.34 and stopped working since v0.35

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [March 8, 2018, 1:07pm UTC](https://discourse.gohugo.io/t/syntax-highlighting-broken/10862/3 "2018-03-08T13:07:46Z")

</div>

Can you share a test site that shows the issue?

---

<div class="post-metadata">

**Author:** ![marcthedark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/marcthedark/32/5408_2.png) [@marcthedark](https://discourse.gohugo.io/u/marcthedark)\
**Post date:** [March 8, 2018, 2:25pm UTC](https://discourse.gohugo.io/t/syntax-highlighting-broken/10862/4 "2018-03-08T14:25:54Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![kaushalmodi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/kaushalmodi/32/2567_2.png) [@kaushalmodi](https://discourse.gohugo.io/u/kaushalmodi)\
**Post date:** [March 8, 2018, 2:31pm UTC](https://discourse.gohugo.io/t/syntax-highlighting-broken/10862/5 "2018-03-08T14:31:17Z")

</div>

> [@marcthedark](#):
>
> I found out that the results depend on the position of “pygmentscodefences = true” in the config.toml

Of course, toml is indentation agnostic, but very much position dependent.

```auto
foo = true
[bar]

```

is very different than:

```auto
[bar]
foo = true

```

Have a look at the TOML readme in its GitHub repo.

---

<div class="post-metadata">

**Author:** ![marcthedark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/marcthedark/32/5408_2.png) [@marcthedark](https://discourse.gohugo.io/u/marcthedark)\
**Post date:** [March 8, 2018, 2:38pm UTC](https://discourse.gohugo.io/t/syntax-highlighting-broken/10862/6 "2018-03-08T14:38:16Z")

</div>

Thank you kaushalmodi!  
Maybe it’s really better to read the toml readme 🙂
