Rendering shortcodes with custom output format, but no HTML

I have custom output format for text/markdown, that’s right rendering from Markdown to Markdown (alongside HTML website).

Then with a default single.md template, it actually adds extra markdown generated from YAML resources - which is why this is done with Hugo.

Now the problem comes with rendering of the content itself. It cannot be pulled with .Content as that would render HTML, but if it is .RawContent then of course nothing gets rendered, even the shortcodes are preserved.

This made sense to me originally and I had some post-processing done with other tools essentially “expanding” the basic shortcodes like ref and relref via regular expressions - doing what Hugo would have done with HTML.

But it became untenable in that e.g. it (the post-processing non-Hugo tool) cannot generate a file link to a transformed image because it does not know its name.

I wonder if I am conceptually missing something when I started thinking about overriding built-in templates so that they do not produce HTML.

On the surface, the requirement is simple:

  • Not render Markdown to HTML; but
  • Render shortcodes (understood that I will need to write my own for my output format)

Is this somehow possible?

EDIT: I originally thought that setting isHTML to false on the output format would do the trick, but apparently it only influences injecting e.g. LiveReload, not sure what else. I also have isPlainText set to true on that output format, but it appears to have no effect whatsoever.

EDIT2: I am now looking at .RenderShortcodes, not sure how I could have missed it.

.Page.RenderShortcodes (instead of .RawContent) is the answer!

The only thing left for me is to find out how to redefine the ref.md so that it actually gives me links to the HTML content and not the Markdown files. :slight_smile:

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