diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2019-06-22 10:16:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-22 10:16:25 (GMT) |
commit | 7684baadf970c3454702968a7464b7c0d190d9f8 (patch) | |
tree | 944021588edb8dce89167f4b2f7c481bcf0e13eb /src | |
parent | d3106415072cbab2dda9ba72d4fc31db13824c24 (diff) | |
parent | b81d5b4c799e1180f5570ab8c8626ff46f3aa84a (diff) | |
download | Doxygen-7684baadf970c3454702968a7464b7c0d190d9f8.zip Doxygen-7684baadf970c3454702968a7464b7c0d190d9f8.tar.gz Doxygen-7684baadf970c3454702968a7464b7c0d190d9f8.tar.bz2 |
Merge pull request #7063 from albert-github/feature/bug_html_endcodeline
Incorrect (X)HTML code when generating source code.
Diffstat (limited to 'src')
-rw-r--r-- | src/docbookgen.cpp | 10 | ||||
-rw-r--r-- | src/htmlgen.cpp | 35 | ||||
-rw-r--r-- | src/htmlgen.h | 4 | ||||
-rw-r--r-- | src/rtfgen.cpp | 21 | ||||
-rw-r--r-- | src/rtfgen.h | 6 |
5 files changed, 65 insertions, 11 deletions
diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp index c6bd1c0..7fe849a 100644 --- a/src/docbookgen.cpp +++ b/src/docbookgen.cpp @@ -185,7 +185,7 @@ void DocbookCodeGenerator::startCodeLine(bool) } void DocbookCodeGenerator::endCodeLine() { - m_t << endl; + if (m_insideCodeLine) m_t << endl; Docbook_DB(("(endCodeLine)\n")); m_lineNumber = -1; m_refId.resize(0); @@ -243,7 +243,7 @@ void DocbookCodeGenerator::addWord(const char *,bool) } void DocbookCodeGenerator::finish() { - if (m_insideCodeLine) endCodeLine(); + endCodeLine(); } void DocbookCodeGenerator::startCodeFragment() { @@ -251,6 +251,9 @@ void DocbookCodeGenerator::startCodeFragment() } void DocbookCodeGenerator::endCodeFragment() { + //endCodeLine checks is there is still an open code line, if so closes it. + endCodeLine(); + m_t << "</computeroutput></literallayout>" << endl; } @@ -1007,6 +1010,9 @@ DB_GEN_C void DocbookGenerator::endCodeFragment() { DB_GEN_C + //endCodeLine checks is there is still an open code line, if so closes it. + endCodeLine(); + t << "</programlisting>"; } void DocbookGenerator::startMemberTemplateParams() diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp index d25dafc..b3abd09 100644 --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -57,6 +57,7 @@ static QCString g_header; static QCString g_footer; static QCString g_mathjax_code; +static bool DoxyCodeLineOpen = FALSE; // note: this is only active if DISABLE_INDEX=YES, if DISABLE_INDEX is disabled, this // part will be rendered inside menu.js @@ -530,7 +531,12 @@ void HtmlCodeGenerator::writeLineNumber(const char *ref,const char *filename, qsnprintf(lineNumber,maxLineNrStr,"%5d",l); qsnprintf(lineAnchor,maxLineNrStr,"l%05d",l); - m_t << "<div class=\"line\">"; + if (!DoxyCodeLineOpen) + { + m_t << "<div class=\"line\">"; + DoxyCodeLineOpen = TRUE; + } + m_t << "<a name=\"" << lineAnchor << "\"></a><span class=\"lineno\">"; if (filename) { @@ -661,12 +667,16 @@ void HtmlCodeGenerator::writeTooltip(const char *id, const DocLinkInfo &docInfo, } -void HtmlCodeGenerator::startCodeLine(bool hasLineNumbers) +void HtmlCodeGenerator::startCodeLine(bool) { if (m_streamSet) { - if (!hasLineNumbers) m_t << "<div class=\"line\">"; m_col=0; + if (!DoxyCodeLineOpen) + { + m_t << "<div class=\"line\">"; + DoxyCodeLineOpen = TRUE; + } } } @@ -679,7 +689,11 @@ void HtmlCodeGenerator::endCodeLine() m_t << " "; m_col++; } - m_t << "</div>"; + if (DoxyCodeLineOpen) + { + m_t << "</div>\n"; + DoxyCodeLineOpen = FALSE; + } } } @@ -2640,6 +2654,19 @@ void HtmlGenerator::endConstraintList() t << "</div>" << endl; } +void HtmlGenerator::startCodeFragment() +{ + t << PREFRAG_START; +} + +void HtmlGenerator::endCodeFragment() +{ + //endCodeLine checks is there is still an open code line, if so closes it. + endCodeLine(); + + t << PREFRAG_END; +} + void HtmlGenerator::lineBreak(const char *style) { if (style) diff --git a/src/htmlgen.h b/src/htmlgen.h index ebecc81..2db5b74 100644 --- a/src/htmlgen.h +++ b/src/htmlgen.h @@ -212,8 +212,8 @@ class HtmlGenerator : public OutputGenerator void writeRuler() { t << "<hr/>"; } void writeAnchor(const char *,const char *name) { t << "<a name=\"" << name <<"\" id=\"" << name << "\"></a>"; } - void startCodeFragment() { t << PREFRAG_START; } - void endCodeFragment() { t << PREFRAG_END; } + void startCodeFragment(); + void endCodeFragment(); void startEmphasis() { t << "<em>"; } void endEmphasis() { t << "</em>"; } void startBold() { t << "<b>"; } diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp index 8139784..2f24ca7 100644 --- a/src/rtfgen.cpp +++ b/src/rtfgen.cpp @@ -48,6 +48,8 @@ #include "filename.h" #include "namespacedef.h" +static bool DoxyCodeLineOpen = FALSE; + //#define DBG_RTF(x) x; #define DBG_RTF(x) @@ -1952,6 +1954,9 @@ void RTFGenerator::endCodeFragment() //styleStack.pop(); //printf("RTFGenerator::endCodeFrament() top=%s\n",styleStack.top()); //t << rtf_Style_Reset << styleStack.top() << endl; + //endCodeLine checks is there is still an open code line, if so closes it. + endCodeLine(); + DBG_RTF(t << "{\\comment (endCodeFragment) }" << endl) t << "}" << endl; m_omitParagraph = TRUE; @@ -3041,6 +3046,22 @@ void RTFGenerator::endInlineMemberDoc() t << "\\cell }{\\row }" << endl; } +void RTFGenerator::writeLineNumber(const char *,const char *,const char *,int l) +{ + DoxyCodeLineOpen = TRUE; + t << QString("%1").arg(l,5) << " "; +} +void RTFGenerator::startCodeLine(bool) +{ + DoxyCodeLineOpen = TRUE; + col=0; +} +void RTFGenerator::endCodeLine() +{ + if (DoxyCodeLineOpen) lineBreak(); + DoxyCodeLineOpen = FALSE; +} + void RTFGenerator::startLabels() { } diff --git a/src/rtfgen.h b/src/rtfgen.h index fe3e753..b5f06f0 100644 --- a/src/rtfgen.h +++ b/src/rtfgen.h @@ -127,9 +127,9 @@ class RTFGenerator : public OutputGenerator void writeAnchor(const char *fileName,const char *name); void startCodeFragment(); void endCodeFragment(); - void writeLineNumber(const char *,const char *,const char *,int l) { t << QString("%1").arg(l,5) << " "; } - void startCodeLine(bool) { col=0; } - void endCodeLine() { lineBreak(); } + void writeLineNumber(const char *,const char *,const char *,int l); + void startCodeLine(bool); + void endCodeLine(); void startEmphasis() { t << "{\\i "; } void endEmphasis() { t << "}"; } void startBold() { t << "{\\b "; } |