commit
4e02135230
@ -319,6 +319,12 @@ define([], function () {
|
|||||||
return window.innerHeight < 800 || window.innerWidth < 800;
|
return window.innerHeight < 800 || window.innerWidth < 800;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Util.stripTags = function (text) {
|
||||||
|
var div = document.createElement("div");
|
||||||
|
div.innerHTML = text;
|
||||||
|
return div.innerText;
|
||||||
|
};
|
||||||
|
|
||||||
return Util;
|
return Util;
|
||||||
});
|
});
|
||||||
}(self));
|
}(self));
|
||||||
|
|||||||
@ -91,12 +91,6 @@ define([
|
|||||||
};
|
};
|
||||||
restrictedRenderer.code = renderer.code;
|
restrictedRenderer.code = renderer.code;
|
||||||
|
|
||||||
var stripTags = function (text) {
|
|
||||||
var div = document.createElement("div");
|
|
||||||
div.innerHTML = text;
|
|
||||||
return div.innerText;
|
|
||||||
};
|
|
||||||
|
|
||||||
renderer.heading = function (text, level) {
|
renderer.heading = function (text, level) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var safeText = text.toLowerCase().replace(/[^\w]+/g, '-');
|
var safeText = text.toLowerCase().replace(/[^\w]+/g, '-');
|
||||||
@ -112,7 +106,7 @@ define([
|
|||||||
toc.push({
|
toc.push({
|
||||||
level: level,
|
level: level,
|
||||||
id: id,
|
id: id,
|
||||||
title: stripTags(text)
|
title: Util.stripTags(text)
|
||||||
});
|
});
|
||||||
return "<h" + level + " id=\"" + id + "\"><a href=\"#" + id + "\" class=\"anchor\"></a>" + text + "</h" + level + ">";
|
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
|
// lines beginning with a hash are potentially valuable
|
||||||
// works for markdown, python, bash, etc.
|
// works for markdown, python, bash, etc.
|
||||||
var hash = /^#+(.*?)$/;
|
var hash = /^#+(.*?)$/;
|
||||||
|
var hashAndLink = /^#+\s*\[(.*?)\]\(.*\)\s*$/;
|
||||||
if (hash.test(line)) {
|
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) {
|
line.replace(hash, function (a, one) {
|
||||||
text = one;
|
text = Util.stripTags(one);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user