I might want to use <span>
or <p class='foobar'>
This code
{{- with .Content}}
<p class="book-notes">
{{ . }}
</p>
{{end -}}
leads to this html:
<p class="book-notes">
</p><p>My content</p>
<p></p>
I might want to use <span>
or <p class='foobar'>
This code
{{- with .Content}}
<p class="book-notes">
{{ . }}
</p>
{{end -}}
leads to this html:
<p class="book-notes">
</p><p>My content</p>
<p></p>
If .Content
is <p>something</p>
then the resulting HTML is what most of the HTML parsers and creators would create. You should post more context of your code to receive a solution. Maybe use .Plain
or plainify
if you know it’s less than one paragraph.
.Content is just the content of a markdown file.
I don’t want to remove other markup, just the wrapping paragraph
.Content
is the parsed content of a markdown file. .Plain
is the unrendered content of a markdown file. As in no p-tags. Probably. But unknown setup could change this assumption.
According to the documentation .Plain / plainify is the content without any html tags, not just p-tags. I just want to strip it of the most outer tag, or actually change it to p with a class
Well, then check the documentation on markdownify and trim and create a combined solution that takes your plain markdown, then trims empty lines from each end and then transforms it into HTML. Hugo wouldn’t add p-tags if it would be more than one paragraph in those markdown files.
Well, then check the documentation on .RawContent, markdownify and trim and use them to create a combined solution that takes your plain markdown, then trims empty lines from each end and then transforms it into HTML. Hugo wouldn’t add p-tags if it would be more than one paragraph in those markdown files.
Thanks, I’ll have a look