From 0eddea19378d60386f31d43592d67acbf132e4c6 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 22 Sep 2016 17:51:34 +0100 Subject: [PATCH] Disable link detection, as per comment --- src/Markdown.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Markdown.js b/src/Markdown.js index e4161c0b76..0151d0ae77 100644 --- a/src/Markdown.js +++ b/src/Markdown.js @@ -16,10 +16,25 @@ limitations under the License. import marked from 'marked'; +// replace the default link renderer function +// to prevent marked from turning plain URLs +// into links, because tits algorithm is fairly +// poor, so let's send plain URLs rather than +// badly linkified ones (the linkifier Vector +// uses on message display is way better, eg. +// handles URLs with closing parens at the end). +const renderer = new marked.Renderer(); +renderer.link = function(href, title, text) { + if (text == href) { + return href; + } + return marked.Renderer.prototype.apply(this, arguments); +} + // marked only applies the default options on the high // level marked() interface, so we do it here. -const marked_options = Object.assign({}, { - renderer: new marked.Renderer(), +const marked_options = Object.assign({}, marked.defaults, { + renderer: renderer, gfm: true, tables: true, breaks: true, @@ -27,7 +42,7 @@ const marked_options = Object.assign({}, { sanitize: true, smartLists: true, smartypants: false, -}, marked.defaults); +}); const real_parser = new marked.Parser(marked_options);