aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--markdown/extensions/fenced_code.py14
-rw-r--r--tests/extensions/test.cfg2
3 files changed, 16 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index a00737a..ebf5e84 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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