Raw HTML Omitted in templates

I just found this code that I am adapting for my summaries. When I add the code below to it, I get raw HTML Omitted message where <sup></sup> should be. How can this be rectified?

| replaceRE `(\d+)\^(st|nd|rd|th)` "$1<sup>$2</sup>"

Try piping through safeHTML

I did before I posted. Didn’t work. Any ideas? cc @jmooring.

Are you calling the partial from a template, or from a shortcode?

Yes. From a template.

Are you passing something through markdownify or .Page.RenderString?

Yes for this option.

The <!-- raw HTML omitted --> HTML comment is generated by Goldmark when it renders markdown to HTML. By default it considers HTML mixed with markdown unsafe.

To change the default behavior:

[markup.goldmark.renderer]
unsafe = true

It’s not unsafe if you control the content.

But I wonder if you really need to pass whatever you’re doing through either of those functions.

Even without the functions, the raw HTML Omitted is also generated. I am using the code for List Pages.

Did you do this yet?

[markup.goldmark.renderer]
unsafe = true

Yes. But I’d rather not do it just for this one issue.

Without the function, some things break, e.g double quotes. But with or without the functions, the the raw HTML Omitted is also generated.

If you are getting this:

<!-- raw HTML omitted -->

But you will not do this:

[markup.goldmark.renderer]
unsafe = true

Then you need to change something else. And I can’t tell you what that is without seeing your project.

My mistake! I was applying safeHTML inside the partial (after all replaceRE occurrences) instead of the code calling the partial. I replaced $.Page.RenderString with safeHTML and it is now working.

{{ partial "summary.html" (dict "input" .Summary "maxLength" 180) | safeHTML  }}

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