From 184ea443799cd27a1e3cd3989c03c183297df890 Mon Sep 17 00:00:00 2001 From: albert-github Date: Sun, 12 Apr 2020 19:17:34 +0200 Subject: Text show as formula when USE_MATHJAX=YES (#7697) When having a line of code like: ``` callback_check = re.compile(r'([^\(]*\(.*)(\* *)(\).*\(.*\))') ``` this is seen as an incomplete formula when using MathJax, the `\(` is seen as start of a MathJax formula. Replacing the backslash by the corresponding code `\` didn't work as this is already translated by the bowser and still picked up by MathJax, so we need `‍` to separate the backslash and the bracket without any spacing. --- src/htmldocvisitor.cpp | 10 ++++++++++ src/htmlgen.cpp | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index bb35cae..ea2dffb 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -2226,6 +2226,11 @@ void HtmlDocVisitor::filter(const char *str) case '<': m_t << "<"; break; case '>': m_t << ">"; break; case '&': m_t << "&"; break; + case '\\': if ((*p == '(') || (*p == ')')) + m_t << "\\‍" << *p++; + else + m_t << c; + break; default: m_t << c; } } @@ -2247,6 +2252,11 @@ void HtmlDocVisitor::filterQuotedCdataAttr(const char* str) case '"': m_t << """; break; case '<': m_t << "<"; break; case '>': m_t << ">"; break; + case '\\': if ((*p == '(') || (*p == ')')) + m_t << "\\‍" << *p++; + else + m_t << c; + break; default: m_t << c; } } diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp index ac42a6a..b157881 100644 --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -668,6 +668,10 @@ void HtmlCodeGenerator::codify(const char *str) { m_t << "<"; p++; } else if (*p=='>') { m_t << ">"; p++; } + else if (*p=='(') + { m_t << "\\‍("; m_col++;p++; } + else if (*p==')') + { m_t << "\\‍)"; m_col++;p++; } else m_t << "\\"; m_col++; @@ -702,6 +706,10 @@ void HtmlCodeGenerator::docify(const char *str) { m_t << "<"; p++; } else if (*p=='>') { m_t << ">"; p++; } + else if (*p=='(') + { m_t << "\\‍("; p++; } + else if (*p==')') + { m_t << "\\‍)"; p++; } else m_t << "\\"; break; @@ -1502,6 +1510,10 @@ void HtmlGenerator::docify(const char *str,bool inHtmlComment) { t << "<"; p++; } else if (*p=='>') { t << ">"; p++; } + else if (*p=='(') + { t << "\\‍("; p++; } + else if (*p==')') + { t << "\\‍)"; p++; } else t << "\\"; break; -- cgit v0.12