From 15151742c9e74609cef362681b9a0b09df5b634c Mon Sep 17 00:00:00 2001 From: Le Tan Date: Sat, 30 Jun 2018 22:16:33 +0800 Subject: [PATCH] HGMarkdownHighlighter: use font family of inline code for MathJax --- src/hgmarkdownhighlighter.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/hgmarkdownhighlighter.cpp b/src/hgmarkdownhighlighter.cpp index a850ee6b..02bcb37d 100644 --- a/src/hgmarkdownhighlighter.cpp +++ b/src/hgmarkdownhighlighter.cpp @@ -49,13 +49,26 @@ HGMarkdownHighlighter::HGMarkdownHighlighter(const QVector &s m_codeBlockFormat.setForeground(QBrush(Qt::darkYellow)); for (int index = 0; index < styles.size(); ++index) { - const pmh_element_type &eleType = styles[index].type; - if (eleType == pmh_VERBATIM) { + switch (styles[index].type) { + case pmh_VERBATIM: m_codeBlockFormat = styles[index].format; - } else if (eleType == pmh_LINK) { + break; + + case pmh_LINK: m_linkFormat = styles[index].format; - } else if (eleType == pmh_IMAGE) { + break; + + case pmh_IMAGE: m_imageFormat = styles[index].format; + break; + + case pmh_CODE: + // Use inline code font family for MathJax format. + m_mathjaxFormat.setFontFamily(styles[index].format.fontFamily()); + break; + + default: + break; } }