1
0
mirror of https://github.com/golang/go synced 2024-11-24 14:50:13 -07: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:
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

@ -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>

View File

@ -106,7 +106,7 @@
<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>

View 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>
@ -38,14 +38,14 @@
{.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}
@ -57,12 +57,12 @@
<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>

View 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>

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,