From 8550099110dc2d90412bad4bd6826ea85c1522dc Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 6 Jul 2017 18:57:22 +0300 Subject: [PATCH] Improve markdown parsing. --- Telegram/SourceFiles/ui/text/text_entity.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Telegram/SourceFiles/ui/text/text_entity.cpp b/Telegram/SourceFiles/ui/text/text_entity.cpp index 45d5989ac5..6d5e63bcd9 100644 --- a/Telegram/SourceFiles/ui/text/text_entity.cpp +++ b/Telegram/SourceFiles/ui/text/text_entity.cpp @@ -1565,6 +1565,12 @@ MarkdownPart GetMarkdownPart(EntityInTextType type, const QString &text, int mat Unexpected("Type in GetMardownPart()"); }; + if (matchFromOffset > 1) { + // If matchFromOffset is after some separator that is allowed to + // start our markdown tag the tag itself will start where we want it. + // So we allow to see this separator and make a match. + --matchFromOffset; + } auto match = regexp().match(text, matchFromOffset); if (!match.hasMatch()) { return result;