From 96d27f191bf31e76fca8c4294a3238519d13a631 Mon Sep 17 00:00:00 2001 From: fourpoints <30053843+fourpoints@users.noreply.github.com> Date: Wed, 25 May 2022 20:58:04 +0200 Subject: [PATCH] Add None check to PrettifyTreeprocessor Fixes #1261. --- docs/change_log/release-3.4.md | 1 + markdown/treeprocessors.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/change_log/release-3.4.md b/docs/change_log/release-3.4.md index eb36b409b..b38831cbf 100644 --- a/docs/change_log/release-3.4.md +++ b/docs/change_log/release-3.4.md @@ -68,3 +68,4 @@ The following new features have been included in the 3.4 release: The following bug fixes are included in the 3.4 release: * Extension entry-points are only loaded if needed (#1216). +* Added a `None` check to `PrettifyTreeprocessor` (#1261). diff --git a/markdown/treeprocessors.py b/markdown/treeprocessors.py index a475fdeb4..f634ff53c 100644 --- a/markdown/treeprocessors.py +++ b/markdown/treeprocessors.py @@ -432,5 +432,5 @@ def run(self, root): # Clean up extra empty lines at end of code blocks. pres = root.iter('pre') for pre in pres: - if len(pre) and pre[0].tag == 'code': + if len(pre) and pre[0].tag == 'code' and pre[0].text is not None: pre[0].text = util.AtomicString(pre[0].text.rstrip() + '\n')