Skip to content

Commit

Permalink
fix issue with non printable characters
Browse files Browse the repository at this point in the history
  • Loading branch information
olivier ruelle committed Sep 3, 2020
1 parent e8d2448 commit 9f279f1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions md_mermaid.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
from markdown.preprocessors import Preprocessor

import re
import string

def strip_notprintable(myStr):
return ''.join(filter(lambda x: x in string.printable, myStr))

MermaidRegex = re.compile(r"^(?P<mermaid_sign>[\~\`]){3}[\ \t]*[Mm]ermaid[\ \t]*$")

Expand All @@ -29,6 +33,8 @@ def run(self, lines):
in_mermaid_code = False
is_mermaid = False
for line in lines:
# Strip non printable characters
line = strip_notprintable(line)
# Wait for starting line with MermaidRegex (~~~ or ``` following by [mM]ermaid )
if not in_mermaid_code:
m_start = MermaidRegex.match(line)
Expand Down

0 comments on commit 9f279f1

Please sign in to comment.