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
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?
Is there a config entry to globally prevent all code block generation?
Example entry so you can test locally
[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 }}
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.
Just to make sure we’re using the correct terminology, text indented with four or more spaces is an indented code block — there is no syntax highlighting. Syntax highlighting is achieved with fenced code blocks.
While you can disable syntax highlighting when using fenced code blocks, you cannot modify the rendering of indented code blocks.
@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.