// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. const TextFormatting = require('./text_formatting.jsx'); 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]+?(?=[\\${text}`; } link(href, title, text) { let outHref = href; if (!(/^(mailto|https?|ftp)/.test(outHref))) { outHref = `http://${outHref}`; } let output = ''; } else { output += ' target="_blank">'; } output += text + ''; return output; } paragraph(text) { let outText = text; // required so markdown does not strip '_' from @user_names outText = TextFormatting.doFormatMentions(text); if (!('emoticons' in this.options) || this.options.emoticon) { outText = TextFormatting.doFormatEmoticons(outText); } if (this.formattingOptions.singleline) { return `
${outText}
`; } return super.paragraph(outText); } table(header, body) { return `