Is is possible to manually render .RawContent?

Howdy,

while trying to customize content summaries, I’m hitting a wall. I was thinking I could take the .RawContent, insert some marker comments, have Hugo render the markup via markdownify and afterwards replace the markers to achieve the desired result.

Like this:

{{- $maxChunks := (cond (not (eq .Params.chunks nil)) .Params.chunks 3) -}}
{{- $chunks := split .RawContent "\n\n" -}}
{{- if ge (len $chunks) $maxChunks -}}
    {{- $result := slice -}}
    {{- range $i, $chunk := $chunks -}}
        {{- if eq $i $maxChunks -}}
          {{- $result = $result | append "<!--start-->" -}}
        {{- end -}}
        {{- $result = $result | append $chunk -}}
    {{- end -}}
    {{- $result = $result | append "<!--end-->" -}}
    {{- $text := (delimit $result "\n\n") | markdownify -}}
    {{- $text = strings.Replace $text "<!--start-->" "<details>\n<summary>More...<summary>" -}}
    {{- $text = strings.Replace $text "<!--end-->" "</details>" -}}
    {{ warnf "->%s<-" $text }}
{{- end -}}

Basically I want to be able to limit the content to a configurable number of paragraphs and hide the rest behind the HTML summary/details element.

Doing that with the raw markup would be easy. I can just look for empty lines and apply some simple string processing (see sample code above). Trying the same with the rendered content is more involved and I could not find a reliable way to deal with the HTML tags without a full HTML parser.

Therefore my question: Is there a way to have Hugo manually process the .RawContent to yield the same result as with .Content, i.e. process my shortcodes?

I’ve read somewhere that markdownify is only meant for templates and there is no intention to include shortcode processing, but maybe there is another way I don’t see?

No. See:

Thanks much for the pointers. Glad to see that Hugo might support this use case in the future. Seems there is a lot of interest.