summaryrefslogtreecommitdiff
path: root/devdocs/python~3.12/library%2Fhtml.html
blob: e6faf9f953df38598d574f5dc854697e0fbcdc6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 <span id="html-hypertext-markup-language-support"></span><h1>html — HyperText Markup Language support</h1> <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/html/__init__.py">Lib/html/__init__.py</a></p>  <p>This module defines utilities to manipulate HTML.</p> <dl class="py function"> <dt class="sig sig-object py" id="html.escape">
<code>html.escape(s, quote=True)</code> </dt> <dd>
<p>Convert the characters <code>&amp;</code>, <code>&lt;</code> and <code>&gt;</code> in string <em>s</em> to HTML-safe sequences. Use this if you need to display text that might contain such characters in HTML. If the optional flag <em>quote</em> is true, the characters (<code>"</code>) and (<code>'</code>) are also translated; this helps for inclusion in an HTML attribute value delimited by quotes, as in <code>&lt;a href="..."&gt;</code>.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.2.</span></p> </div> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="html.unescape">
<code>html.unescape(s)</code> </dt> <dd>
<p>Convert all named and numeric character references (e.g. <code>&amp;gt;</code>, <code>&amp;#62;</code>, <code>&amp;#x3e;</code>) in the string <em>s</em> to the corresponding Unicode characters. This function uses the rules defined by the HTML 5 standard for both valid and invalid character references, and the <a class="reference internal" href="html.entities#html.entities.html5" title="html.entities.html5"><code>list of
HTML 5 named character references</code></a>.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.4.</span></p> </div> </dd>
</dl>  <p>Submodules in the <code>html</code> package are:</p> <ul class="simple"> <li>
<a class="reference internal" href="html.parser#module-html.parser" title="html.parser: A simple parser that can handle HTML and XHTML."><code>html.parser</code></a> – HTML/XHTML parser with lenient parsing mode</li> <li>
<a class="reference internal" href="html.entities#module-html.entities" title="html.entities: Definitions of HTML general entities."><code>html.entities</code></a> – HTML entity definitions</li> </ul> <div class="_attribution">
  <p class="_attribution-p">
    &copy; 2001&ndash;2023 Python Software Foundation<br>Licensed under the PSF License.<br>
    <a href="https://docs.python.org/3.12/library/html.html" class="_attribution-link">https://docs.python.org/3.12/library/html.html</a>
  </p>
</div>