summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-10-13 14:36:58 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-10-13 14:36:58 -0400
commit17d37816d42f93c42187787397c7d4060b2b943d (patch)
tree949e11b256b193d27b74bc76896f84ef8a03befb /web
parenta2979924a430e9e9bb70d30653035af77ecb1ef2 (diff)
downloadchat-17d37816d42f93c42187787397c7d4060b2b943d.tar.gz
chat-17d37816d42f93c42187787397c7d4060b2b943d.tar.bz2
chat-17d37816d42f93c42187787397c7d4060b2b943d.zip
Revert "Modified markdown lexer to not break up words written in snake_case"
This reverts commit 787d2ef7bca7f411b18d1d13561d61d7e95c81a7.
Diffstat (limited to 'web')
-rw-r--r--web/react/utils/markdown.jsx38
-rw-r--r--web/react/utils/text_formatting.jsx9
2 files changed, 8 insertions, 39 deletions
diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx
index 848b1ea75..12d6dd424 100644
--- a/web/react/utils/markdown.jsx
+++ b/web/react/utils/markdown.jsx
@@ -6,31 +6,7 @@ const Utils = require('./utils.jsx');
const marked = require('marked');
-class MattermostInlineLexer extends marked.InlineLexer {
- constructor(links, options) {
- super(links, options);
-
- // modified version of the regex that doesn't break up words in snake_case
- // the original is /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
- this.rules.text = /^[\s\S]+?(?=__|\b_|[\\<!\[*`]| {2,}\n|$)/;
- }
-}
-
-class MattermostParser extends marked.Parser {
- parse(src) {
- this.inline = new MattermostInlineLexer(src.links, this.options, this.renderer);
- this.tokens = src.reverse();
-
- var out = '';
- while (this.next()) {
- out += this.tok();
- }
-
- return out;
- }
-}
-
-class MattermostMarkdownRenderer extends marked.Renderer {
+export class MattermostMarkdownRenderer extends marked.Renderer {
constructor(options, formattingOptions = {}) {
super(options);
@@ -92,15 +68,3 @@ class MattermostMarkdownRenderer extends marked.Renderer {
return TextFormatting.doFormatText(text, this.formattingOptions);
}
}
-
-export function format(text, options) {
- const markdownOptions = {
- renderer: new MattermostMarkdownRenderer(null, options),
- sanitize: true
- };
-
- const tokens = marked.lexer(text, markdownOptions);
-
- return new MattermostParser(markdownOptions).parse(tokens);
-}
-
diff --git a/web/react/utils/text_formatting.jsx b/web/react/utils/text_formatting.jsx
index 6778d341a..2b6e6e14e 100644
--- a/web/react/utils/text_formatting.jsx
+++ b/web/react/utils/text_formatting.jsx
@@ -8,6 +8,8 @@ const Markdown = require('./markdown.jsx');
const UserStore = require('../stores/user_store.jsx');
const Utils = require('./utils.jsx');
+const marked = require('marked');
+
// Performs formatting of user posts including highlighting mentions and search terms and converting urls, hashtags, and
// @mentions to links by taking a user's message and returning a string of formatted html. Also takes a number of options
// as part of the second parameter:
@@ -20,8 +22,11 @@ export function formatText(text, options = {}) {
let output;
if (!('markdown' in options) || options.markdown) {
- // the markdown renderer will call doFormatText as necessary
- output = Markdown.format(text, options);
+ // the markdown renderer will call doFormatText as necessary so just call marked
+ output = marked(text, {
+ renderer: new Markdown.MattermostMarkdownRenderer(null, options),
+ sanitize: true
+ });
} else {
output = sanitizeHtml(text);
output = doFormatText(output, options);