aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/extensions/fenced_code.py
diff options
context:
space:
mode:
Diffstat (limited to 'markdown/extensions/fenced_code.py')
-rw-r--r--markdown/extensions/fenced_code.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/markdown/extensions/fenced_code.py b/markdown/extensions/fenced_code.py
index 64ff769..6ee6759 100644
--- a/markdown/extensions/fenced_code.py
+++ b/markdown/extensions/fenced_code.py
@@ -62,7 +62,7 @@ Optionally backticks instead of tildes as per how github's code block markdown i
If the codehighlite extension and Pygments are installed, lines can be highlighted:
>>> text = '''
- ... ```{1,3}
+ ... ```hl_lines="1 3"
... line 1
... line 2
... line 3
@@ -108,7 +108,10 @@ class FencedCodeExtension(Extension):
class FencedBlockPreprocessor(Preprocessor):
FENCED_BLOCK_RE = re.compile(r'''
-(?P<fence>^(?:~{3,}|`{3,}))[ ]*(\{?\.?(?P<lang>[a-zA-Z0-9_+-]*)\}?)?[ ]*(?P<hl_lines>\{.*?})?[ ]*\n
+(?P<fence>^(?:~{3,}|`{3,}))[ ]* # Opening ``` or ~~~
+(\{?\.?(?P<lang>[a-zA-Z0-9_+-]*))?[ ]* # Optional {, and lang
+(hl_lines="(?P<hl_lines>.*?)")?[ ]* # Optional highlight lines
+}?[ ]*\n # Optional closing }
(?P<code>.*?)(?<=\n)
(?P=fence)[ ]*$''', re.MULTILINE | re.DOTALL | re.VERBOSE)
CODE_WRAP = '<pre><code%s>%s</code></pre>'