Replace generated content / post processing hooks?

Is there any way to replace the html content generated before it is saved to disk?

I use pure-css and want my tables to automatically specify a few classes. Before moving to hugo, I could simply add {.classname} after a markdown block and nanoc would include those classes. I understand goldmark doesn’t support this.

I have tried a bunch of things, and the following gets me close

{{ replace .Content "<table>" "<table class='pure-table pure-table-striped'>" | markdownify}}

which works if I set config.toml to contain

      unsafe = true

However, the | markdownify then causes the chroma syntax highlighting to break as it messes up the spacing in my code blocks.

Is there a better solution? Perhaps creating a post-processing hook?

No need to markdownify again. The ouput of .Content is already processed by goldmark.

And yes, you need to use unsafe = true option.

Unfortunately, looks like markdownify is needed. Without it, the output displays the html tags as well.

Use safeHTML.

{{ replace .Content "<table>" "<table class='pure-table pure-table-striped'>" | safeHTML }}

That did the trick! Thanks!