Fix markdown link in title issue
This commit is contained in:
@@ -45,6 +45,7 @@ define([
|
|||||||
|
|
||||||
var toc = [];
|
var toc = [];
|
||||||
var getTOC = function () {
|
var getTOC = function () {
|
||||||
|
console.log(toc);
|
||||||
var content = [h('h2', Messages.markdown_toc)];
|
var content = [h('h2', Messages.markdown_toc)];
|
||||||
toc.forEach(function (obj) {
|
toc.forEach(function (obj) {
|
||||||
// Only include level 2 headings
|
// Only include level 2 headings
|
||||||
@@ -84,7 +85,14 @@ define([
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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) {
|
||||||
|
console.log(text, level);
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var safeText = text.toLowerCase().replace(/[^\w]+/g, '-');
|
var safeText = text.toLowerCase().replace(/[^\w]+/g, '-');
|
||||||
var getId = function () {
|
var getId = function () {
|
||||||
@@ -99,7 +107,7 @@ define([
|
|||||||
toc.push({
|
toc.push({
|
||||||
level: level,
|
level: level,
|
||||||
id: id,
|
id: id,
|
||||||
title: text
|
title: 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 + ">";
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user