]> Cypherpunks repositories - gostls13.git/commitdiff
Distinguish between html generation and html quoting in godoc formatters.
authorRobert Griesemer <gri@golang.org>
Wed, 13 Jan 2010 23:18:56 +0000 (15:18 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 13 Jan 2010 23:18:56 +0000 (15:18 -0800)
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
lib/godoc/godoc.html
lib/godoc/package.html
lib/godoc/search.html
src/cmd/godoc/godoc.go

index b35da55d8d01c652f065402411561658312491b5..a94f249d91f87e34ac79ce399f6d2b39d92c4cd5 100644 (file)
@@ -18,7 +18,7 @@
 </tr>
 {.repeated section @}
 <tr>
-       <td align="left"><a href="{Name|html}{@|dir/}">{Name|html}{@|dir/}</a></td>
+       <td align="left"><a href="{Name|html-esc}{@|dir/}">{Name|html}{@|dir/}</a></td>
        <td></td>
        <td align="right">{Size|html}</td>
        <td></td>
index 56163e075e22704f1f13e6e2a1d49b8f0fae150f..5f5cf310fd37fd381ca42339115cdc60b7d72d51 100644 (file)
     <li class="blank">&nbsp;</li>
     <li class="navhead">Go code search</li>
     <form method="GET" action="/search" class="search">
-    <input type="search" name="q" value="{Query|html}" size="25" style="width:80%; max-width:200px" />
+    <input type="search" name="q" value="{Query|html-esc}" size="25" style="width:80%; max-width:200px" />
     <input type="submit" value="Go" />
     </form>
 
index 99e588cfd54ccb4d98c27425873e49934889807a..6a799c2fd8da10a627304de07ec35fd945613218 100644 (file)
@@ -16,7 +16,7 @@
                        <h4>Package files</h4>
                        <span style="font-size:90%">
                        {.repeated section @}
-                               <a href="/{FilePath|html}/{@|html}">{@|html}</a>
+                               <a href="/{FilePath|html-esc}/{@|html-esc}">{@|html}</a>
                        {.end}
                        </span>
                        </p>
        {.end}
        {.section Funcs}
                {.repeated section @}
-                       <h2 id="{Name|html}">func <a href="{Decl|link}">{Name|html}</a></h2>
+                       <h2 id="{Name|html-esc}">func <a href="{Decl|link}">{Name|html}</a></h2>
                        <p><code>{Decl|html}</code></p>
                        {Doc|html-comment}
                {.end}
        {.end}
        {.section Types}
                {.repeated section @}
-                       <h2 id="{Type.Name|html}">type <a href="{Decl|link}">{Type.Name|html}</a></h2>
+                       <h2 id="{Type.Name|html-esc}">type <a href="{Decl|link}">{Type.Name|html}</a></h2>
                        {Doc|html-comment}
                        <p><pre>{Decl|html}</pre></p>
                        {.repeated section Consts}
                                <pre>{Decl|html}</pre>
                        {.end}
                        {.repeated section Factories}
-                               <h3 id="{Type.Name|html}.{Name|html}">func <a href="{Decl|link}">{Name|html}</a></h3>
+                               <h3 id="{Type.Name|html-esc}.{Name|html-esc}">func <a href="{Decl|link}">{Name|html}</a></h3>
                                <p><code>{Decl|html}</code></p>
                                {Doc|html-comment}
                        {.end}
                        {.repeated section Methods}
-                               <h3 id="{Type.Name|html}.{Name|html}">func ({Recv|html}) <a href="{Decl|link}">{Name|html}</a></h3>
+                               <h3 id="{Type.Name|html-esc}.{Name|html-esc}">func ({Recv|html}) <a href="{Decl|link}">{Name|html}</a></h3>
                                <p><code>{Decl|html}</code></p>
                                {Doc|html-comment}
                        {.end}
@@ -80,7 +80,7 @@
        <p>
        <table class="layout">
        <tr>
-       <th align="left" colspan="{MaxHeight|html}">Name</th>
+       <th align="left" colspan="{MaxHeight|html-esc}">Name</th>
        <td width="25">&nbsp;</td>
        <th align="left">Synopsis</th>
        </tr>
@@ -90,7 +90,7 @@
        {.repeated section List}
                <tr>
                {Depth|padding}
-               <td align="left" colspan="{Height|html}"><a href="{Path|html}">{Name|html}<a></td>
+               <td align="left" colspan="{Height|html-esc}"><a href="{Path|html-esc}">{Name|html}<a></td>
                <td></td>
                <td align="left">{Synopsis|html}</td>
                </tr>
index d82e52e8af8327a74d9ba3897a8910415c65776c..254f9b66f3a2ed7ca5f20f899050f24c41c9797a 100644 (file)
@@ -14,7 +14,7 @@
        <p>
        <span class="alert" style="font-size:120%">Did you mean: </span>
        {.repeated section Alts}
-               <a href="search?q={@|html}" style="font-size:120%">{@|html}</a>
+               <a href="search?q={@|html-esc}" style="font-size:120%">{@|html}</a>
        {.end}
        </p>
 {.end}
@@ -26,7 +26,7 @@
                        {.repeated section Files}
                                {.repeated section Groups}
                                        {.repeated section Infos}
-                                               <a href="{File.Path|html}?h={Query|html}#L{@|infoLine}">{File.Path|html}:{@|infoLine}</a>
+                                               <a href="{File.Path|html-esc}?h={Query|html-esc}#L{@|infoLine}">{File.Path|html}:{@|infoLine}</a>
                                                <pre>{@|infoSnippet}</pre>
                                        {.end}
                                {.end}
@@ -38,7 +38,7 @@
                {.repeated section @}
                        <h3 id="Local_{Pak.Path|path}">package <a href="{Pak.Path|path}">{Pak.Name|html}</a></h3>
                        {.repeated section Files}
-                               <a href="{File.Path|html}?h={Query|html}">{File.Path|html}</a>
+                               <a href="{File.Path|html-esc}?h={Query|html-esc}">{File.Path|html}</a>
                                <table class="layout">
                                {.repeated section Groups}
                                        <tr>
@@ -47,7 +47,7 @@
                                        <td align="left" width="4"></td>
                                        <td>
                                        {.repeated section Infos}
-                                               <a href="{File.Path|html}?h={Query|html}#L{@|infoLine}">{@|infoLine}</a>
+                                               <a href="{File.Path|html-esc}?h={Query|html-esc}#L{@|infoLine}">{@|infoLine}</a>
                                        {.end}
                                        </td>
                                        </tr>
index b590cd29712bcb0dca84f4f3dea5779ac928f49f..df0f948ade91883dfbeaaf45178d14441e7f84b3 100644 (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,