From 803ded62a17f93d1f3e0e63c4cdef78b1fb7e0dc Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Mon, 2 Feb 2009 21:36:50 -0500 Subject: 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. --- markdown/extensions/fenced_code.py | 10 +++++----- 1 file 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 ...

block two

- ... ~~~~{.html}''' + ... ~~~~''' >>> markdown.markdown(text, extensions=['fenced_code']) u'
block one\\n
\\n\\n
<p>block two</p>\\n
' @@ -64,7 +64,7 @@ import markdown, re # Global vars FENCED_BLOCK_RE = re.compile( \ - r'(?P^~{3,})[ ]*\n(?P.*?)(?P=fence)[ ]*(\{\.(?P[a-zA-Z0-9_-]*)\})?[ ]*$', + r'(?P^~{3,})[ ]*(\{?\.(?P[a-zA-Z0-9_-]*)\}?)?[ ]*\n(?P.*?)(?P=fence)[ ]*$', re.MULTILINE|re.DOTALL ) CODE_WRAP = '
%s
' -- cgit v1.2.3