diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-05-31 10:37:59 -0400 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-05-31 10:37:59 -0400 |
commit | 4a326dd6ce29c7ff62e0f620e8cdca920e1f3016 (patch) | |
tree | 9a1af026012651f9a5e55c79c426115003843ede /webapp/utils/markdown.jsx | |
parent | 397e0a3f683e324ce2d4d16c8a7f3f9346c8566b (diff) | |
download | chat-4a326dd6ce29c7ff62e0f620e8cdca920e1f3016.tar.gz chat-4a326dd6ce29c7ff62e0f620e8cdca920e1f3016.tar.bz2 chat-4a326dd6ce29c7ff62e0f620e8cdca920e1f3016.zip |
PLT-1626/PLT-1424/PLT-1473/PLT-1483 Improved search highlighting (#3171)
* PLT-1626 Stopped breaking up hyphenated hashtags when highlighting search terms
* Made hashtag search highlighting case independent
* PLT-1424 Improved search highlighting when searching for CJK characters
* PLT-1473 Added search term highlighting to single-line code blocks
* PLT-1473 Added search term highlighting to code blocks that don't use syntax highlighting
* PLT-1483 Added proper highlighting of at mentions
* Fixing formatting
Diffstat (limited to 'webapp/utils/markdown.jsx')
-rw-r--r-- | webapp/utils/markdown.jsx | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/webapp/utils/markdown.jsx b/webapp/utils/markdown.jsx index 809ecc526..7fd165134 100644 --- a/webapp/utils/markdown.jsx +++ b/webapp/utils/markdown.jsx @@ -43,11 +43,25 @@ class MattermostMarkdownRenderer extends marked.Renderer { usedLanguage = 'xml'; } - return syntaxHightlighting.formatCode(usedLanguage, code); + return syntaxHightlighting.formatCode(usedLanguage, code, null, this.formattingOptions.searchTerm); } codespan(text) { - return '<span class="codespan__pre-wrap">' + super.codespan(text) + '</span>'; + let output = text; + + if (this.formattingOptions.searchTerm) { + const tokens = new Map(); + output = TextFormatting.highlightSearchTerms(output, tokens, this.formattingOptions.searchTerm); + output = TextFormatting.replaceTokens(output, tokens); + } + + return ( + '<span class="codespan__pre-wrap">' + + '<code>' + + output + + '</code>' + + '</span>' + ); } br() { |