summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2015-10-22 09:56:22 -0400
committerHarrison Healey <harrisonmhealey@gmail.com>2015-10-22 09:56:22 -0400
commit20a5380746ad6865dcd55cf8a8ee6a934696b5f0 (patch)
tree6871b6589f5a4e93a588af3564a25df0a7e4725b /web/react/utils
parent14e24650c501a2ee93b9dafb4f5877ba5a9ec22f (diff)
parent25e018ece082a8136024b6d0a6c9db46cb113db1 (diff)
downloadchat-20a5380746ad6865dcd55cf8a8ee6a934696b5f0.tar.gz
chat-20a5380746ad6865dcd55cf8a8ee6a934696b5f0.tar.bz2
chat-20a5380746ad6865dcd55cf8a8ee6a934696b5f0.zip
Merge pull request #1141 from hmhealey/plt521b
PLT-521 Changed markdown renderer to only parse emoticons twice
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/emoticons.jsx2
-rw-r--r--web/react/utils/markdown.jsx7
-rw-r--r--web/react/utils/text_formatting.jsx9
3 files changed, 16 insertions, 2 deletions
diff --git a/web/react/utils/emoticons.jsx b/web/react/utils/emoticons.jsx
index 7b43e48b4..aabddcffd 100644
--- a/web/react/utils/emoticons.jsx
+++ b/web/react/utils/emoticons.jsx
@@ -133,7 +133,7 @@ export function handleEmoticons(text, tokens) {
const alias = `MM_EMOTICON${index}`;
tokens.set(alias, {
- value: `<img align="absmiddle" alt=${match} class="emoji" src=${getImagePathForEmoticon(name)} title=${match} />`,
+ value: `<img align="absmiddle" alt="${match}" class="emoji" src="${getImagePathForEmoticon(name)}" title="${match}" />`,
originalText: match
});
diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx
index 1b699bc98..7a4e70054 100644
--- a/web/react/utils/markdown.jsx
+++ b/web/react/utils/markdown.jsx
@@ -11,6 +11,7 @@ export class MattermostMarkdownRenderer extends marked.Renderer {
super(options);
this.heading = this.heading.bind(this);
+ this.paragraph = this.paragraph.bind(this);
this.text = this.text.bind(this);
this.formattingOptions = formattingOptions;
@@ -53,7 +54,11 @@ export class MattermostMarkdownRenderer extends marked.Renderer {
}
paragraph(text) {
- let outText = TextFormatting.doFormatText(text, this.options);
+ let outText = text;
+
+ if (!('emoticons' in this.options) || this.options.emoticon) {
+ outText = TextFormatting.doFormatEmoticons(text);
+ }
if (this.formattingOptions.singleline) {
return `<p class="markdown__paragraph-inline">${outText}</p>`;
diff --git a/web/react/utils/text_formatting.jsx b/web/react/utils/text_formatting.jsx
index d79aeed68..5c2e68f1e 100644
--- a/web/react/utils/text_formatting.jsx
+++ b/web/react/utils/text_formatting.jsx
@@ -69,6 +69,15 @@ export function doFormatText(text, options) {
return output;
}
+export function doFormatEmoticons(text) {
+ const tokens = new Map();
+
+ let output = Emoticons.handleEmoticons(text, tokens);
+ output = replaceTokens(output, tokens);
+
+ return output;
+}
+
export function sanitizeHtml(text) {
let output = text;