diff --git a/markdown/blockprocessors.py b/markdown/blockprocessors.py index 8518e50f5..dac3f086a 100644 --- a/markdown/blockprocessors.py +++ b/markdown/blockprocessors.py @@ -559,7 +559,7 @@ def run(self, parent, blocks): class ReferenceProcessor(BlockProcessor): """ Process link references. """ RE = re.compile( - r'^[ ]{0,3}\[([^\]]*)\]:[ ]*\n?[ ]*([^\s]+)[ ]*\n?[ ]*((["\'])(.*)\4|\((.*)\))?[ ]*$', re.MULTILINE + r'^[ ]{0,3}\[([^\]]*)\]:[ ]*\n?[ ]*([^\s]+)[ ]*(?:\n[ ]*)?((["\'])(.*)\4[ ]*|\((.*)\)[ ]*)?$', re.MULTILINE ) def test(self, parent, block): diff --git a/markdown/extensions/fenced_code.py b/markdown/extensions/fenced_code.py index 716b46772..04c249e6d 100644 --- a/markdown/extensions/fenced_code.py +++ b/markdown/extensions/fenced_code.py @@ -42,13 +42,13 @@ def extendMarkdown(self, md): class FencedBlockPreprocessor(Preprocessor): FENCED_BLOCK_RE = re.compile( dedent(r''' - (?P^(?:~{3,}|`{3,}))[ ]* # opening fence - ((\{(?P[^\}\n]*)\})?| # (optional {attrs} or - (\.?(?P[\w#.+-]*))?[ ]* # optional (.)lang - (hl_lines=(?P"|')(?P.*?)(?P=quot))?) # optional hl_lines) - [ ]*\n # newline (end of opening fence) - (?P.*?)(?<=\n) # the code block - (?P=fence)[ ]*$ # closing fence + (?P^(?:~{3,}|`{3,}))[ ]* # opening fence + ((\{(?P[^\}\n]*)\})| # (optional {attrs} or + (\.?(?P[\w#.+-]*)[ ]*)? # optional (.)lang + (hl_lines=(?P"|')(?P.*?)(?P=quot)[ ]*)?) # optional hl_lines) + \n # newline (end of opening fence) + (?P.*?)(?<=\n) # the code block + (?P=fence)[ ]*$ # closing fence '''), re.MULTILINE | re.DOTALL | re.VERBOSE )