diff options
author | Mike Dirolf <mike@dirolf.com> | 2012-01-17 16:00:31 -0500 |
---|---|---|
committer | Mike Dirolf <mike@dirolf.com> | 2012-01-17 16:00:31 -0500 |
commit | a9179833ae458861d8a4d72336a1df4ee4f6d070 (patch) | |
tree | 28834aa8d4ee487878a786a9e36b83ef452a7e8e | |
parent | a2377e1129331430998de821ed3abf38247edca1 (diff) | |
download | markdown-a9179833ae458861d8a4d72336a1df4ee4f6d070.tar.gz markdown-a9179833ae458861d8a4d72336a1df4ee4f6d070.tar.bz2 markdown-a9179833ae458861d8a4d72336a1df4ee4f6d070.zip |
Fenced code blocks need to end with a fence on its own line.
-rw-r--r-- | markdown/extensions/fenced_code.py | 2 | ||||
-rw-r--r-- | tests/extensions/fenced_code.html | 32 | ||||
-rw-r--r-- | tests/extensions/fenced_code.txt | 34 | ||||
-rw-r--r-- | tests/extensions/test.cfg | 3 |
4 files changed, 70 insertions, 1 deletions
diff --git a/markdown/extensions/fenced_code.py b/markdown/extensions/fenced_code.py index 0534251..9b99e5a 100644 --- a/markdown/extensions/fenced_code.py +++ b/markdown/extensions/fenced_code.py @@ -81,7 +81,7 @@ from markdown.extensions.codehilite import CodeHilite, CodeHiliteExtension # Global vars FENCED_BLOCK_RE = re.compile( \ - r'(?P<fence>^(?:~{3,}|`{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>.*?)(?<=\n)(?P=fence)[ ]*$', re.MULTILINE|re.DOTALL ) CODE_WRAP = '<pre><code%s>%s</code></pre>' diff --git a/tests/extensions/fenced_code.html b/tests/extensions/fenced_code.html new file mode 100644 index 0000000..7b86e79 --- /dev/null +++ b/tests/extensions/fenced_code.html @@ -0,0 +1,32 @@ +<p>index 0000000..6e956a9</p> +<pre><code>--- /dev/null ++++ b/test/data/stripped_text/mike-30-lili +@@ -0,0 +1,27 @@ ++Summary: ++ drift_mod.py | 1 + ++ 1 files changed, 1 insertions(+), 0 deletions(-) ++ ++commit da4bfb04debdd994683740878d09988b2641513d ++Author: Mike Dirolf <mike@dirolf.com> ++Date: Tue Jan 17 13:42:28 2012 -0500 ++ ++``` ++minor: just wanted to push something. ++``` ++ ++diff --git a/drift_mod.py b/drift_mod.py ++index 34dfba6..8a88a69 100644 ++ ++``` ++--- a/drift_mod.py +++++ b/drift_mod.py ++@@ -281,6 +281,7 @@ CONTEXT_DIFF_LINE_PATTERN = re.compile(r'^(' ++ '|\+ .*' ++ '|- .*' ++ ')$') +++ ++ def wrap_context_diffs(message_text): ++ return _wrap_diff(CONTEXT_DIFF_HEADER_PATTERN, ++ CONTEXT_DIFF_LINE_PATTERN, ++``` +</code></pre>
\ No newline at end of file diff --git a/tests/extensions/fenced_code.txt b/tests/extensions/fenced_code.txt new file mode 100644 index 0000000..73c0337 --- /dev/null +++ b/tests/extensions/fenced_code.txt @@ -0,0 +1,34 @@ +index 0000000..6e956a9 + +``` +--- /dev/null ++++ b/test/data/stripped_text/mike-30-lili +@@ -0,0 +1,27 @@ ++Summary: ++ drift_mod.py | 1 + ++ 1 files changed, 1 insertions(+), 0 deletions(-) ++ ++commit da4bfb04debdd994683740878d09988b2641513d ++Author: Mike Dirolf <mike@dirolf.com> ++Date: Tue Jan 17 13:42:28 2012 -0500 ++ ++``` ++minor: just wanted to push something. ++``` ++ ++diff --git a/drift_mod.py b/drift_mod.py ++index 34dfba6..8a88a69 100644 ++ ++``` ++--- a/drift_mod.py +++++ b/drift_mod.py ++@@ -281,6 +281,7 @@ CONTEXT_DIFF_LINE_PATTERN = re.compile(r'^(' ++ '|\+ .*' ++ '|- .*' ++ ')$') +++ ++ def wrap_context_diffs(message_text): ++ return _wrap_diff(CONTEXT_DIFF_HEADER_PATTERN, ++ CONTEXT_DIFF_LINE_PATTERN, ++``` +``` diff --git a/tests/extensions/test.cfg b/tests/extensions/test.cfg index c25bdfb..f3d0321 100644 --- a/tests/extensions/test.cfg +++ b/tests/extensions/test.cfg @@ -20,3 +20,6 @@ extensions=toc [wikilinks] extensions=wikilinks + +[fenced_code] +extensions=fenced_code |