mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 06:19:52 +08:00
fix Hoedown's toc
Hoedown will treat '_' in title as '<em>'. Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
a22bf1059d
commit
87c668bc67
@ -135,10 +135,20 @@ void VEditTab::previewByConverter()
|
|||||||
QString html = mdConverter.generateHtml(content, vconfig.getMarkdownExtensions());
|
QString html = mdConverter.generateHtml(content, vconfig.getMarkdownExtensions());
|
||||||
QRegularExpression tocExp("<p>\\[TOC\\]<\\/p>", QRegularExpression::CaseInsensitiveOption);
|
QRegularExpression tocExp("<p>\\[TOC\\]<\\/p>", QRegularExpression::CaseInsensitiveOption);
|
||||||
QString toc = mdConverter.generateToc(content, vconfig.getMarkdownExtensions());
|
QString toc = mdConverter.generateToc(content, vconfig.getMarkdownExtensions());
|
||||||
|
processHoedownToc(toc);
|
||||||
html.replace(tocExp, toc);
|
html.replace(tocExp, toc);
|
||||||
document.setHtml(html);
|
document.setHtml(html);
|
||||||
// Hoedown will add '\n' while Marked does not
|
// Hoedown will add '\n' while Marked does not
|
||||||
updateTocFromHtml(toc.replace("\n", ""));
|
updateTocFromHtml(toc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VEditTab::processHoedownToc(QString &p_toc)
|
||||||
|
{
|
||||||
|
// Hoedown will add '\n'.
|
||||||
|
p_toc.replace("\n", "");
|
||||||
|
// Hoedown will translate `_` in title to `<em>`.
|
||||||
|
p_toc.replace("<em>", "_");
|
||||||
|
p_toc.replace("</em>", "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
void VEditTab::showFileEditMode()
|
void VEditTab::showFileEditMode()
|
||||||
|
@ -60,6 +60,7 @@ private:
|
|||||||
void showFileEditMode();
|
void showFileEditMode();
|
||||||
void setupMarkdownPreview();
|
void setupMarkdownPreview();
|
||||||
void previewByConverter();
|
void previewByConverter();
|
||||||
|
void processHoedownToc(QString &p_toc);
|
||||||
inline bool isChild(QObject *obj);
|
inline bool isChild(QObject *obj);
|
||||||
void parseTocUl(QXmlStreamReader &xml, QVector<VHeader> &headers, int level);
|
void parseTocUl(QXmlStreamReader &xml, QVector<VHeader> &headers, int level);
|
||||||
void parseTocLi(QXmlStreamReader &xml, QVector<VHeader> &headers, int level);
|
void parseTocLi(QXmlStreamReader &xml, QVector<VHeader> &headers, int level);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user