From 1c65ee150be0a0d738d805f987ccc36139f9bc43 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 22 Jan 2024 17:56:40 -0500 Subject: [PATCH] relocate renderer.link --- shared/naturalcrit/markdown.js | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 5be80ac97..43729a539 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -28,6 +28,28 @@ renderer.paragraph = function(text){ return `

${text}

\n`; }; +//Fix local links in the Preview iFrame to link inside the frame +renderer.link = function (href, title, text) { + let self = false; + if(href[0] == '#') { + self = true; + } + href = cleanUrl(this.options.sanitize, this.options.baseUrl, href); + + if(href === null) { + return text; + } + let out = `${text}`; + return out; +}; + const mustacheSpans = { name : 'mustacheSpans', level : 'inline', // Is this a block-level or inline-level tokenizer? @@ -271,28 +293,6 @@ Marked.use(mustacheInjectBlock); Marked.use({ renderer: renderer, mangle: false }); Marked.use(MarkedExtendedTables(), MarkedGFMHeadingId(), MarkedSmartypantsLite()); -//Fix local links in the Preview iFrame to link inside the frame -renderer.link = function (href, title, text) { - let self = false; - if(href[0] == '#') { - self = true; - } - href = cleanUrl(this.options.sanitize, this.options.baseUrl, href); - - if(href === null) { - return text; - } - let out = `${text}`; - return out; -}; - const nonWordAndColonTest = /[^\w:]/g; const cleanUrl = function (sanitize, base, href) { if(sanitize) {