Distinguish between html generation and html quoting in godoc formatters.

Replacement for CL 184084; originally by Roger Peppe (rogpeppe@gmail.com).

R=rsc
CC=golang-dev, rog
https://golang.org/cl/189059
This commit is contained in:
Robert Griesemer 2010-01-13 15:18:56 -08:00
parent 6ae763a727
commit 27be2915f3
5 changed files with 22 additions and 13 deletions

View file

@ -587,6 +587,14 @@ func htmlFmt(w io.Writer, x interface{}, format string) {
}
// Template formatter for "html-esc" format.
func htmlEscFmt(w io.Writer, x interface{}, format string) {
var buf bytes.Buffer
writeAny(&buf, x, false)
template.HTMLEscape(w, buf.Bytes())
}
// Template formatter for "html-comment" format.
func htmlCommentFmt(w io.Writer, x interface{}, format string) {
var buf bytes.Buffer
@ -705,6 +713,7 @@ func dirslashFmt(w io.Writer, x interface{}, format string) {
var fmap = template.FormatterMap{
"": textFmt,
"html": htmlFmt,
"html-esc": htmlEscFmt,
"html-comment": htmlCommentFmt,
"path": pathFmt,
"link": linkFmt,