From 69b365d07c7fabb206d9094398de2162cbcf6ba3 Mon Sep 17 00:00:00 2001 From: Mike Dirolf Date: Tue, 17 Jan 2012 16:52:39 -0500 Subject: Support github-flavored markdown by making the '.' optional before language type. --- markdown/extensions/fenced_code.py | 2 +- tests/extensions/github_flavored.html | 32 ++++++++++++++++++++++++++++++++ tests/extensions/github_flavored.txt | 34 ++++++++++++++++++++++++++++++++++ tests/extensions/test.cfg | 3 +++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 tests/extensions/github_flavored.html create mode 100644 tests/extensions/github_flavored.txt diff --git a/markdown/extensions/fenced_code.py b/markdown/extensions/fenced_code.py index 9b99e5a..95fe3b4 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^(?:~{3,}|`{3,}))[ ]*(\{?\.(?P[a-zA-Z0-9_-]*)\}?)?[ ]*\n(?P.*?)(?<=\n)(?P=fence)[ ]*$', + r'(?P^(?:~{3,}|`{3,}))[ ]*(\{?\.?(?P[a-zA-Z0-9_-]*)\}?)?[ ]*\n(?P.*?)(?<=\n)(?P=fence)[ ]*$', re.MULTILINE|re.DOTALL ) CODE_WRAP = '
%s
' diff --git a/tests/extensions/github_flavored.html b/tests/extensions/github_flavored.html new file mode 100644 index 0000000..60e16b1 --- /dev/null +++ b/tests/extensions/github_flavored.html @@ -0,0 +1,32 @@ +

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,
++```
+
\ No newline at end of file diff --git a/tests/extensions/github_flavored.txt b/tests/extensions/github_flavored.txt new file mode 100644 index 0000000..d0737bd --- /dev/null +++ b/tests/extensions/github_flavored.txt @@ -0,0 +1,34 @@ +index 0000000..6e956a9 + +```diff +--- /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 ++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 f3d0321..ebe9a8f 100644 --- a/tests/extensions/test.cfg +++ b/tests/extensions/test.cfg @@ -23,3 +23,6 @@ extensions=wikilinks [fenced_code] extensions=fenced_code + +[github_flavored] +extensions=codehilite,fenced_code -- cgit v1.2.3