Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > 475047415fcf83c129d0834cea9418c4 > files > 141

python3-markdown-2.4.1-4.mga5.noarch.rpm

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Table of Contents Extension &#8212; Python Markdown</title>
<link rel="stylesheet" href="../default.css" type="text/css">
</head>
<body>

<div class="related">
  <h3>Navigation</h3>
  <ul>
    <li class="right" style="margin-right: 10px">
      <a href="../siteindex.html" title="General Index">index</a></li>
    <li class="right">
      <a href="wikilinks.html" title="WikiLinks Extension"
         accesskey="N">next</a> |</li>
    <li class="right">
      <a href="smarty.html" title="SmartyPants Extension"
         accesskey="P">previous</a> |</li>
    <li><img src="../py.png" alt=""
             style="vertical-align: middle; margin-top: -1px"/></li>
    <li><a href="../index.html">Python Markdown v2.4.1 documentation</a> &raquo;</li>
    <li><a href="index.html">Extensions</a> &raquo;</li>
<li><a href="toc.html">Table of Contents Extension</a> &raquo;</li>
  </ul>
</div> <!-- .related -->

<div class="document">
  <div class="documentwrapper">
    <div class="bodywrapper">
      <div class="body">
<h1 id="table-of-contents">Table of Contents<a class="headerlink" href="#table-of-contents" title="Permanent link">&para;</a></h1>
<h2 id="summary">Summary<a class="headerlink" href="#summary" title="Permanent link">&para;</a></h2>
<p>The Table of Contents extension generates a Table of Contents from a Markdown
document and adds it into the resulting HTML document.</p>
<p>This extension is included in the standard Markdown library.</p>
<h2 id="syntax">Syntax<a class="headerlink" href="#syntax" title="Permanent link">&para;</a></h2>
<p>Place a marker in the document where you would like the Table of Contents to
appear. Then, a nested list of all the headers in the document will replace the
marker. The marker defaults to <code>[TOC]</code> so the following document:</p>
<pre><code>[TOC]

# Header 1

## Header 2
</code></pre>
<p>would generate the following output:</p>
<pre><code>&lt;div class="toc"&gt;
  &lt;ul&gt;
    &lt;li&gt;&lt;a href="#header-1"&gt;Header 1&lt;/a&gt;&lt;/li&gt;
      &lt;ul&gt;
        &lt;li&gt;&lt;a href="#header-2"&gt;Header 2&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/ul&gt;
&lt;/div&gt;
&lt;h1 id="header-1"&gt;Header 1&lt;/h1&gt;
&lt;h1 id="header-2"&gt;Header 2&lt;/h1&gt;
</code></pre>
<h2 id="usage">Usage<a class="headerlink" href="#usage" title="Permanent link">&para;</a></h2>
<p>See <a href="index.html">Extensions</a> for general extension usage, specify <code>toc</code>
as the name of the extension.</p>
<p>See the <a href="../reference.html#extensions">Library Reference</a> for information about
configuring extensions.</p>
<p>The following options are provided to configure the output:</p>
<ul>
<li>
<p><strong><code>marker</code></strong>:
    Text to find and replace with the Table of Contents. Defaults
    to <code>[TOC]</code>.</p>
<p>If a <code>marker</code> is not found in the document, then the Table of Contents is
available as an attribute of the Markdown class. This allows one to insert
the Table of Contents elsewhere in their page template. For example:</p>
<pre><code>&gt;&gt;&gt; text = '''
# Header 1

## Header 2
'''
&gt;&gt;&gt; md = markdown.Markdown(extensions=['toc'])
&gt;&gt;&gt; html = md.convert(text)
&gt;&gt;&gt; render_some_template(context={'body': html, 'toc': md.toc})
</code></pre>
</li>
<li>
<p><strong><code>slugify</code></strong>:
    Callable to generate anchors based on header text. Defaults to a built in
    <code>slugify</code> method. The callable must accept one argument which contains the
    text content of the header and return a string which will be used as the
    anchor text.</p>
</li>
<li>
<p><strong><code>title</code></strong>:
    Title to insert in the Table of Contents&rsquo; <code>&lt;div&gt;</code>. Defaults to <code>None</code>.</p>
</li>
<li>
<p><strong><code>anchorlink</code></strong>:
    Setting to <code>True</code> will cause the headers link to themselves. Default is
    <code>False</code>.</p>
</li>
<li>
<p><strong><code>permalink</code></strong>:
    Set to <code>True</code> to have this extension generate a Sphinx-style permanent links
    near the headers (for use with Sphinx stylesheets).</p>
</li>
</ul>
      </div> <!-- .body -->
    </div> <!-- .bodywrapper -->
  </div> <!-- .documentwrapper -->

  <div class="sphinxsidebar">
    <div class="sphinxsidebarwrapper">
    <h3>Table Of Contents</h3>
    <div class="toc">
<ul>
<li><a href="#table-of-contents">Table of Contents</a><ul>
<li><a href="#summary">Summary</a></li>
<li><a href="#syntax">Syntax</a></li>
<li><a href="#usage">Usage</a></li>
</ul>
</li>
</ul>
</div>


    <h4>Previous topic</h4>
      <p class="topless"><a href="smarty.html"
         title="previous chapter">SmartyPants Extension</a></p>
    <h4>Next topic</h4>
      <p class="topless"><a href="wikilinks.html"
         title="next chapter">WikiLinks Extension</a></p>
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="https://github.com/waylan/Python-Markdown/issues"
             >Report a Bug</a></li>
      <li><a href="toc.txt"
             rel="nofollow">Show Source</a></li>
    </ul>
    </div> <!-- .sphinxsidebarwrapper -->
  </div> <!-- .sphinxsidebar -->

  <div class="clearer"></div>
</div> <!-- .document -->

<div class="related">
  <h3>Navigation</h3>
  <ul>
    <li class="right" style="margin-right: 10px">
      <a href="../siteindex.html" title="General Index">index</a></li>
    <li class="right">
      <a href="wikilinks.html" title="WikiLinks Extension"
         accesskey="N">next</a> |</li>
    <li class="right">
      <a href="smarty.html" title="SmartyPants Extension"
         accesskey="P">previous</a> |</li>
    <li><img src="../py.png" alt=""
             style="vertical-align: middle; margin-top: -1px"/></li>
    <li><a href="../index.html">Python Markdown v2.4.1 documentation</a> &raquo;</li>
    <li><a href="index.html">Extensions</a> &raquo;</li>
<li><a href="toc.html">Table of Contents Extension</a> &raquo;</li>
  </ul>
</div> <!-- .related -->

<div class="footer">&copy; 2010-2012 Python Markdown Project</div>
</body>
</html>