mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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:
parent
6ae763a727
commit
27be2915f3
5 changed files with 22 additions and 13 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue