diff --git a/src/vedittab.cpp b/src/vedittab.cpp index e722950a..79f80f43 100644 --- a/src/vedittab.cpp +++ b/src/vedittab.cpp @@ -135,10 +135,20 @@ void VEditTab::previewByConverter() QString html = mdConverter.generateHtml(content, vconfig.getMarkdownExtensions()); QRegularExpression tocExp("
\\[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 ``.
+ p_toc.replace("", "_");
+ p_toc.replace("", "_");
}
void VEditTab::showFileEditMode()
diff --git a/src/vedittab.h b/src/vedittab.h
index 91d40858..c7eb6e63 100644
--- a/src/vedittab.h
+++ b/src/vedittab.h
@@ -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