From a390d6a9ad62019c7ca3d3689184fd3ce6afd57c Mon Sep 17 00:00:00 2001 From: albert-github Date: Mon, 12 Aug 2019 18:51:01 +0200 Subject: Incorrect NCName in docbook citations In a bibtex reference it is possible to have a colon as the id, but in docbook this will result in: ``` docbook/citelist.xml:5: validity error : xml:id : attribute value _citelist_1CITEREF_pre:post is not an NCName [1] ``` So the id has to be translated. A colon in an id can only happen in case the names is provided from the outside. --- src/docbookvisitor.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp index ce3a845..83c34e7 100644 --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -36,6 +36,7 @@ #include "htmlentity.h" #include "emoji.h" #include "plantuml.h" +#include "growbuf.h" #if 0 #define DB_VIS_C DB_VIS_C1(m_t) @@ -49,6 +50,25 @@ #define DB_VIS_C2a(x,y) #endif +static QCString filterId(const char *s) +{ + static GrowBuf growBuf; + growBuf.clear(); + if (s==0) return ""; + const unsigned char *p=(const unsigned char *)s; + char c; + while ((c=*p++)) + { + switch (c) + { + case ':': growBuf.addStr("_1"); break; + default: growBuf.addChar(c); break; + } + } + growBuf.addChar(0); + return growBuf.get(); +} + void DocbookDocVisitor::visitCaption(const QList &children) { QListIterator cli(children); @@ -374,7 +394,7 @@ void DocbookDocVisitor::visit(DocAnchor *anc) { DB_VIS_C if (m_hide) return; - m_t << "file()) << "_1" << anc->anchor() << "\"/>"; + m_t << "file()) << "_1" << filterId(anc->anchor()) << "\"/>"; } void DocbookDocVisitor::visit(DocInclude *inc) @@ -550,7 +570,7 @@ void DocbookDocVisitor::visit(DocCite *cite) { DB_VIS_C if (m_hide) return; - if (!cite->file().isEmpty()) startLink(cite->file(),cite->anchor()); + if (!cite->file().isEmpty()) startLink(cite->file(),filterId(cite->anchor())); filter(cite->text()); if (!cite->file().isEmpty()) endLink(); } -- cgit v0.12 From d43815b2d1aed4fd10a918f18688c35995298677 Mon Sep 17 00:00:00 2001 From: albert-github Date: Mon, 19 Aug 2019 14:39:12 +0200 Subject: Warning in case of usage of a single quote in a code span. When we have a single quotes in a codespan we can get the warning: ``` warning: found tag without matching ``` Added the workaround to the documentation. --- doc/markdown.doc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/markdown.doc b/doc/markdown.doc index 5edbaf9..883e831 100644 --- a/doc/markdown.doc +++ b/doc/markdown.doc @@ -193,10 +193,12 @@ code spans appear inline in a paragraph. An example: Use the `printf()` function. -To show a literal backtick inside a code span use double backticks, i.e. +To show a literal backtick or single quote inside a code span use double backticks, i.e. To assign the output of command `ls` to `var` use ``var=`ls```. + To assign the text 'text' to `var` use ``var='text'``. + See section \ref mddox_code_spans for more info how doxygen handles code spans slightly different than standard Markdown. @@ -606,6 +608,9 @@ In other words; a single quote cancels the special treatment of a code span wrapped in a pair of backtick characters. This extra restriction was added for backward compatibility reasons. +In case you want to have single quotes inside a code span, don't use +one backtick but two backticks around the code span. + \subsection mddox_lists Lists Extensions With Markdown two lists separated by an empty line are joined together into -- cgit v0.12 From 5576550317561f0fc33c26db144d0bea5561bc9f Mon Sep 17 00:00:00 2001 From: albert-github Date: Tue, 20 Aug 2019 12:34:59 +0200 Subject: issue #7210: 1.8.16: Image inclusion is inconsistent The consequence of #7084 (Missing warning about ambiguous files) was that in case a file was ambiguous only a message was given. Now a warning is given plus one of the ambiguous files is used (might be the wrong one). --- src/docparser.cpp | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/src/docparser.cpp b/src/docparser.cpp index 9dd1c71..4ec4b52 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -287,8 +287,17 @@ static QCString findAndCopyImage(const char *fileName,DocImage::Type type, bool bool ambig; FileDef *fd; //printf("Search for %s\n",fileName); - if ((fd=findFileDef(Doxygen::imageNameDict,fileName,ambig)) && !ambig) + if (fd=findFileDef(Doxygen::imageNameDict,fileName,ambig)) { + if (ambig & dowarn) + { + QCString text; + text.sprintf("image file name %s is ambiguous.\n",qPrint(fileName)); + text+="Possible candidates:\n"; + text+=showFileDefMatches(Doxygen::imageNameDict,fileName); + warn_doc_error(g_fileName,doctokenizerYYlineno,text); + } + QCString inputFile = fd->absFilePath(); QFile inImage(inputFile); if (inImage.open(IO_ReadOnly)) @@ -378,17 +387,6 @@ static QCString findAndCopyImage(const char *fileName,DocImage::Type type, bool return baseName; } } - else if (ambig) - { - if (dowarn) - { - QCString text; - text.sprintf("image file name %s is ambiguous.\n",qPrint(fileName)); - text+="Possible candidates:\n"; - text+=showFileDefMatches(Doxygen::imageNameDict,fileName); - warn_doc_error(g_fileName,doctokenizerYYlineno,text); - } - } else { result=fileName; @@ -1846,16 +1844,16 @@ static void readTextFileByName(const QCString &file,QCString &text) // as a fallback we also look in the exampleNameDict bool ambig; FileDef *fd; - if ((fd=findFileDef(Doxygen::exampleNameDict,file,ambig)) && !ambig) + if (fd=findFileDef(Doxygen::exampleNameDict,file,ambig)) { text = fileToString(fd->absFilePath(),Config_getBool(FILTER_SOURCE_FILES)); - } - else if (ambig) - { - warn_doc_error(g_fileName,doctokenizerYYlineno,"included file name %s is ambiguous" + if (ambig) + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"included file name %s is ambiguous" "Possible candidates:\n%s",qPrint(file), qPrint(showFileDefMatches(Doxygen::exampleNameDict,file)) ); + } } else { @@ -2748,17 +2746,17 @@ bool DocDotFile::parse() { fd = findFileDef(Doxygen::dotFileNameDict,m_name+".dot",ambig); } - if (fd && !ambig) + if (fd) { m_file = fd->absFilePath(); ok = true; - } - else if (ambig) - { - warn_doc_error(g_fileName,doctokenizerYYlineno,"included dot file name %s is ambiguous.\n" + if (ambig) + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"included dot file name %s is ambiguous.\n" "Possible candidates:\n%s",qPrint(m_name), qPrint(showFileDefMatches(Doxygen::dotFileNameDict,m_name)) ); + } } else { @@ -2785,17 +2783,17 @@ bool DocMscFile::parse() { fd = findFileDef(Doxygen::mscFileNameDict,m_name+".msc",ambig); } - if (fd && !ambig) + if (fd) { m_file = fd->absFilePath(); ok = true; - } - else if (ambig) - { - warn_doc_error(g_fileName,doctokenizerYYlineno,"included msc file name %s is ambiguous.\n" + if (ambig) + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"included msc file name %s is ambiguous.\n" "Possible candidates:\n%s",qPrint(m_name), qPrint(showFileDefMatches(Doxygen::mscFileNameDict,m_name)) ); + } } else { @@ -2824,17 +2822,17 @@ bool DocDiaFile::parse() { fd = findFileDef(Doxygen::diaFileNameDict,m_name+".dia",ambig); } - if (fd && !ambig) + if (fd) { m_file = fd->absFilePath(); ok = true; - } - else if (ambig) - { - warn_doc_error(g_fileName,doctokenizerYYlineno,"included dia file name %s is ambiguous.\n" + if (ambig) + { + warn_doc_error(g_fileName,doctokenizerYYlineno,"included dia file name %s is ambiguous.\n" "Possible candidates:\n%s",qPrint(m_name), qPrint(showFileDefMatches(Doxygen::diaFileNameDict,m_name)) ); + } } else { -- cgit v0.12 From 4e2a1ac22f27046f16acc95ea7d763a67bb7f344 Mon Sep 17 00:00:00 2001 From: albert-github Date: Fri, 23 Aug 2019 15:15:37 +0200 Subject: Text ' ' appears in code segments In case we have the UTF-8 code for nbsp in our source this is (see #6983) replaced with ` `, though in code fragments this is unwanted as here the text appears literally. the UTF-8 nbsp is temporary replaced by a "doxygen" tag and for fenced code blocks, backtick blocks and special bloc commands (code, verbatim, htmlonly, formulas,...) replaced back with the UTF-8 version, the remaining "doxygen" tags are at the end replaced with ` ` --- src/markdown.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/markdown.cpp b/src/markdown.cpp index 2cbdcb5..a3455ab 100644 --- a/src/markdown.cpp +++ b/src/markdown.cpp @@ -108,7 +108,8 @@ static Entry *g_current; static QCString g_fileName; static int g_lineNr; static int g_indentLevel=0; // 0 is outside markdown, -1=page level - +static char g_doxynbsputf8[3] = {'\xc2', '\xa0', '\0'}; // UTF-8 nbsp +static char *g_doxynbsp = "&_doxy_nbsp;"; //---------- const int codeBlockIndent = 4; @@ -1044,7 +1045,7 @@ static int processSpecialCommand(GrowBuf &out, const char *data, int offset, int if (qstrncmp(&data[i+1],endBlockName,l)==0) { //printf("found end at %d\n",i); - out.addStr(data,i+1+l); + out.addStr(substitute(QCString(data).left(i+1+l),g_doxynbsp,g_doxynbsputf8)); return i+1+l; } } @@ -2174,7 +2175,7 @@ static void writeFencedCodeBlock(GrowBuf &out,const char *data,const char *lng, { out.addStr("{"+lang+"}"); } - out.addStr(data+blockStart,blockEnd-blockStart); + out.addStr(substitute(QCString(data+blockStart).left(blockEnd-blockStart),g_doxynbsp,g_doxynbsputf8)); out.addStr("\n"); out.addStr("@endcode"); } @@ -2484,7 +2485,7 @@ static QCString detab(const QCString &s,int &refIndent) // special handling of the UTF-8 nbsp character 0xc2 0xa0 if (c == '\xc2' && data[i] == '\xa0') { - out.addStr(" "); + out.addStr(g_doxynbsp); i++; } else @@ -2561,7 +2562,7 @@ QCString processMarkdown(const QCString &fileName,const int lineNr,Entry *e,cons processInline(out,s,s.length()); out.addChar(0); Debug::print(Debug::Markdown,0,"======== Markdown =========\n---- input ------- \n%s\n---- output -----\n%s\n=========\n",qPrint(input),qPrint(out.get())); - return out.get(); + return substitute(out.get(),g_doxynbsp," "); } //--------------------------------------------------------------------------- -- cgit v0.12 From fd3b60caa8bb99bec81b74d74f394c6043091c76 Mon Sep 17 00:00:00 2001 From: albert-github Date: Tue, 27 Aug 2019 16:55:47 +0200 Subject: Create possibility to define LaTeX commands for formulas To be able to have building bocks for formulas one can create a `\newcommand` (or when one wants to change a command `\renewcommand`). Due to the different handling of LaTeX commands in pure LaTeX code (latex output and formulas converted to images) and MathJax it is necessary to transform LaTeX commands to the MathJax equivalent. This is done in a transparent way by providing the new commands in a file and add this verbatim to the pure LaTeX code and to translate the `\newcommand` and `\renewcomamnd` to MathJax macros. --- addon/doxywizard/expert.cpp | 3 + doc/formulas.doc | 20 ++++- src/config.xml | 10 +++ src/configgen.py | 2 + src/formula.cpp | 14 ++++ src/htmlgen.cpp | 185 +++++++++++++++++++++++++++++++++++++++++++- src/latexgen.cpp | 10 +++ 7 files changed, 242 insertions(+), 2 deletions(-) diff --git a/addon/doxywizard/expert.cpp b/addon/doxywizard/expert.cpp index 64df27f..1303a22 100644 --- a/addon/doxywizard/expert.cpp +++ b/addon/doxywizard/expert.cpp @@ -398,6 +398,7 @@ static QString getDocsForNode(const QDomElement &child) // Remove / replace doxygen markup strings // the regular expressions are hard to read so the intention will be given + // Note: see also configgen.py in the src directory for other doxygen parts QRegExp regexp; // remove \n at end and replace by a space regexp.setPattern(SA("\\n$")); @@ -432,6 +433,8 @@ static QString getDocsForNode(const QDomElement &child) docs.replace(regexp,SA("\"External Indexing and Searching\"")); regexp.setPattern(SA("\\\\ref[ ]+external")); docs.replace(regexp,SA("\"Linking to external documentation\"")); + regexp.setPattern(SA("\\\\ref[ ]+formulas")); + docs.replace(regexp,SA("\"Including formulas\"")); // fallback for not handled docs.replace(SA("\\\\ref"),SA("")); // \b word -> word<\b> diff --git a/doc/formulas.doc b/doc/formulas.doc index 520f089..88a8725 100644 --- a/doc/formulas.doc +++ b/doc/formulas.doc @@ -100,9 +100,27 @@ 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 -files formula.repository that are written to the html and rtf directories to +files formula.repository that are written to the html, rtf etc. directories to get rid of an incorrect formula as well as the form_* files. +To have the possibility to define your own \LaTeX commands, for e.g. formula building blocks +or consistent writing of certain words, the configuration option \ref cfg_formula_macrofile "FORMULA_MACROFILE" +can be used. to supply a file with \LaTeX commands. +This file can contain \LaTeX `\newcommand` and \`renewcommand` commands and they are included +formulas (image version and MathJax version) as well as in the generated \LaTeX output (for PDF generation).
+The `\newcommand` (and `\renewcommand`) are restricted to a version without optional +parameters so only the following types are supported: +``` +\newcommand{\cmd}{replacement} + and +\newcommand{\cmd}[nr]{replacement} +``` +e.g. +``` +\newcommand{\E}{\mathrm{E}} +\newcommand{\ccSum}[3]{\sum_{#1}^{#2}{#3}} +``` + \htmlonly Go to the next section or return to the index. diff --git a/src/config.xml b/src/config.xml index e68b3d7..a226863 100644 --- a/src/config.xml +++ b/src/config.xml @@ -2377,6 +2377,16 @@ The \c DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. ]]> +