Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions markdown/extensions/fenced_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ class FencedBlockPreprocessor(Preprocessor):
FENCED_BLOCK_RE = re.compile(r'''
(?P<fence>^(?:~{3,}|`{3,}))[ ]* # Opening ``` or ~~~
(\{?\.?(?P<lang>[\w#.+-]*))?[ ]* # Optional {, and lang
(?P<lang2>::[^}\n]*)? # Optional lang trailer (up to } or NL)
# Optional highlight lines, single- or double-quote-delimited
(hl_lines=(?P<quot>"|')(?P<hl_lines>.*?)(?P=quot))?[ ]*
}?[ ]*\n # Optional closing }
(?P<code>.*?)(?<=\n)
(?P=fence)[ ]*$''', re.MULTILINE | re.DOTALL | re.VERBOSE)
CODE_WRAP = '<pre><code%s>%s</code></pre>'
LANG_TAG = ' class="%s"'
LANG_TAG = ' class="%s%s"'

def __init__(self, md):
super().__init__(md)
Expand All @@ -66,7 +67,8 @@ def run(self, lines):
if m:
lang = ''
if m.group('lang'):
lang = self.LANG_TAG % m.group('lang')
lang = self.LANG_TAG % (m.group('lang'), m.group(
'lang2') or '')

# If config is not empty, then the codehighlite extension
# is enabled, so we call it to highlight the code
Expand Down