mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 22:09:52 +08:00
bugfix: escape special symbols (&) in TOC during generation
This commit is contained in:
parent
7d05f96f94
commit
4c63839c4d
@ -60,7 +60,7 @@ mdit = mdit.use(window.markdownitHeadingAnchor, {
|
|||||||
toc.push({
|
toc.push({
|
||||||
level: getHeadingLevel(openToken.tag),
|
level: getHeadingLevel(openToken.tag),
|
||||||
anchor: anchor,
|
anchor: anchor,
|
||||||
title: inlineToken.content
|
title: escapeHtml(inlineToken.content)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -313,3 +313,16 @@ var insertImageCaption = function() {
|
|||||||
var finishLogics = function() {
|
var finishLogics = function() {
|
||||||
content.finishLogics();
|
content.finishLogics();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Escape @text to Html.
|
||||||
|
var escapeHtml = function(text) {
|
||||||
|
var map = {
|
||||||
|
'&': '&',
|
||||||
|
'<': '<',
|
||||||
|
'>': '>',
|
||||||
|
'"': '"',
|
||||||
|
"'": '''
|
||||||
|
};
|
||||||
|
|
||||||
|
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
|
||||||
|
};
|
||||||
|
@ -24,7 +24,7 @@ var parseHeadings = function(html) {
|
|||||||
toc.push({
|
toc.push({
|
||||||
level: level,
|
level: level,
|
||||||
anchor: ele.id,
|
anchor: ele.id,
|
||||||
title: ele.innerText
|
title: ele.innerHTML
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ VEditWindow::VEditWindow(VNote *vnote, VEditArea *editArea, QWidget *parent)
|
|||||||
void VEditWindow::initTabActions()
|
void VEditWindow::initTabActions()
|
||||||
{
|
{
|
||||||
m_locateAct = new QAction(QIcon(":/resources/icons/locate_note.svg"),
|
m_locateAct = new QAction(QIcon(":/resources/icons/locate_note.svg"),
|
||||||
tr("Locate To Directory"), this);
|
tr("Locate To Folder"), this);
|
||||||
m_locateAct->setToolTip(tr("Locate the directory of current note"));
|
m_locateAct->setToolTip(tr("Locate the folder of current note"));
|
||||||
connect(m_locateAct, &QAction::triggered,
|
connect(m_locateAct, &QAction::triggered,
|
||||||
this, &VEditWindow::handleLocateAct);
|
this, &VEditWindow::handleLocateAct);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user