diff options
author | hmhealey <harrisonmhealey@gmail.com> | 2015-09-19 11:08:39 -0400 |
---|---|---|
committer | hmhealey <harrisonmhealey@gmail.com> | 2015-09-19 11:18:37 -0400 |
commit | 144a277a44350af14993d439b3bd9999f75e84e7 (patch) | |
tree | 086e02d2aa1200a8804c52efb559a686a27a34e9 | |
parent | 5f18c71d07e8ea0ac3f9053ad0a67c5380e613ef (diff) | |
download | chat-144a277a44350af14993d439b3bd9999f75e84e7.tar.gz chat-144a277a44350af14993d439b3bd9999f75e84e7.tar.bz2 chat-144a277a44350af14993d439b3bd9999f75e84e7.zip |
Cleaned up markdown formatting code and removed debug statements
-rw-r--r-- | web/react/utils/markdown.jsx | 8 | ||||
-rw-r--r-- | web/react/utils/text_formatting.jsx | 8 |
2 files changed, 9 insertions, 7 deletions
diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx index 880e41a18..8c63810cd 100644 --- a/web/react/utils/markdown.jsx +++ b/web/react/utils/markdown.jsx @@ -5,10 +5,12 @@ const marked = require('marked'); export class MattermostMarkdownRenderer extends marked.Renderer { link(href, title, text) { - if (href.lastIndexOf('http', 0) !== 0) { - href = `http://${href}`; + let outHref = href; + + if (outHref.lastIndexOf('http', 0) !== 0) { + outHref = `http://${outHref}`; } - return super.link(href, title, text); + return super.link(outHref, title, text); } } diff --git a/web/react/utils/text_formatting.jsx b/web/react/utils/text_formatting.jsx index 47b56cc3c..4e390f708 100644 --- a/web/react/utils/text_formatting.jsx +++ b/web/react/utils/text_formatting.jsx @@ -17,9 +17,11 @@ const markdownRenderer = new Markdown.MattermostMarkdownRenderer(); // - searchTerm - If specified, this word is highlighted in the resulting html. Defaults to nothing. // - mentionHighlight - Specifies whether or not to highlight mentions of the current user. Defaults to true. // - singleline - Specifies whether or not to remove newlines. Defaults to false. +// - markdown - Enables markdown parsing. Defaults to true. export function formatText(text, options = {}) { - // TODO remove me - options.markdown = true; + if (!('markdown' in options)) { + options.markdown = true; + } // wait until marked can sanitize the html so that we don't break markdown block quotes let output; @@ -46,12 +48,10 @@ export function formatText(text, options = {}) { // perform markdown parsing while we have an html-free input string if (options.markdown) { - console.log('output before marked ' + output); output = marked(output, { renderer: markdownRenderer, sanitize: true }); - console.log('output after marked ' + output); } // reinsert tokens with formatted versions of the important words and phrases |