summaryrefslogtreecommitdiff
path: root/public/js
diff options
context:
space:
mode:
authorWu Cheng-Han2016-11-28 22:15:07 +0800
committerWu Cheng-Han2016-11-28 22:15:07 +0800
commitead48e45e0977e6376640b89f842f238ab382f94 (patch)
tree5cd8a54efb787a58b31c1c5c059f20423d5d05d8 /public/js
parentde2067f7e898f3557323782d28e8f7530ffb539f (diff)
Fix header id and text might affects by mathjax tags
Diffstat (limited to '')
-rw-r--r--public/js/extra.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/public/js/extra.js b/public/js/extra.js
index 3fe1084e..8ca1dcb5 100644
--- a/public/js/extra.js
+++ b/public/js/extra.js
@@ -689,7 +689,8 @@ function generateToc(id) {
'top': -1,
'class': 'toc',
'ulClass': 'nav',
- 'targetId': id
+ 'targetId': id,
+ 'process': getHeaderContent
});
if (target.text() == 'undefined')
target.html('');
@@ -777,7 +778,7 @@ var linkifyAnchors = function (level, containingElement) {
if (header.getElementsByClassName("anchor").length == 0) {
if (typeof header.id == "undefined" || header.id == "") {
//to escape characters not allow in css and humanize
- var id = slugifyWithUTF8(header.innerHTML);
+ var id = slugifyWithUTF8(getHeaderContent(header));
header.id = id;
}
header.insertBefore(anchorForId(header.id), header.firstChild);
@@ -795,6 +796,13 @@ function autoLinkify(view) {
}
}
+function getHeaderContent(header) {
+ var headerHTML = $(header).clone();
+ headerHTML.find('.MathJax_Preview').remove();
+ headerHTML.find('.MathJax').remove();
+ return headerHTML[0].innerHTML;
+}
+
function deduplicatedHeaderId(view) {
var headers = view.find(':header.raw').removeClass('raw').toArray();
for (var i = 0; i < headers.length; i++) {
@@ -826,7 +834,8 @@ function renderTOC(view) {
'level': 3,
'top': -1,
'class': 'toc',
- 'targetId': id
+ 'targetId': id,
+ 'process': getHeaderContent
});
if (target.text() == 'undefined')
target.html('');