From 14cff7588fd1d88b6b503a410554344c5ba496d8 Mon Sep 17 00:00:00 2001
From: Florian Orben <florian.orben@gmail.com>
Date: Sat, 7 Nov 2015 02:22:39 +0100
Subject: Add latex support

Adds latex highlighting support via https://www.npmjs.com/package/katex
as requested in
https://mattermost.uservoice.com/forums/306457-general/suggestions/10160757-add-latex-support
---
 web/react/utils/markdown.jsx | 9 +++++++++
 1 file changed, 9 insertions(+)

(limited to 'web/react/utils/markdown.jsx')

diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx
index 946f93078..3d967ae6d 100644
--- a/web/react/utils/markdown.jsx
+++ b/web/react/utils/markdown.jsx
@@ -69,6 +69,15 @@ class MattermostMarkdownRenderer extends marked.Renderer {
             usedLanguage = 'xml';
         }
 
+        if (usedLanguage && (usedLanguage === 'tex' || usedLanguage === 'tex')) {
+            try {
+                var html = katex.renderToString(TextFormatting.sanitizeHtml(code), {throwOnError: false, displayMode: true});
+                return '<div class="post-body--code tex">' + html + '</div>';
+            } catch (e) {
+                return '<div class="post-body--code">' + TextFormatting.sanitizeHtml(code) + '</div>';
+            }
+        }
+
         if (!usedLanguage || highlightJs.listLanguages().indexOf(usedLanguage) < 0) {
             let parsed = super.code(code, usedLanguage);
             return '<div class="post-body--code"><code class="hljs">' + TextFormatting.sanitizeHtml($(parsed).text()) + '</code></div>';
-- 
cgit v1.2.3-1-g7c22


From 5ed94c8f5823c7ae49d7b6f861a366af16ac94ea Mon Sep 17 00:00:00 2001
From: Florian Orben <florian.orben@gmail.com>
Date: Sun, 8 Nov 2015 14:30:35 +0100
Subject: fix indentation to use tabs

---
 web/react/utils/markdown.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'web/react/utils/markdown.jsx')

diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx
index 3d967ae6d..4d1a35d19 100644
--- a/web/react/utils/markdown.jsx
+++ b/web/react/utils/markdown.jsx
@@ -69,7 +69,7 @@ class MattermostMarkdownRenderer extends marked.Renderer {
             usedLanguage = 'xml';
         }
 
-        if (usedLanguage && (usedLanguage === 'tex' || usedLanguage === 'tex')) {
+        if (usedLanguage && (usedLanguage === 'tex' || usedLanguage === 'latex')) {
             try {
                 var html = katex.renderToString(TextFormatting.sanitizeHtml(code), {throwOnError: false, displayMode: true});
                 return '<div class="post-body--code tex">' + html + '</div>';
-- 
cgit v1.2.3-1-g7c22

