Sophie

Sophie

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

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

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Fenced Code Blocks 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="footnotes.html" title="Footnotes Extension"
         accesskey="N">next</a> |</li>
    <li class="right">
      <a href="definition_lists.html" title="Definition Lists 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="fenced_code_blocks.html">Fenced Code Blocks Extension</a> &raquo;</li>
  </ul>
</div> <!-- .related -->

<div class="document">
  <div class="documentwrapper">
    <div class="bodywrapper">
      <div class="body">
<h1 id="fenced-code-blocks">Fenced Code Blocks<a class="headerlink" href="#fenced-code-blocks" title="Permanent link">&para;</a></h1>
<h2 id="summary">Summary<a class="headerlink" href="#summary" title="Permanent link">&para;</a></h2>
<p>The Fenced Code Blocks extension adds a secondary way to define code blocks,
which overcomes a few limitations of the indented code blocks.</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>Fenced Code Blocks are defined using the syntax established in 
<a href="http://www.michelf.com/projects/php-markdown/extra/#fenced-code-blocks">PHP Markdown Extra</a>.</p>
<p>Thus, the following text (taken from the above referenced PHP documentation):</p>
<pre><code>This is a paragraph introducing:

~~~~~~~~~~~~~~~~~~~~
a one-line code block
~~~~~~~~~~~~~~~~~~~~
</code></pre>
<p>Fenced code blocks can have a blank line as the first  and/or last line of a 
code block and they can also come immediately after a list item without becoming
part of the list.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Fenced Code Blocks are only supported at the document root level.
Therefore, they cannot be nested inside lists or blockquotes.</p>
</div>
<h3 id="language">Language<a class="headerlink" href="#language" title="Permanent link">&para;</a></h3>
<p>In addition to PHP Extra&rsquo;s syntax, you can define the language of the code 
block for use by syntax highlighters etc. The language will be assigned as a 
class attribute of the <code>&lt;code&gt;</code> element in the output. Therefore, you should 
define the language as you would a css class - <code>.language</code>. For consistency 
with other markdown syntax, the language can <em>optionally</em> be wrapped in curly 
brackets:</p>
<pre><code>~~~~{.python}
# python code
~~~~

~~~~.html
&lt;p&gt;HTML Document&lt;/p&gt;
~~~~
</code></pre>
<p>The above will output:</p>
<pre><code>&lt;pre&gt;&lt;code class="python"&gt;# python code
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="html"&gt;&amp;lt;p&amp;gt;HTML Document&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
</code></pre>
<p><a href="http://github.github.com/github-flavored-markdown/">Github</a>&lsquo;s backtick (```) syntax is also supported:</p>
<pre><code>```python
# more python code
```
</code></pre>
<h3 id="emphasized-lines">Emphasized Lines<a class="headerlink" href="#emphasized-lines" title="Permanent link">&para;</a></h3>
<p>If you would like to have your fenced code blocks highlighted with the 
<a href="code_hilite.html">CodeHilite</a> extension, simply enable that extension (remember that
<a href="http://pygments.org/">Pygments</a> is its dependency) and the language of your fenced code blocks
will be passed in and highlighted appropriately.</p>
<p>Similar to the <a href="code_hilite.html#colons">colon</a> syntax of the CodeHilite extension, fenced code blocks
can also have emphasized certain lines of code.</p>
<p>The lines can be specified with PHP Extra&rsquo;s syntax:</p>
<pre><code>~~~~{.python hl_lines="1 3"}
# This line is emphasized
# This line isn't
# This line is emphasized
~~~~
</code></pre>
<p>&hellip; or with GitHub&rsquo;s:</p>
<pre><code>```python hl_lines="1 3"
# This line is emphasized
# This line isn't
# This line is emphasized
```
</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>fenced_code</code>
as the name of the extension.</p>
<p>This extension does not accept any special configuration options.</p>
      </div> <!-- .body -->
    </div> <!-- .bodywrapper -->
  </div> <!-- .documentwrapper -->

  <div class="sphinxsidebar">
    <div class="sphinxsidebarwrapper">
    <h3>Table Of Contents</h3>
    <div class="toc">
<ul>
<li><a href="#fenced-code-blocks">Fenced Code Blocks</a><ul>
<li><a href="#summary">Summary</a></li>
<li><a href="#syntax">Syntax</a><ul>
<li><a href="#language">Language</a></li>
<li><a href="#emphasized-lines">Emphasized Lines</a></li>
</ul>
</li>
<li><a href="#usage">Usage</a></li>
</ul>
</li>
</ul>
</div>


    <h4>Previous topic</h4>
      <p class="topless"><a href="definition_lists.html"
         title="previous chapter">Definition Lists Extension</a></p>
    <h4>Next topic</h4>
      <p class="topless"><a href="footnotes.html"
         title="next chapter">Footnotes 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="fenced_code_blocks.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="footnotes.html" title="Footnotes Extension"
         accesskey="N">next</a> |</li>
    <li class="right">
      <a href="definition_lists.html" title="Definition Lists 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="fenced_code_blocks.html">Fenced Code Blocks Extension</a> &raquo;</li>
  </ul>
</div> <!-- .related -->

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