From 27be2915f361d1c7904c61f492c1471dea41c2cc Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 13 Jan 2010 15:18:56 -0800 Subject: [PATCH] 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 --- lib/godoc/dirlist.html | 2 +- lib/godoc/godoc.html | 2 +- lib/godoc/package.html | 14 +++++++------- lib/godoc/search.html | 8 ++++---- src/cmd/godoc/godoc.go | 9 +++++++++ 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/lib/godoc/dirlist.html b/lib/godoc/dirlist.html index b35da55d8d0..a94f249d91f 100644 --- a/lib/godoc/dirlist.html +++ b/lib/godoc/dirlist.html @@ -18,7 +18,7 @@ {.repeated section @} - {Name|html}{@|dir/} + {Name|html}{@|dir/} {Size|html} diff --git a/lib/godoc/godoc.html b/lib/godoc/godoc.html index 56163e075e2..5f5cf310fd3 100644 --- a/lib/godoc/godoc.html +++ b/lib/godoc/godoc.html @@ -106,7 +106,7 @@
  •  
  • diff --git a/lib/godoc/package.html b/lib/godoc/package.html index 99e588cfd54..6a799c2fd8d 100644 --- a/lib/godoc/package.html +++ b/lib/godoc/package.html @@ -16,7 +16,7 @@

    Package files

    {.repeated section @} - {@|html} + {@|html} {.end}

    @@ -38,14 +38,14 @@ {.end} {.section Funcs} {.repeated section @} -

    func {Name|html}

    +

    func {Name|html}

    {Decl|html}

    {Doc|html-comment} {.end} {.end} {.section Types} {.repeated section @} -

    type {Type.Name|html}

    +

    type {Type.Name|html}

    {Doc|html-comment}

    {Decl|html}

    {.repeated section Consts} @@ -57,12 +57,12 @@
    {Decl|html}
    {.end} {.repeated section Factories} -

    func {Name|html}

    +

    func {Name|html}

    {Decl|html}

    {Doc|html-comment} {.end} {.repeated section Methods} -

    func ({Recv|html}) {Name|html}

    +

    func ({Recv|html}) {Name|html}

    {Decl|html}

    {Doc|html-comment} {.end} @@ -80,7 +80,7 @@

    - + @@ -90,7 +90,7 @@ {.repeated section List} {Depth|padding} - + diff --git a/lib/godoc/search.html b/lib/godoc/search.html index d82e52e8af8..254f9b66f3a 100644 --- a/lib/godoc/search.html +++ b/lib/godoc/search.html @@ -14,7 +14,7 @@

    Did you mean: {.repeated section Alts} - {@|html} + {@|html} {.end}

    {.end} @@ -26,7 +26,7 @@ {.repeated section Files} {.repeated section Groups} {.repeated section Infos} - {File.Path|html}:{@|infoLine} + {File.Path|html}:{@|infoLine}
    {@|infoSnippet}
    {.end} {.end} @@ -38,7 +38,7 @@ {.repeated section @}

    package {Pak.Name|html}

    {.repeated section Files} - {File.Path|html} + {File.Path|html}
    NameName   Synopsis
    {Name|html}{Name|html} {Synopsis|html}
    {.repeated section Groups} @@ -47,7 +47,7 @@ diff --git a/src/cmd/godoc/godoc.go b/src/cmd/godoc/godoc.go index b590cd29712..df0f948ade9 100644 --- a/src/cmd/godoc/godoc.go +++ b/src/cmd/godoc/godoc.go @@ -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,
    {.repeated section Infos} - {@|infoLine} + {@|infoLine} {.end}