summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/change_log/index.md1
-rw-r--r--markdown/postprocessors.py4
2 files changed, 4 insertions, 1 deletions
diff --git a/docs/change_log/index.md b/docs/change_log/index.md
index fe40094..d1f36c0 100644
--- a/docs/change_log/index.md
+++ b/docs/change_log/index.md
@@ -7,6 +7,7 @@ Under development: version 3.3.5 (a bug-fix release).
* Make the `slugify_unicode` function not remove diacritical marks (#1118).
* Fix `[toc]` detection when used with `nl2br` extension (#1160)
+* Re-use compiled regex for block level checks (#1169)
Feb 24, 2021: version 3.3.4 (a bug-fix release).
diff --git a/markdown/postprocessors.py b/markdown/postprocessors.py
index 2e572f6..f4fb924 100644
--- a/markdown/postprocessors.py
+++ b/markdown/postprocessors.py
@@ -65,6 +65,8 @@ class Postprocessor(util.Processor):
class RawHtmlPostprocessor(Postprocessor):
""" Restore raw html to the document. """
+ BLOCK_LEVEL_REGEX = re.compile(r'^\<\/?([^ >]+)')
+
def run(self, text):
""" Iterate over html stash and restore html. """
replacements = OrderedDict()
@@ -99,7 +101,7 @@ class RawHtmlPostprocessor(Postprocessor):
return self.run(processed_text)
def isblocklevel(self, html):
- m = re.match(r'^\<\/?([^ >]+)', html)
+ m = self.BLOCK_LEVEL_REGEX.match(html)
if m:
if m.group(1)[0] in ('!', '?', '@', '%'):
# Comment, php etc...