From d59ed22f114398d74d5c3fd1445a7901d26ff93a Mon Sep 17 00:00:00 2001 From: albert-github Date: Sun, 28 May 2017 13:14:50 +0200 Subject: Bug 783134 - LaTeX output for \tparam block fails to compile when it contains a \code block General problem regarding having a code / verbatim section inside a table. Besides handling of the $ some other characters need special handling as well as the \n. --- src/latexdocvisitor.cpp | 3 +++ src/latexdocvisitor.h | 1 + src/latexgen.cpp | 6 +++++- src/util.cpp | 7 +++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp index 9016c25..5463830 100644 --- a/src/latexdocvisitor.cpp +++ b/src/latexdocvisitor.cpp @@ -35,6 +35,7 @@ #include "plantuml.h" const int maxLevels=5; +int usedTableLevels = 0; static const char *secLabels[maxLevels] = { "section","subsection","subsubsection","paragraph","subparagraph" }; @@ -1391,6 +1392,7 @@ void LatexDocVisitor::visitPre(DocParamSect *s) if (m_hide) return; bool hasInOutSpecs = s->hasInOutSpecifier(); bool hasTypeSpecs = s->hasTypeSpecifier(); + usedTableLevels++; switch(s->type()) { case DocParamSect::Param: @@ -1424,6 +1426,7 @@ void LatexDocVisitor::visitPre(DocParamSect *s) void LatexDocVisitor::visitPost(DocParamSect *s) { if (m_hide) return; + usedTableLevels--; switch(s->type()) { case DocParamSect::Param: diff --git a/src/latexdocvisitor.h b/src/latexdocvisitor.h index 02df1ef..9ad162f 100644 --- a/src/latexdocvisitor.h +++ b/src/latexdocvisitor.h @@ -24,6 +24,7 @@ #include #include //#include +extern int usedTableLevels; class FTextStream; class CodeOutputInterface; diff --git a/src/latexgen.cpp b/src/latexgen.cpp index 8d338ae..84dd9c2 100644 --- a/src/latexgen.cpp +++ b/src/latexgen.cpp @@ -92,7 +92,7 @@ void LatexCodeGenerator::codify(const char *str) m_col+=spacesToNextTabStop; p++; break; - case '\n': m_t << '\n'; m_col=0; p++; + case '\n': (usedTableLevels>0) ? m_t << "\\newline\n" : m_t << '\n'; m_col=0; p++; break; default: i=0; @@ -1843,11 +1843,13 @@ void LatexGenerator::writeNonBreakableSpace(int) void LatexGenerator::startDescTable(const char *title) { + usedTableLevels++; t << "\\begin{DoxyEnumFields}{" << title << "}" << endl; } void LatexGenerator::endDescTable() { + usedTableLevels--; t << "\\end{DoxyEnumFields}" << endl; } @@ -2190,6 +2192,7 @@ void LatexGenerator::lineBreak(const char *) void LatexGenerator::startMemberDocSimple(bool isEnum) { + usedTableLevels++; if (isEnum) { t << "\\begin{DoxyEnumFields}{"; @@ -2205,6 +2208,7 @@ void LatexGenerator::startMemberDocSimple(bool isEnum) void LatexGenerator::endMemberDocSimple(bool isEnum) { + usedTableLevels--; if (isEnum) { t << "\\end{DoxyEnumFields}" << endl; diff --git a/src/util.cpp b/src/util.cpp index e44f825..02be332 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -47,6 +47,7 @@ #include "searchindex.h" #include "doxygen.h" #include "textdocvisitor.h" +#include "latexdocvisitor.h" #include "portable.h" #include "parserintf.h" #include "bufstr.h" @@ -6655,6 +6656,12 @@ void filterLatexString(FTextStream &t,const char *str, case '{': t << "\\{"; break; case '}': t << "\\}"; break; case '_': t << "\\_"; break; + case '&': t << "\\&"; break; + case '%': t << "\\%"; break; + case '#': t << "\\#"; break; + case '$': t << "\\$"; break; + case '^': (usedTableLevels>0) ? t << "\\string^" : t << (char)c; break; + case '~': (usedTableLevels>0) ? t << "\\string~" : t << (char)c; break; case ' ': if (keepSpaces) t << "~"; else t << ' '; break; default: -- cgit v0.12 From 8afcb87097c92fd124282a998dad61ea2b16c7ec Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Sun, 31 Dec 2017 13:09:54 +0100 Subject: Bug 783134 - LaTeX output for \tparam block fails to compile when it contains a \code block --- src/latexdocvisitor.cpp | 5 ++--- src/latexdocvisitor.h | 2 -- src/latexgen.cpp | 10 +++++----- src/util.cpp | 24 ++++++++++++++++++++++-- src/util.h | 4 ++++ 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp index 9bddf36..5a67c15 100644 --- a/src/latexdocvisitor.cpp +++ b/src/latexdocvisitor.cpp @@ -35,7 +35,6 @@ #include "plantuml.h" const int maxLevels=5; -int usedTableLevels = 0; static const char *secLabels[maxLevels] = { "section","subsection","subsubsection","paragraph","subparagraph" }; @@ -1392,7 +1391,7 @@ void LatexDocVisitor::visitPre(DocParamSect *s) if (m_hide) return; bool hasInOutSpecs = s->hasInOutSpecifier(); bool hasTypeSpecs = s->hasTypeSpecifier(); - usedTableLevels++; + incUsedTableLevels(); switch(s->type()) { case DocParamSect::Param: @@ -1426,7 +1425,7 @@ void LatexDocVisitor::visitPre(DocParamSect *s) void LatexDocVisitor::visitPost(DocParamSect *s) { if (m_hide) return; - usedTableLevels--; + decUsedTableLevels(); switch(s->type()) { case DocParamSect::Param: diff --git a/src/latexdocvisitor.h b/src/latexdocvisitor.h index bd89f03..881863a 100644 --- a/src/latexdocvisitor.h +++ b/src/latexdocvisitor.h @@ -23,8 +23,6 @@ #include #include #include -//#include -extern int usedTableLevels; class FTextStream; class CodeOutputInterface; diff --git a/src/latexgen.cpp b/src/latexgen.cpp index 6e52a84..1511dcb 100644 --- a/src/latexgen.cpp +++ b/src/latexgen.cpp @@ -92,7 +92,7 @@ void LatexCodeGenerator::codify(const char *str) m_col+=spacesToNextTabStop; p++; break; - case '\n': (usedTableLevels>0) ? m_t << "\\newline\n" : m_t << '\n'; m_col=0; p++; + case '\n': (usedTableLevels()>0) ? m_t << "\\newline\n" : m_t << '\n'; m_col=0; p++; break; default: i=0; @@ -1849,13 +1849,13 @@ void LatexGenerator::writeNonBreakableSpace(int) void LatexGenerator::startDescTable(const char *title) { - usedTableLevels++; + incUsedTableLevels(); t << "\\begin{DoxyEnumFields}{" << title << "}" << endl; } void LatexGenerator::endDescTable() { - usedTableLevels--; + decUsedTableLevels(); t << "\\end{DoxyEnumFields}" << endl; } @@ -2198,7 +2198,7 @@ void LatexGenerator::lineBreak(const char *) void LatexGenerator::startMemberDocSimple(bool isEnum) { - usedTableLevels++; + incUsedTableLevels(); if (isEnum) { t << "\\begin{DoxyEnumFields}{"; @@ -2214,7 +2214,7 @@ void LatexGenerator::startMemberDocSimple(bool isEnum) void LatexGenerator::endMemberDocSimple(bool isEnum) { - usedTableLevels--; + decUsedTableLevels(); if (isEnum) { t << "\\end{DoxyEnumFields}" << endl; diff --git a/src/util.cpp b/src/util.cpp index ab7079e..8e936b5 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -6730,8 +6730,8 @@ void filterLatexString(FTextStream &t,const char *str, case '%': t << "\\%"; break; case '#': t << "\\#"; break; case '$': t << "\\$"; break; - case '^': (usedTableLevels>0) ? t << "\\string^" : t << (char)c; break; - case '~': (usedTableLevels>0) ? t << "\\string~" : t << (char)c; break; + case '^': (usedTableLevels()>0) ? t << "\\string^" : t << (char)c; break; + case '~': (usedTableLevels()>0) ? t << "\\string~" : t << (char)c; break; case ' ': if (keepSpaces) t << "~"; else t << ' '; break; default: @@ -8830,3 +8830,23 @@ void writeExtraLatexPackages(FTextStream &t) } } +//------------------------------------------------------ + +static int g_usedTableLevels = 0; + +void incUsedTableLevels() +{ + g_usedTableLevels++; +} +void decUsedTableLevels() +{ + g_usedTableLevels--; +} +int usedTableLevels() +{ + return g_usedTableLevels; +} + +//------------------------------------------------------ + + diff --git a/src/util.h b/src/util.h index 322ba7e..7cbe5e3 100644 --- a/src/util.h +++ b/src/util.h @@ -478,5 +478,9 @@ bool mainPageHasTitle(); bool openOutputFile(const char *outFile,QFile &f); void writeExtraLatexPackages(FTextStream &t); +int usedTableLevels(); +void incUsedTableLevels(); +void decUsedTableLevels(); + #endif -- cgit v0.12