I’m curious what the inaccuracies are, and suggest that the the full expected experience of these methods be a part of the clarity and completeness of the documentation.
Using these methods on HTML output seems to have at least the described effect in the commit, but I’m not aware of the other effects or when using JSON.
The value of .Plain is exactly what Goldmark produced after the HTML tags are stripped.
The left double quotation mark, right double quotation mark, and right single quotation mark are untouched as they pass through Goldmark, and then through Go’s text/template package.
The symbols as template pipelines are sanitized by Go’s html/template package.
The value of .Plain is exactly what Goldmark produced after the HTML tags are stripped and it is sanitized by Go’s html/template package.
The left double quotation mark, right double quotation mark, and right single quotation mark are untouched as they pass through Goldmark, and then through Go’s html/template package.
Summary
How you use .Plain in your templates depends on the output format, specifically the value of the isPlainText property, which controls whether we use pkg.go.dev/text/template or pkg.go.dev/html/template.
You may wish to pipe .Plain through the htmlUnescape function depending on what you are trying to achieve.
Testing
Feel free to try it yourself.
git clone --single-branch -b hugo-forum-topic-41335 https://github.com/jmooring/hugo-testing hugo-forum-topic-41335
cd hugo-forum-topic-41335
hugo --quiet && cat public/index.txt public/index.html
So I see that the TXT and HTML do not output the same exact thing from .Plain but currently in the docs there is no mention of any of this for any output format. So having what you’ve written here, as an expansion and clarification (replacement) on what I had originally made in the PR would solve the issue I was trying to solve. When I was playing with those methods, there was no context as to what to expect so I got very unexpected results because the normal behaviour wasn’t described. And you’ve done so clearly and deeply. So yea, this should be what the PR consists of. At the very worst case, have a link to this thread in the docs for .Plain and .PlainWords with a backreference in the htmlUnescape docs.
The description of .PlainWords references .Plain so I do not see a need to duplicate the information.
Finally, a description of the difference between output formats (text/template vs. html/template) belongs elsewhere, possibly near the description of the isPlainText property on this page.