commit
4e02135230
|
@ -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));
|
||||
|
|
|
@ -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 "<h" + level + " id=\"" + id + "\"><a href=\"#" + id + "\" class=\"anchor\"></a>" + text + "</h" + level + ">";
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue