mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +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());
|
||||
QRegularExpression tocExp("<p>\\[TOC\\]<\\/p>", QRegularExpression::CaseInsensitiveOption);
|
||||
QString toc = mdConverter.generateToc(content, vconfig.getMarkdownExtensions());
|
||||
processHoedownToc(toc);
|
||||
html.replace(tocExp, toc);
|
||||
document.setHtml(html);
|
||||
// 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()
|
||||
|
@ -60,6 +60,7 @@ private:
|
||||
void showFileEditMode();
|
||||
void setupMarkdownPreview();
|
||||
void previewByConverter();
|
||||
void processHoedownToc(QString &p_toc);
|
||||
inline bool isChild(QObject *obj);
|
||||
void parseTocUl(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