From edd042190d5e2be7404fa544011c5a6b639d03ed Mon Sep 17 00:00:00 2001 From: EyeZiS Date: Tue, 8 May 2018 23:56:44 +0200 Subject: [PATCH] clean up parser --- stdplugins/markdown.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/stdplugins/markdown.py b/stdplugins/markdown.py index 91edcda..87cc192 100644 --- a/stdplugins/markdown.py +++ b/stdplugins/markdown.py @@ -63,25 +63,24 @@ def parse(message): match = pattern.match(message, pos=i) if match: break - - if match: - text, entity = parser(match) - # replace whole match with text from parser - message = ''.join(( - message[:match.start()], - text, - message[match.end():] - )) - - # append entity if we got one - if entity: - entities.append(entity) - - # skip past the match - i += len(text) + else: + i += 1 continue - i += 1 + text, entity = parser(match) + # replace whole match with text from parser + message = ''.join(( + message[:match.start()], + text, + message[match.end():] + )) + + # append entity if we got one + if entity: + entities.append(entity) + + # skip past the match + i += len(text) return _del_surrogate(message), entities