diff options
author | Waylan Limberg <waylan@gmail.com> | 2009-02-02 21:36:50 -0500 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2009-02-02 21:36:50 -0500 |
commit | 803ded62a17f93d1f3e0e63c4cdef78b1fb7e0dc (patch) | |
tree | bdfe8738906e5b5a07715c9c86fac5d16a8a8d6d | |
parent | be6891a22f6888af302392bc2dfa1e4a6099fd4f (diff) | |
download | markdown-803ded62a17f93d1f3e0e63c4cdef78b1fb7e0dc.tar.gz markdown-803ded62a17f93d1f3e0e63c4cdef78b1fb7e0dc.tar.bz2 markdown-803ded62a17f93d1f3e0e63c4cdef78b1fb7e0dc.zip |
Updated fenced_code extension to fit in with consensious on Markdown list. Language is defined on first line rather than last, and currly brackets around language are optional.
-rw-r--r-- | markdown/extensions/fenced_code.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/markdown/extensions/fenced_code.py b/markdown/extensions/fenced_code.py index d758f7b..307b1dc 100644 --- a/markdown/extensions/fenced_code.py +++ b/markdown/extensions/fenced_code.py @@ -37,13 +37,13 @@ Include tilde's in a code block and wrap with blank lines: Multiple blocks and language tags: >>> text = ''' - ... ~~~~ - ... block one ... ~~~~{.python} - ... + ... block one ... ~~~~ + ... + ... ~~~~.html ... <p>block two</p> - ... ~~~~{.html}''' + ... ~~~~''' >>> markdown.markdown(text, extensions=['fenced_code']) u'<pre><code class="python">block one\\n</code></pre>\\n\\n<pre><code class="html"><p>block two</p>\\n</code></pre>' @@ -64,7 +64,7 @@ import markdown, re # Global vars FENCED_BLOCK_RE = re.compile( \ - r'(?P<fence>^~{3,})[ ]*\n(?P<code>.*?)(?P=fence)[ ]*(\{\.(?P<lang>[a-zA-Z0-9_-]*)\})?[ ]*$', + r'(?P<fence>^~{3,})[ ]*(\{?\.(?P<lang>[a-zA-Z0-9_-]*)\}?)?[ ]*\n(?P<code>.*?)(?P=fence)[ ]*$', re.MULTILINE|re.DOTALL ) CODE_WRAP = '<pre><code%s>%s</code></pre>' |