diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/go/html%2Findex.html | |
new repository
Diffstat (limited to 'devdocs/go/html%2Findex.html')
| -rw-r--r-- | devdocs/go/html%2Findex.html | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/devdocs/go/html%2Findex.html b/devdocs/go/html%2Findex.html new file mode 100644 index 00000000..27643e64 --- /dev/null +++ b/devdocs/go/html%2Findex.html @@ -0,0 +1,23 @@ +<h1> Package html </h1> <ul id="short-nav"> +<li><code>import "html"</code></li> +<li><a href="#pkg-overview" class="overviewLink">Overview</a></li> +<li><a href="#pkg-index" class="indexLink">Index</a></li> +<li><a href="#pkg-examples" class="examplesLink">Examples</a></li> +<li><a href="#pkg-subdirectories">Subdirectories</a></li> +</ul> <h2 id="pkg-overview">Overview </h2> <p>Package html provides functions for escaping and unescaping HTML text. </p> <h2 id="pkg-index">Index </h2> <ul id="manual-nav"> +<li><a href="#EscapeString">func EscapeString(s string) string</a></li> +<li><a href="#UnescapeString">func UnescapeString(s string) string</a></li> +</ul> <div id="pkg-examples"> <h3>Examples</h3> <dl> <dd><a class="exampleLink" href="#example_EscapeString">EscapeString</a></dd> <dd><a class="exampleLink" href="#example_UnescapeString">UnescapeString</a></dd> </dl> </div> <h3>Package files</h3> <p> <span>entity.go</span> <span>escape.go</span> </p> <h2 id="EscapeString">func <span>EscapeString</span> </h2> <pre data-language="go">func EscapeString(s string) string</pre> <p>EscapeString escapes special characters like "<" to become "&lt;". It escapes only five such characters: <, >, &, ' and ". UnescapeString(EscapeString(s)) == s always holds, but the converse isn't always true. </p> <h4 id="example_EscapeString"> <span class="text">Example</span> +</h4> <p>Code:</p> <pre class="code" data-language="go">const s = `"Fran & Freddie's Diner" <tasty@example.com>` +fmt.Println(html.EscapeString(s)) +</pre> <p>Output:</p> <pre class="output" data-language="go">&#34;Fran &amp; Freddie&#39;s Diner&#34; &lt;tasty@example.com&gt; +</pre> <h2 id="UnescapeString">func <span>UnescapeString</span> </h2> <pre data-language="go">func UnescapeString(s string) string</pre> <p>UnescapeString unescapes entities like "&lt;" to become "<". It unescapes a larger range of entities than EscapeString escapes. For example, "&aacute;" unescapes to "รก", as does "&#225;" and "&#xE1;". UnescapeString(EscapeString(s)) == s always holds, but the converse isn't always true. </p> <h4 id="example_UnescapeString"> <span class="text">Example</span> +</h4> <p>Code:</p> <pre class="code" data-language="go">const s = `&quot;Fran &amp; Freddie&#39;s Diner&quot; &lt;tasty@example.com&gt;` +fmt.Println(html.UnescapeString(s)) +</pre> <p>Output:</p> <pre class="output" data-language="go">"Fran & Freddie's Diner" <tasty@example.com> +</pre> <h2 id="pkg-subdirectories">Subdirectories</h2> <div class="pkg-dir"> <table> <tr> <th class="pkg-name">Name</th> <th class="pkg-synopsis">Synopsis</th> </tr> <tr> <td colspan="2"><a href="../index">..</a></td> </tr> <tr> <td class="pkg-name"> <a href="template/index">template</a> </td> <td class="pkg-synopsis"> Package template (html/template) implements data-driven templates for generating HTML output safe against code injection. </td> </tr> </table> </div><div class="_attribution"> + <p class="_attribution-p"> + © Google, Inc.<br>Licensed under the Creative Commons Attribution License 3.0.<br> + <a href="http://golang.org/pkg/html/" class="_attribution-link">http://golang.org/pkg/html/</a> + </p> +</div> |
