diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2021-05-01 17:33:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-01 17:33:29 (GMT) |
commit | 59edaeeed17cc8d7323e1c555c073786feab87db (patch) | |
tree | 488e82f28e06abdd001ae0b385c9e1f19db8fafe /src | |
parent | 77ee20e5b3ac5c8a6360f04f4d19fe681c3ada50 (diff) | |
parent | 200c31bf342c533de77fede161e18e395c5ce875 (diff) | |
download | Doxygen-59edaeeed17cc8d7323e1c555c073786feab87db.zip Doxygen-59edaeeed17cc8d7323e1c555c073786feab87db.tar.gz Doxygen-59edaeeed17cc8d7323e1c555c073786feab87db.tar.bz2 |
Merge pull request #8509 from albert-github/feature/bug_formula_mj
Problems with some commands in MathJax
Diffstat (limited to 'src')
-rw-r--r-- | src/commentcnv.l | 8 | ||||
-rw-r--r-- | src/commentscan.l | 20 | ||||
-rw-r--r-- | src/docparser.h | 2 | ||||
-rw-r--r-- | src/htmldocvisitor.cpp | 5 | ||||
-rw-r--r-- | src/lexcode.l | 4 | ||||
-rw-r--r-- | src/lexscanner.l | 4 | ||||
-rw-r--r-- | src/markdown.cpp | 5 | ||||
-rw-r--r-- | src/pre.l | 4 | ||||
-rw-r--r-- | src/scanner.l | 12 |
9 files changed, 46 insertions, 18 deletions
diff --git a/src/commentcnv.l b/src/commentcnv.l index 23611a9..d331fa4 100644 --- a/src/commentcnv.l +++ b/src/commentcnv.l @@ -438,7 +438,7 @@ SLASHopt [/]* } BEGIN(VerbatimCode); } -<CComment,ReadLine>[\\@]("f$"|"f["|"f{") { +<CComment,ReadLine>[\\@]("f$"|"f["|"f{"|"f(") { copyToOutput(yyscanner,yytext,(int)yyleng); yyextra->blockName=&yytext[1]; if (yyextra->blockName.at(1)=='[') @@ -449,6 +449,10 @@ SLASHopt [/]* { yyextra->blockName.at(1)='}'; } + else if (yyextra->blockName.at(1)=='(') + { + yyextra->blockName.at(1)=')'; + } yyextra->lastCommentContext = YY_START; BEGIN(Verbatim); } @@ -467,7 +471,7 @@ SLASHopt [/]* <Scan>. { /* any other character */ copyToOutput(yyscanner,yytext,(int)yyleng); } -<Verbatim>[\\@]("endverbatim"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}") { /* end of verbatim block */ +<Verbatim>[\\@]("endverbatim"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"f$"|"f]"|"f}"|"f)") { /* end of verbatim block */ copyToOutput(yyscanner,yytext,(int)yyleng); if (&yytext[1]==yyextra->blockName) // end of formula { diff --git a/src/commentscan.l b/src/commentscan.l index 399f5fb..adf7e1b 100644 --- a/src/commentscan.l +++ b/src/commentscan.l @@ -541,6 +541,7 @@ STopt [^\n@\\]* %x InheritParam %x ExtendsParam %x ReadFormulaShort +%x ReadFormulaRound %x ReadFormulaLong %x AnchorLabel %x HtmlComment @@ -556,7 +557,7 @@ STopt [^\n@\\]* /* What can happen in while parsing a comment block: * commands (e.g. @page, or \page) * escaped commands (e.g. @@page or \\page). - * formulas (e.g. \f$...\f$ \f[...\f] \f{...\f}) + * formulas (e.g. \f$...\f$ \f[...\f] \f{...\f} \f(...\f) ) * directories (e.g. \doxygen\src\) * autolist end. (e.g. a dot on an otherwise empty line) * newlines. @@ -754,6 +755,11 @@ STopt [^\n@\\]* yyextra->formulaNewLines=0; BEGIN(ReadFormulaShort); } +<Comment>{B}*{CMD}"f(" { // start of a inline formula + yyextra->formulaText=""; + yyextra->formulaNewLines=0; + BEGIN(ReadFormulaRound); + } <Comment>{B}*{CMD}"f[" { // start of a block formula setOutput(yyscanner,OutputDoc); yyextra->formulaText="\\["; @@ -937,6 +943,10 @@ STopt [^\n@\\]* addOutput(yyscanner," "+addFormula(yyscanner)); BEGIN(Comment); } +<ReadFormulaRound>{CMD}"f)" { // end of inline formula + addOutput(yyscanner," "+addFormula(yyscanner)); + BEGIN(Comment); + } <ReadFormulaLong>{CMD}"f]" { // end of block formula yyextra->formulaText+="\\]"; addOutput(yyscanner," "+addFormula(yyscanner)); @@ -948,15 +958,15 @@ STopt [^\n@\\]* addOutput(yyscanner," "+addFormula(yyscanner)); BEGIN(Comment); } -<ReadFormulaLong,ReadFormulaShort>[^\\@\n]+ { // any non-special character +<ReadFormulaLong,ReadFormulaShort,ReadFormulaRound>[^\\@\n]+ { // any non-special character yyextra->formulaText+=yytext; } -<ReadFormulaLong,ReadFormulaShort>\n { // new line +<ReadFormulaLong,ReadFormulaShort,ReadFormulaRound>\n { // new line yyextra->formulaNewLines++; yyextra->formulaText+=*yytext; yyextra->lineNr++; } -<ReadFormulaLong,ReadFormulaShort>. { // any other character +<ReadFormulaLong,ReadFormulaShort,ReadFormulaRound>. { // any other character yyextra->formulaText+=*yytext; } @@ -3255,7 +3265,7 @@ static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size) static void checkFormula(yyscan_t yyscanner) { struct yyguts_t *yyg = (struct yyguts_t*)yyscanner; - if (YY_START==ReadFormulaShort || YY_START==ReadFormulaLong) + if (YY_START==ReadFormulaShort || YY_START==ReadFormulaRound || YY_START==ReadFormulaLong) { warn(yyextra->fileName,yyextra->lineNr,"End of comment block while inside formula."); } diff --git a/src/docparser.h b/src/docparser.h index 548376d..44cd8dc 100644 --- a/src/docparser.h +++ b/src/docparser.h @@ -637,7 +637,7 @@ class DocFormula : public DocNode QCString relPath() const { return m_relPath; } int id() const { return m_id; } void accept(DocVisitor *v) { v->visit(this); } - bool isInline() { return m_text.length()>0 ? m_text.at(0)!='\\' : TRUE; } + bool isInline() { return m_text.length()>1 ? !(m_text.at(0)=='\\' && (m_text.at(1)=='{' || m_text.at(1)=='[')): TRUE; } private: QCString m_name; diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index a1c0fb4..a8544e9 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -853,6 +853,11 @@ void HtmlDocVisitor::visit(DocFormula *f) text = text.mid(1,text.length()-2); m_t << "\\("; } + else if (!bDisplay && !text.isEmpty()) + { + closeInline=TRUE; + m_t << "\\("; + } m_t << convertToHtml(text); if (closeInline) { diff --git a/src/lexcode.l b/src/lexcode.l index 4cfb636..59b05b7 100644 --- a/src/lexcode.l +++ b/src/lexcode.l @@ -724,7 +724,7 @@ NONLopt [^\n]* <DocBlock>({CMD}{CMD}){ID}/[^a-z_A-Z0-9] { // escaped command yyextra->CCodeBuffer += yytext; } -<DocBlock>{CMD}("f$"|"f["|"f{") { +<DocBlock>{CMD}("f$"|"f["|"f{"|"f(") { yyextra->CCodeBuffer += yytext; yyextra->docBlockName=&yytext[1]; if (yyextra->docBlockName.at(1)=='{') @@ -794,7 +794,7 @@ NONLopt [^\n]* BEGIN(DocBlock); } } -<DocCopyBlock>[\\@]("f$"|"f]"|"f}") { +<DocCopyBlock>[\\@]("f$"|"f]"|"f}"|"f)") { yyextra->CCodeBuffer += yytext; BEGIN(DocBlock); } diff --git a/src/lexscanner.l b/src/lexscanner.l index cd06464..2b6b3a0 100644 --- a/src/lexscanner.l +++ b/src/lexscanner.l @@ -706,7 +706,7 @@ NONLopt [^\n]* <DocBlock>({CMD}{CMD}){ID}/[^a-z_A-Z0-9] { // escaped command yyextra->cCodeBuffer += yytext; } -<DocBlock>{CMD}("f$"|"f["|"f{") { +<DocBlock>{CMD}("f$"|"f["|"f{"|"f(") { yyextra->cCodeBuffer += yytext; yyextra->docBlockName=&yytext[1]; if (yyextra->docBlockName.at(1)=='{') @@ -775,7 +775,7 @@ NONLopt [^\n]* BEGIN(DocBlock); } } -<DocCopyBlock>[\\@]("f$"|"f]"|"f}") { +<DocCopyBlock>[\\@]("f$"|"f]"|"f}"|"f)") { yyextra->cCodeBuffer += yytext; BEGIN(DocBlock); } diff --git a/src/markdown.cpp b/src/markdown.cpp index 4627e73..59ef730 100644 --- a/src/markdown.cpp +++ b/src/markdown.cpp @@ -303,6 +303,7 @@ static Alignment markersToAlignment(bool leftMarker,bool rightMarker) // \code .. \endcode // \msc .. \endmsc // \f$..\f$ +// \f(..\f) // \f[..\f] // \f{..\f} // \verbatim..\endverbatim @@ -351,6 +352,10 @@ QCString Markdown::isBlockCommand(const char *data,int offset,int size) { return "f$"; } + else if (data[end]=='(') + { + return "f)"; + } else if (data[end]=='[') { return "f]"; @@ -1164,7 +1164,7 @@ WSopt [ \t\r]* outputChar(yyscanner,'/');outputChar(yyscanner,'*'); //yyextra->commentCount++; } -<SkipCComment>[\\@][\\@]("f{"|"f$"|"f[") { +<SkipCComment>[\\@][\\@]("f{"|"f$"|"f[""f(") { outputArray(yyscanner,yytext,yyleng); } <SkipCComment>^({B}*"*"+)?{B}{0,3}"~~~"[~]* { @@ -1316,7 +1316,7 @@ WSopt [ \t\r]* BEGIN(yyextra->condCtx); } } -<SkipVerbatim>[\\@]("endverbatim"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"enddot"|"endcode"|"f$"|"f]"|"f}") { /* end of verbatim block */ +<SkipVerbatim>[\\@]("endverbatim"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endrtfonly"|"endmanonly"|"enddot"|"endcode"|"f$"|"f]"|"f}""f}") { /* end of verbatim block */ outputArray(yyscanner,yytext,yyleng); if (yytext[1]=='f' && yyextra->blockName=="f") { diff --git a/src/scanner.l b/src/scanner.l index f03304a..70c13c4 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -4521,7 +4521,7 @@ NONLopt [^\n]* yyextra->fullArgString+=yytext; BEGIN(CopyArgVerbatim); } -<CopyArgCommentLine>{CMD}("f$"|"f["|"f{") { +<CopyArgCommentLine>{CMD}("f$"|"f["|"f{"|"f(") { yyextra->docBlockName=&yytext[1]; if (yyextra->docBlockName.at(1)=='[') { @@ -4531,10 +4531,14 @@ NONLopt [^\n]* { yyextra->docBlockName.at(1)='}'; } + if (yyextra->docBlockName.at(1)=='(') + { + yyextra->docBlockName.at(1)=')'; + } yyextra->fullArgString+=yytext; BEGIN(CopyArgVerbatim); } -<CopyArgVerbatim>[\\@]("endverbatim"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endmanonly"|"endrtfonly"|"enddot"|"endcode"|"f$"|"f]"|"f}")/[^a-z_A-Z0-9\-] { // end of verbatim block +<CopyArgVerbatim>[\\@]("endverbatim"|"endlatexonly"|"endhtmlonly"|"endxmlonly"|"enddocbookonly"|"endmanonly"|"endrtfonly"|"enddot"|"endcode"|"f$"|"f]"|"f}"|"f)")/[^a-z_A-Z0-9\-] { // end of verbatim block yyextra->fullArgString+=yytext; if (yytext[1]=='f') // end of formula { @@ -6531,7 +6535,7 @@ NONLopt [^\n]* <DocBlock>({CMD}{CMD}){ID}/[^a-z_A-Z0-9] { // escaped command yyextra->docBlock << yytext; } -<DocBlock>{CMD}("f$"|"f["|"f{") { +<DocBlock>{CMD}("f$"|"f["|"f{"|"f(") { yyextra->docBlock << yytext; yyextra->docBlockName=&yytext[1]; if (yyextra->docBlockName.at(1)=='{') @@ -6613,7 +6617,7 @@ NONLopt [^\n]* BEGIN(DocBlock); } } -<DocCopyBlock>[\\@]("f$"|"f]"|"f}") { +<DocCopyBlock>[\\@]("f$"|"f]"|"f}"|"f)") { yyextra->docBlock << yytext; BEGIN(DocBlock); } |