From caed3e9224bb2db694f919d29d855e7d778f2836 Mon Sep 17 00:00:00 2001 From: Youness Alaoui Date: Sat, 9 Feb 2019 13:03:26 -0500 Subject: [PATCH] Fix crash when 7 pound signs are written alone on a line. The code would look for trailing pound signs and would count all the way to the beginning and beyond, resulting in an out of bounds exception. --- manuskript/ui/highlighters/markdownTokenizer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manuskript/ui/highlighters/markdownTokenizer.py b/manuskript/ui/highlighters/markdownTokenizer.py index 0b8aeceb..564db4dc 100644 --- a/manuskript/ui/highlighters/markdownTokenizer.py +++ b/manuskript/ui/highlighters/markdownTokenizer.py @@ -279,7 +279,9 @@ class MarkdownTokenizer(HighlightTokenizer): if level > 0 and level < len(text): # Count how many pound signs are at the end of the text. - while escapedText[-trailingPoundCount -1] == "#": + # Ignore starting pound signs when calculating trailing signs + while level + trailingPoundCount < len(text) and \ + escapedText[-trailingPoundCount -1] == "#": trailingPoundCount += 1 token = Token()