diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2018-05-01 17:20:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-01 17:20:15 (GMT) |
commit | 5719de71298c5e9c067b01bf68c90a308f65cedb (patch) | |
tree | ecbdc40672b381ce9a6de9c5d4f4c950fb9ec778 /src | |
parent | 2ea42a5bbc6a6f720502da775a649371bce46d00 (diff) | |
parent | ee1ea269e1c684cf5ff39ed836fd8af288837275 (diff) | |
download | Doxygen-5719de71298c5e9c067b01bf68c90a308f65cedb.zip Doxygen-5719de71298c5e9c067b01bf68c90a308f65cedb.tar.gz Doxygen-5719de71298c5e9c067b01bf68c90a308f65cedb.tar.bz2 |
Merge pull request #711 from albert-github/feature/bug_768240
Bug 768240 - Make maxLineLen of latex output configurable
Diffstat (limited to 'src')
-rw-r--r-- | src/latexdocvisitor.cpp | 16 | ||||
-rw-r--r-- | src/latexgen.cpp | 96 |
2 files changed, 83 insertions, 29 deletions
diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp index 5a67c15..86ceade 100644 --- a/src/latexdocvisitor.cpp +++ b/src/latexdocvisitor.cpp @@ -526,7 +526,19 @@ void LatexDocVisitor::visit(DocIncOperator *op) void LatexDocVisitor::visit(DocFormula *f) { if (m_hide) return; - m_t << f->text(); + const char *p=f->text(); + char c; + if (p) + { + while ((c=*p++)) + { + switch (c) + { + case '\'': m_t << "\\text{'}"; break; + default: m_t << c; break; + } + } + } } void LatexDocVisitor::visit(DocIndexEntry *i) @@ -927,7 +939,7 @@ static void writeStartTableCommand(FTextStream &t,const DocNode *n,int cols) } else { - t << "\\tabulinesep=1mm\n\\begin{longtabu} spread 0pt [c]{*{" << cols << "}{|X[-1]}|}\n"; + t << "\\tabulinesep=1mm\n\\begin{longtabu}spread 0pt [c]{*{" << cols << "}{|X[-1]}|}\n"; } //return isNested ? "TabularNC" : "TabularC"; } diff --git a/src/latexgen.cpp b/src/latexgen.cpp index 9b07fe6..7d72974 100644 --- a/src/latexgen.cpp +++ b/src/latexgen.cpp @@ -38,6 +38,7 @@ #include "filename.h" #include "resourcemgr.h" +static bool DoxyCodeOpen = FALSE; //------------------------------- LatexCodeGenerator::LatexCodeGenerator(FTextStream &t,const QCString &relPath,const QCString &sourceFileName) @@ -77,8 +78,8 @@ void LatexCodeGenerator::codify(const char *str) //char cs[5]; int spacesToNextTabStop; static int tabSize = Config_getInt(TAB_SIZE); - const int maxLineLen = 108; - QCString result(4*maxLineLen+1); // worst case for 1 line of 4-byte chars + static char *result = NULL; + static int lresult = 0; int i; while ((c=*p)) { @@ -86,9 +87,17 @@ void LatexCodeGenerator::codify(const char *str) { case 0x0c: p++; // remove ^L break; + case ' ': m_t <<" "; + m_col++; + p++; + break; + case '^': m_t <<"\\string^"; + m_col++; + p++; + break; case '\t': spacesToNextTabStop = tabSize - (m_col%tabSize); - m_t << Doxygen::spaces.left(spacesToNextTabStop); + for (i = 0; i < spacesToNextTabStop; i++) m_t <<" "; m_col+=spacesToNextTabStop; p++; break; @@ -100,6 +109,11 @@ void LatexCodeGenerator::codify(const char *str) #undef COPYCHAR // helper macro to copy a single utf8 character, dealing with multibyte chars. #define COPYCHAR() do { \ + if (lresult < (i + 5)) \ + { \ + lresult += 512; \ + result = (char *)realloc(result, lresult); \ + } \ result[i++]=c; p++; \ if (c<0) /* multibyte utf-8 character */ \ { \ @@ -116,30 +130,16 @@ void LatexCodeGenerator::codify(const char *str) result[i++]=*p++; \ } \ } \ - m_col++; \ + m_col++; \ } while(0) - // gather characters until we find whitespace or are at - // the end of a line + // gather characters until we find whitespace or another special character COPYCHAR(); - if (m_col>=maxLineLen) // force line break - { - m_t << "\n "; - m_col=0; - } - else // copy more characters + while ((c=*p) && + c!=0x0c && c!='\t' && c!='\n' && c!=' ' && c!='^' + ) { - while (m_col<maxLineLen && (c=*p) && - c!=0x0c && c!='\t' && c!='\n' && c!=' ' - ) - { - COPYCHAR(); - } - if (m_col>=maxLineLen) // force line break - { - m_t << "\n "; - m_col=0; - } + COPYCHAR(); } result[i]=0; // add terminator //if (m_prettyCode) @@ -190,6 +190,11 @@ void LatexCodeGenerator::writeLineNumber(const char *ref,const char *fileName,co { static bool usePDFLatex = Config_getBool(USE_PDFLATEX); static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS); + if (!DoxyCodeOpen) + { + m_t << "\\DoxyCodeLine{"; + DoxyCodeOpen = TRUE; + } if (m_prettyCode) { QCString lineNumber; @@ -223,10 +228,20 @@ void LatexCodeGenerator::writeLineNumber(const char *ref,const char *fileName,co void LatexCodeGenerator::startCodeLine(bool) { m_col=0; + if (!DoxyCodeOpen) + { + m_t << "\\DoxyCodeLine{"; + DoxyCodeOpen = TRUE; + } } void LatexCodeGenerator::endCodeLine() { + if (DoxyCodeOpen) + { + m_t << "}"; + DoxyCodeOpen = FALSE; + } codify("\n"); } @@ -472,8 +487,7 @@ static void writeDefaultHeaderPart1(FTextStream &t) t << "% Packages required by doxygen\n" "\\usepackage{fixltx2e}\n" // for \textsubscript "\\usepackage{calc}\n" - "\\usepackage{doxygen}\n" - "\\usepackage[export]{adjustbox} % also loads graphicx\n"; + "\\usepackage{doxygen}\n"; QStrList extraLatexStyle = Config_getList(LATEX_EXTRA_STYLESHEET); for (uint i=0; i<extraLatexStyle.count(); ++i) { @@ -503,7 +517,6 @@ static void writeDefaultHeaderPart1(FTextStream &t) "\\PassOptionsToPackage{warn}{textcomp}\n" "\\usepackage{textcomp}\n" "\\usepackage[nointegrals]{wasysym}\n" - "\\usepackage[table]{xcolor}\n" "\n"; // Language support @@ -625,13 +638,42 @@ static void writeDefaultHeaderPart1(FTextStream &t) bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS); if (pdfHyperlinks) { + unsigned char minus[4]; // Superscript minus + char *pminus = (char *)minus; + unsigned char sup2[3]; // Superscript two + char *psup2 = (char *)sup2; + unsigned char sup3[3]; + char *psup3 = (char *)sup3; // Superscript three + minus[0]= 0xE2; + minus[1]= 0x81; + minus[2]= 0xBB; + minus[3]= 0; + sup2[0]= 0xC2; + sup2[1]= 0xB2; + sup2[2]= 0; + sup3[0]= 0xC2; + sup3[1]= 0xB3; + sup3[2]= 0; + t << "% Hyperlinks (required, but should be loaded last)\n" - "\\usepackage{ifpdf}\n" "\\ifpdf\n" " \\usepackage[pdftex,pagebackref=true]{hyperref}\n" "\\else\n" " \\usepackage[ps2pdf,pagebackref=true]{hyperref}\n" "\\fi\n" + "\\ifpdf\n" + " \\DeclareUnicodeCharacter{207B}{${}^{-}$}% Superscript minus\n" + " \\DeclareUnicodeCharacter{C2B2}{${}^{2}$}% Superscript two\n" + " \\DeclareUnicodeCharacter{C2B3}{${}^{3}$}% Superscript three\n" + "\\else\n" + " \\catcode`\\" << pminus << "=13% Superscript minus\n" + " \\def" << pminus << "{${}^{-}$}\n" + " \\catcode`\\" << psup2 << "=13% Superscript two\n" + " \\def" << psup2 << "{${}^{2}$}\n" + " \\catcode`\\"<<psup3<<"=13% Superscript three\n" + " \\def"<<psup3<<"{${}^{3}$}\n" + "\\fi\n" + "\n" "\\hypersetup{%\n" " colorlinks=true,%\n" " linkcolor=blue,%\n" |