diff options
author | Waylan Limberg <waylan@gmail.com> | 2011-12-28 08:00:23 -0800 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2011-12-28 08:00:23 -0800 |
commit | 4daad37ae0108e2f5459d93b97202af39b4dd935 (patch) | |
tree | 9bf7277aff5877088260e9f49be0ebe4ad5c6455 | |
parent | eb1c507ef4621c75d349457f38615c1374a274a8 (diff) | |
parent | 4c7c189ae3d32f0cc947c78c1b116539b2ca0bf6 (diff) | |
download | markdown-4daad37ae0108e2f5459d93b97202af39b4dd935.tar.gz markdown-4daad37ae0108e2f5459d93b97202af39b4dd935.tar.bz2 markdown-4daad37ae0108e2f5459d93b97202af39b4dd935.zip |
Merge pull request #67 from fiesta/master
Allow backticks in addition to tildes for code blocks in the fenced_code extension
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | markdown/extensions/fenced_code.py | 14 | ||||
-rw-r--r-- | tests/extensions/test.cfg | 2 |
3 files changed, 16 insertions, 2 deletions
@@ -7,3 +7,5 @@ dist/* tmp/* MANIFEST .venv +*~ +#* diff --git a/markdown/extensions/fenced_code.py b/markdown/extensions/fenced_code.py index e5b3350..5a50ba3 100644 --- a/markdown/extensions/fenced_code.py +++ b/markdown/extensions/fenced_code.py @@ -49,6 +49,18 @@ Language tags: <pre><code class="python"># Some python code </code></pre> +Optionally backticks instead of tildes as per how github's code block markdown is identified: + + >>> text = ''' + ... ````` + ... # Arbitrary code + ... ~~~~~ # these tildes will not close the block + ... `````''' + >>> print markdown.markdown(text, extensions=['fenced_code']) + <pre><code># Arbitrary code + ~~~~~ # these tildes will not close the block + </code></pre> + Copyright 2007-2008 [Waylan Limberg](http://achinghead.com/). Project website: <http://www.freewisdom.org/project/python-markdown/Fenced__Code__Blocks> @@ -69,7 +81,7 @@ from markdown.extensions.codehilite import CodeHilite, CodeHiliteExtension # Global vars FENCED_BLOCK_RE = re.compile( \ - r'(?P<fence>^~{3,})[ ]*(\{?\.(?P<lang>[a-zA-Z0-9_-]*)\}?)?[ ]*\n(?P<code>.*?)(?P=fence)[ ]*$', + r'(?P<fence>^(?:~{3,}|`{3,}))[ ]*(\{?\.(?P<lang>[a-zA-Z0-9_-]*)\}?)?[ ]*\n(?P<code>.*?)(?P=fence)[ ]*$', re.MULTILINE|re.DOTALL ) CODE_WRAP = '<pre><code%s>%s</code></pre>' diff --git a/tests/extensions/test.cfg b/tests/extensions/test.cfg index 671f2a5..c25bdfb 100644 --- a/tests/extensions/test.cfg +++ b/tests/extensions/test.cfg @@ -4,7 +4,7 @@ extensions=attr_list [codehilite] extensions=codehilite # This passes or not based on version of pygments. -skip=1 +skip=1 [toc] extensions=toc |