hugo: Indented `highlight` shortcode brings in the indentation as part of the code block

  • When using the highlight shortcode for code blocks in lists, the indentation needed to have the code blocks indented gets added to the code block itself.
  • This does not happen when using code fences.

So the bug seems to be localized to Hugo and not Blackfriday.

Here is a test page demonstrating the bug:

In the same test page above, the first section has the same code blocks, but done using the code fences, where that extra indentation issue is not seen.

Another effect of not removing that indentation is that the indentation before the closing {{< /highlight >}} creates an extra blank line in the final HTML.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 28 (24 by maintainers)

Commits related to this issue

Most upvoted comments

How do we upvote this one… I’m guessing it’s a weird use case in a blog, but in technical documentation, it’s common to have indented code blocks within numbered lists, for example. We’re trying to use readFile within those blocks, and this sure breaks that in a hurry.

@bep can you please add this issue to a near term milestone. This particular issue prevents me from using highlight shortcode in lists (which I seem to end up using a lot more than general, I think).

Also, I don’t have any outside-hugo workaround for this.

Thanks.