# Preventing code block generation from indented \`en.toml\` entries

**URL:** <https://discourse.gohugo.io/t/preventing-code-block-generation-from-indented-en-toml-entries/40237>\
**Category:** support\
**Created:** [August 27, 2022, 5:16pm UTC](https://discourse.gohugo.io/t/preventing-code-block-generation-from-indented-en-toml-entries/40237 "2022-08-27T17:16:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![angel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/angel/32/6325_2.png) [@angel](https://discourse.gohugo.io/u/angel)\
**Post date:** [August 27, 2022, 5:16pm UTC](https://discourse.gohugo.io/t/preventing-code-block-generation-from-indented-en-toml-entries/40237/1 "2022-08-27T17:16:19Z")

</div>

I couldn’t find anything in Goldmark or the Hugo docs on this. I’ll be the first to call out that this isn’t worth a lot of thought as you can fix it by just removing the indentation. We’ve been wondering since we keep having non-technical people indent text in our `i18n/en.toml` file without knowing it’ll display weirdly.

**Questions**

1. When a user indents in the `en.toml` file, it causes that text to turn into a code block. What causes this, and how can we prevent it?
2. Is there a config entry to globally prevent all code block generation?

**Example entry so you can test locally**

```nohighlight
[markdownify_with_indentation_causing_code_block]
other = """
Text without an indent displays as expected

    But indented text gets turned into a code block

- same thing with list items
- same thing with list items
- same thing with list items

Let's indent some list items...

    - indented list items also get a code block
    1. indented list items also get a code block

But again, no indent means no code block
"""

```

Then in an HTML file put `{{ i18n "markdownify_with_indentation_causing_code_block" | markdownify }}`

You should see this:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/b/f/bf5436a62bff62bf4556bf25fd472f9e56c85fce.png)

---

<div class="post-metadata">

**Author:** ![angel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/angel/32/6325_2.png) [@angel](https://discourse.gohugo.io/u/angel)\
**Post date:** [August 27, 2022, 8:05pm UTC](https://discourse.gohugo.io/t/preventing-code-block-generation-from-indented-en-toml-entries/40237/3 "2022-08-27T20:05:36Z")

</div>

@ju52 Thank you for sharing those links, I’m not seeing any references to my question in the three links. Could you please clarify?

---

<div class="post-metadata">

**Author:** ![pamubay](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pamubay/32/17838_2.png) [@pamubay](https://discourse.gohugo.io/u/pamubay)\
**Post date:** [August 28, 2022, 4:13am UTC](https://discourse.gohugo.io/t/preventing-code-block-generation-from-indented-en-toml-entries/40237/4 "2022-08-28T04:13:16Z")

</div>

Goldmark follows Commonmark Spec, that’s called **Indented code blocks**

[https://spec.commonmark.org/0.30/#indented-code-blocks](https://spec.commonmark.org/0.30/#indented-code-blocks)

* * *

Test Commonmark:

[Test Commonmark](https://spec.commonmark.org/dingus/?text=Text%20without%20an%20indent%20displays%20as%20expected%0A%0A%20%20%20%20But%20indented%20text%20get%20syntax%20highlighting%0A%0A-%20same%20thing%20with%20list%20items%0A-%20same%20thing%20with%20list%20items%0A-%20same%20thing%20with%20list%20items%0A%0ALet%27s%20indent%20some%20list%20items...%0A%0A%20%20%20%20-%20indented%20list%20items%20also%20get%20syntax%20highlighting%0A%20%20%20%201.%20indented%20list%20items%20also%20get%20syntax%20highlighting%0A%0ABut%20again%2C%20no%20indent%20means%20no%20syntax%20highlighting%0A%0A)

* * *

AFAIK, there is no option to disable this automatic indented code block conversion.

---

<div class="post-metadata">

**Author:** ![angel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/angel/32/6325_2.png) [@angel](https://discourse.gohugo.io/u/angel)\
**Post date:** [August 28, 2022, 5:06pm UTC](https://discourse.gohugo.io/t/preventing-code-block-generation-from-indented-en-toml-entries/40237/5 "2022-08-28T17:06:30Z")

</div>

Ah, thank you.

I had not heard of commonmark. That is definitely the cause. I wonder if there is a Hugo way or a Goldmark way to disable syntax highlighting altogether.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [August 28, 2022, 5:30pm UTC](https://discourse.gohugo.io/t/preventing-code-block-generation-from-indented-en-toml-entries/40237/6 "2022-08-28T17:30:54Z")

</div>

Just to make sure we’re using the correct terminology, text indented with four or more spaces is an [indented code block](https://spec.commonmark.org/0.30/#indented-code-blocks) — there is no syntax highlighting. Syntax highlighting is achieved with [fenced code blocks](https://spec.commonmark.org/0.30/#fenced-code-blocks).

While you can disable syntax highlighting when using fenced code blocks, you cannot modify the rendering of indented code blocks.

---

<div class="post-metadata">

**Author:** ![angel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/angel/32/6325_2.png) [@angel](https://discourse.gohugo.io/u/angel)\
**Post date:** [August 29, 2022, 12:49pm UTC](https://discourse.gohugo.io/t/preventing-code-block-generation-from-indented-en-toml-entries/40237/7 "2022-08-29T12:49:42Z")

</div>

@jmooring thank you for clarifying the correct terminology, I’ve updated my post’s language to match.

> While you can disable syntax highlighting when using fenced code blocks, you cannot modify the rendering of indented code blocks.

Darn, good to know. It kind of makes sense that a tool (and a spec) that’s built for developers would prioritize code block generation over flexibility content editors.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [August 31, 2022, 12:50pm UTC](https://discourse.gohugo.io/t/preventing-code-block-generation-from-indented-en-toml-entries/40237/8 "2022-08-31T12:50:17Z")

</div>

Closed on August 31, 2022, 12:50pm UTC

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
