From 6ae5da3d10bae67abd2001670cff880752eaca27 Mon Sep 17 00:00:00 2001 From: ClemDee Date: Wed, 24 Jul 2019 14:41:37 +0200 Subject: [PATCH 1/3] Move stripTags function to Util --- www/common/common-util.js | 6 ++++++ www/common/diffMarked.js | 8 +------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/www/common/common-util.js b/www/common/common-util.js index 9fd2305c3..03c9e321b 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -319,6 +319,12 @@ define([], function () { return window.innerHeight < 800 || window.innerWidth < 800; }; + Util.stripTags = function (text) { + var div = document.createElement("div"); + div.innerHTML = text; + return div.innerText; + }; + return Util; }); }(self)); diff --git a/www/common/diffMarked.js b/www/common/diffMarked.js index 35633c4cd..44a2f56a4 100644 --- a/www/common/diffMarked.js +++ b/www/common/diffMarked.js @@ -84,12 +84,6 @@ define([ } }; - var stripTags = function (text) { - var div = document.createElement("div"); - div.innerHTML = text; - return div.innerText; - }; - renderer.heading = function (text, level) { var i = 0; var safeText = text.toLowerCase().replace(/[^\w]+/g, '-'); @@ -105,7 +99,7 @@ define([ toc.push({ level: level, id: id, - title: stripTags(text) + title: Util.stripTags(text) }); return "" + text + ""; }; From e1690c6f1a98ba9bcb489f9681a73690df6b4f3c Mon Sep 17 00:00:00 2001 From: ClemDee Date: Wed, 24 Jul 2019 15:27:10 +0200 Subject: [PATCH 2/3] Escape titles inside links for Code and Slide titles --- www/common/sframe-common-codemirror.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/www/common/sframe-common-codemirror.js b/www/common/sframe-common-codemirror.js index 8a0e2de63..eb2298e3d 100644 --- a/www/common/sframe-common-codemirror.js +++ b/www/common/sframe-common-codemirror.js @@ -98,7 +98,15 @@ define([ // lines beginning with a hash are potentially valuable // works for markdown, python, bash, etc. var hash = /^#+(.*?)$/; + var hashAndLink = /^#+\s*\[(.*?)\]\(.*\)\s*$/; if (hash.test(line)) { + // test for link inside the title, and set text just to the name of the link + if (hashAndLink.test(line)) { + line.replace(hashAndLink, function (a, one) { + text = one; + }); + return true; + } line.replace(hash, function (a, one) { text = one; }); From 938bc0a4b2a857c2c871434a7b2701f69a39a26c Mon Sep 17 00:00:00 2001 From: ClemDee Date: Thu, 8 Aug 2019 16:47:45 +0200 Subject: [PATCH 3/3] Escape HTML tags from markdown for pad title --- www/common/sframe-common-codemirror.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/common/sframe-common-codemirror.js b/www/common/sframe-common-codemirror.js index eb2298e3d..ec09def81 100644 --- a/www/common/sframe-common-codemirror.js +++ b/www/common/sframe-common-codemirror.js @@ -103,12 +103,12 @@ define([ // test for link inside the title, and set text just to the name of the link if (hashAndLink.test(line)) { line.replace(hashAndLink, function (a, one) { - text = one; + text = Util.stripTags(one); }); return true; } line.replace(hash, function (a, one) { - text = one; + text = Util.stripTags(one); }); return true; }