Hugo 0.60.0 Raw HTML omitted Issue

I’ve just upgraded to 0.60.0 and have a problem.

I have a shortcode that is simply a wrapper for tables.

<div class="table wide">{{- .Inner | markdownify -}}</div>

For standard markdown tables everything works fine. However, when I use a HTML table nothing appears. Instead in the html source I see:

Raw HTML omitted

Is there something I have overlooked?

1 Like

Same question. A workaround seems to enable the unsafe mode:

markup:
  goldmark:
    renderer:
      unsafe: true

But this would be required for quite many sites, wouldn’t it?

1 Like

Probably.

So, you can set unsafe: true. But you can also use the {{< delimiter when including the shortcode in the page. This may or may not be what you want.

2 Likes

That helps alot. Thanks Bep and Guite.

This looks promising for me :slight_smile:
Example:

{{< bsrow >}}
{{% bsgrid class="col-md-7" %}}
Some markdown
{{% /bsgrid %}}
{{% bsgrid class="col-md-5 sidebar" %}}
Some markdown
{{% /bsgrid %}}
{{< /bsrow >}}

I have considered the default settings carefully. Mostly to match Blackfriday’s, but setting unsafe: true is something each user have to decide.

Also, I have an open issue about adding Bluemonday – which is a better HTML sanitizer.

Also note that if you own/control the content, setting unsafe: true is perfectly safe.

2 Likes

But note that the caveat is that the rendered shortcode will not be part of the “outer rendering” (so to speak), which is not optimal if they contain headings/footnotes that needs to be in the ToC etc.

I’m not sure what the solution here is? I am already using the delimiter in the markdown file but still get the omission issue. What are you suggesting to do?

Thanks Guite.

For config.toml use this
[markup.goldmark.renderer]
unsafe = true

1 Like

Is it possible to support multiple layouts directory like how static works? I like the unsafe = false direction but there are situations where I want certain partials to be privatized.

Disclaimer: I’m maintaining a Hugo Theme which has its own Hugo site generator hosting the page. Things like Paypal button broke but can be solved nicely using partials and short-code.

Just in case anyone find this post like me looking for a way to add HTML to their markdown page, I ended up doing the following…

Create a custom shortcode called something like raw-html.html with the contents:

{{ .Inner }}

Then wrap your HTML in your content like so:

{{< raw-html >}}
<video width="480" height="480" autoplay muted loop playsinline>
  <source src="https://i.giphy.com/media/687qS11pXwjCM/giphy.mp4" type="video/mp4" />
  Your browser does not support the video tag.
</video>
{{< / raw-html >}}

Not saying this is a good idea or solution, but it seems to work.

I am using this one in my config file (src/config.toml):

[markup.goldmark.renderer]
  unsafe= true

And it works!

Documentation about this “feature” (issue):

This topic was automatically closed after 31 hours. New replies are no longer allowed.