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 1b7f21e2b..3798c0609 100644 --- a/www/common/diffMarked.js +++ b/www/common/diffMarked.js @@ -91,12 +91,6 @@ define([ }; restrictedRenderer.code = renderer.code; - 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, '-'); @@ -112,7 +106,7 @@ define([ toc.push({ level: level, id: id, - title: stripTags(text) + title: Util.stripTags(text) }); return "" + text + ""; }; diff --git a/www/common/sframe-common-codemirror.js b/www/common/sframe-common-codemirror.js index 5c71bbee2..f910f12b6 100644 --- a/www/common/sframe-common-codemirror.js +++ b/www/common/sframe-common-codemirror.js @@ -99,9 +99,17 @@ 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 = Util.stripTags(one); + }); + return true; + } line.replace(hash, function (a, one) { - text = one; + text = Util.stripTags(one); }); return true; }