Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Münchbach <182-FlorianMuenchbach@users.noreply.dev.gajim.org>2019-02-18 22:32:41 +0300
committerFlorian Münchbach <182-FlorianMuenchbach@users.noreply.dev.gajim.org>2019-02-18 23:18:21 +0300
commit7e068624d874e67ebb12294d09af4f04e0dd2e88 (patch)
treeceecfd497099a07d7f131cb30dedb140085603dc
parentf2c4368f87540ac78f8b7980ceb2c018dfff3ff4 (diff)
[syntax_highlight] More strict checking for inline code spans
-rw-r--r--syntax_highlight/chat_syntax_highlighter.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/syntax_highlight/chat_syntax_highlighter.py b/syntax_highlight/chat_syntax_highlighter.py
index 3d720dc..fea203b 100644
--- a/syntax_highlight/chat_syntax_highlighter.py
+++ b/syntax_highlight/chat_syntax_highlighter.py
@@ -84,8 +84,14 @@ class ChatSyntaxHighlighter:
return matches
def find_inline_matches(self, text):
- return [(i.start(), i.end(), i.group(0)) for i in \
- re.finditer(r'(?<!`)`(?!`|\n).+(?<!`)`', text)]
+ """
+ Inline code is highlighted if the start marker is precedded by a start
+ of line, a whitespace character or either of the other span markers
+ defined in XEP-0393.
+ The same applies mirrored to the end marker.
+ """
+ return [(i.start(1), i.end(1), i.group(1)) for i in \
+ re.finditer(r'(?:^|\s|\*|~|_)(`((?!`).+?)`)(?:\s|\*|~|_|$)', text)]
def merge_match_groups(self, real_text, inline_matches, multiline_matches):
it_inline = iter(inline_matches)