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 | |
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
-rw-r--r-- | doc/Doxyfile | 4 | ||||
-rw-r--r-- | doc/commands.doc | 19 | ||||
-rw-r--r-- | doc/formulas.doc | 29 | ||||
-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 |
12 files changed, 88 insertions, 28 deletions
diff --git a/doc/Doxyfile b/doc/Doxyfile index caf6229..15d210e 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -51,8 +51,8 @@ USE_PDFLATEX = YES STRIP_CODE_COMMENTS = NO HTML_STYLESHEET = doxygen_manual.css HTML_EXTRA_FILES = doxygen_logo.svg -ALIASES = LaTeX="\f$\mbox{\LaTeX}\f$" -ALIASES += TeX="\f$\mbox{\TeX}\f$" +ALIASES = LaTeX="\f(\LaTeX\f)" +ALIASES += TeX="\f(\TeX\f)" ALIASES += forceNewPage="\latexonly \newpage \endlatexonly" LATEX_BATCHMODE = YES LATEX_EXTRA_STYLESHEET = manual.sty diff --git a/doc/commands.doc b/doc/commands.doc index 820d0a3..fb59d28 100644 --- a/doc/commands.doc +++ b/doc/commands.doc @@ -104,6 +104,8 @@ documentation: \refitem cmdexample \\example \refitem cmdexception \\exception \refitem cmdextends \\extends +\refitem cmdfrndopen \\f( +\refitem cmdfrndclose \\f) \refitem cmdfdollar \\f\$ \refitem cmdfbropen \\f[ \refitem cmdfbrclose \\f] @@ -3240,6 +3242,23 @@ class Receiver \sa section \ref formulas "formulas" for an example. <hr> +\section cmdfrndopen \\f( + + \addindex \\f( + + Marks the start of an in-text formula, but contrary to \ref cmdfdollar "\\f$" it will + not explicitly open the math-mode in \LaTeX. + \sa section \ref cmdfrndclose "\\f)" and section \ref formulas "formulas". + +<hr> +\section cmdfrndclose \\f) + + \addindex \\f) + + Marks the end of an in-text formula started with \ref cmdfrndopen "\\f(". + \sa section \ref cmdfrndopen "\\f(" and section \ref formulas "formulas". + +<hr> \section cmdfbropen \\f[ \addindex \\f[ diff --git a/doc/formulas.doc b/doc/formulas.doc index e9a8076..1a87977 100644 --- a/doc/formulas.doc +++ b/doc/formulas.doc @@ -34,10 +34,10 @@ require the above tools. If you enable \ref cfg_use_mathjax "USE_MATHJAX" in the configuration then the latex formulas will be copied to the HTML "as is" and a client side javascript will parse them and turn them into (interactive) images. -There are three ways to include formulas in the documentation. +There are four ways to include formulas in the documentation. <ol> <li>Using in-text formulas that appear in the running text. - These formulas should be put between a pair of \\f\$ + These formulas should be put between a pair of \ref cmdfdollar "\\f\$" commands, so \verbatim The distance between \f$(x_1,y_1)\f$ and \f$(x_2,y_2)\f$ is @@ -47,8 +47,19 @@ There are three ways to include formulas in the documentation. The distance between \f$(x_1,y_1)\f$ and \f$(x_2,y_2)\f$ is \f$\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\f$. <br> +<li>Using in-text formulas that appear in the running text, contrary to + \ref cmdfdollar "\\f$" it will not explicitly open the math mode in \LaTeX. + These formulas should be put between \ref cmdfrndclose "\\f(" and + \ref cmdfrndopen "\\f)" commands, so +\verbatim + The LaTeX and Tex logos are: \f(\LaTeX \f) and \f(\TeX \f). +\endverbatim results in: + + The LaTeX and Tex logos are: \f(\LaTeX \f) and \f(\TeX \f). +<br> <li>Unnumbered displayed formulas that are centered on a separate line. - These formulas should be put between \\f[ and \\f] commands. + These formulas should be put between \ref cmdfbropen "\\f[" and + \ref cmdfbrclose "\\f]" commands. An example: \verbatim \f[ @@ -74,9 +85,9 @@ There are three ways to include formulas in the documentation. \right| \f] <li>Formulas or other latex elements that are not in a math - environment can be specified using \\f{environment}, where + environment can be specified using \ref cmdfcurlyopen "\\f{environment}", where \c environment is the name of the \LaTeX environment, - the corresponding end command is \\f}. Here is an example for an + the corresponding end command is \ref cmdfcurlyclose "\\f}". Here is an example for an equation array \verbatim \f{eqnarray*}{ @@ -94,9 +105,11 @@ There are three ways to include formulas in the documentation. &=& 9.82066032\,\mbox{m/s}^2 \f} </ol> -For the first two commands one should make sure formulas contain -valid commands in \LaTeX's math-mode. For the third command -the section should contain valid command for the specific environment. +For the first and third commands one should make sure formulas contain +valid commands in \LaTeX's math-mode. +The second command should valid text-mode commands that also work in math-mode when using +\ref cfg_use_mathjax "USE_MATHJAX". +For the fourth command the section should contain valid command for the specific environment. \warning Currently, doxygen is not very fault tolerant in recovering from typos in formulas. It may be necessary to remove the 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); } |