Merge pull request #1141 from hmhealey/plt521b

PLT-521 Changed markdown renderer to only parse emoticons twice
Этот коммит содержится в:
Harrison Healey
2015-10-22 09:56:22 -04:00
родитель 14e24650c5 25e018ece0
Коммит 20a5380746
3 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@@ -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
});

Просмотреть файл

@@ -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>`;

Просмотреть файл

@@ -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;