From 4a326dd6ce29c7ff62e0f620e8cdca920e1f3016 Mon Sep 17 00:00:00 2001
From: Harrison Healey <harrisonmhealey@gmail.com>
Date: Tue, 31 May 2016 10:37:59 -0400
Subject: 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
---
 webapp/utils/syntax_hightlighting.jsx | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'webapp/utils/syntax_hightlighting.jsx')

diff --git a/webapp/utils/syntax_hightlighting.jsx b/webapp/utils/syntax_hightlighting.jsx
index 882afe67f..33b3e2d3d 100644
--- a/webapp/utils/syntax_hightlighting.jsx
+++ b/webapp/utils/syntax_hightlighting.jsx
@@ -123,10 +123,12 @@ hlJS.registerLanguage('yaml', hljsYaml);
 
 const HighlightedLanguages = Constants.HighlightedLanguages;
 
-export function formatCode(lang, data, filename) {
+export function formatCode(lang, data, filename, searchTerm) {
     const language = lang.toLowerCase() || '';
+
     let contents;
     let header = '';
+    let className = 'post-code';
 
     if (HighlightedLanguages[language]) {
         let name = HighlightedLanguages[language].name;
@@ -147,10 +149,13 @@ export function formatCode(lang, data, filename) {
         contents = TextFormatting.sanitizeHtml(data);
     }
 
-    let className = 'post-code';
     if (!language) {
         // wrap when no language is specified
         className += ' post-code--wrap';
+
+        const tokens = new Map();
+        contents = TextFormatting.highlightSearchTerms(contents, tokens, searchTerm);
+        contents = TextFormatting.replaceTokens(contents, tokens);
     }
 
     if (filename) {
-- 
cgit v1.2.3-1-g7c22

