Skip to content

Commit a153ed0

Browse files
committed
issue doxygen#11590 Invalid LaTeX caused by unclosed markdown codeblocks. No warnings provided
1 parent 871d803 commit a153ed0

File tree

5 files changed

+28
-2
lines changed

5 files changed

+28
-2
lines changed

src/docbookgen.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,11 @@ DB_GEN_C1(*m_t)
308308
void DocbookCodeGenerator::endCodeFragment(const QCString &)
309309
{
310310
DB_GEN_C1(*m_t)
311+
bool wasHidden = m_hide;
312+
m_hide = false;
311313
//endCodeLine checks is there is still an open code line, if so closes it.
312314
endCodeLine();
315+
m_hide = wasHidden;
313316

314317
*m_t << "</programlisting>";
315318
}

src/htmlgen.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ void HtmlCodeGenerator::writeLineNumber(const QCString &ref,const QCString &file
842842
qsnprintf(lineNumber,maxLineNrStr,"%5d",l);
843843
qsnprintf(lineAnchor,maxLineNrStr,"l%05d",l);
844844

845+
//printf("writeLineNumber open=%d\n",m_lineOpen);
845846
if (!m_lineOpen)
846847
{
847848
*m_t << "<div class=\"line\">";
@@ -988,6 +989,7 @@ void HtmlCodeGenerator::writeTooltip(const QCString &id, const DocLinkInfo &docI
988989

989990
void HtmlCodeGenerator::startCodeLine(int)
990991
{
992+
//printf("startCodeLine open=%d\n",m_lineOpen);
991993
m_col=0;
992994
if (m_hide) return;
993995
if (!m_lineOpen)
@@ -999,6 +1001,7 @@ void HtmlCodeGenerator::startCodeLine(int)
9991001

10001002
void HtmlCodeGenerator::endCodeLine()
10011003
{
1004+
//printf("endCodeLine hide=%d open=%d\n",m_hide,m_lineOpen);
10021005
if (m_hide) return;
10031006
if (m_col == 0)
10041007
{
@@ -1037,14 +1040,19 @@ void HtmlCodeGenerator::startCodeFragment(const QCString &)
10371040

10381041
void HtmlCodeGenerator::endCodeFragment(const QCString &)
10391042
{
1043+
//printf("endCodeFragment hide=%d open=%d\n",m_hide,m_lineOpen);
1044+
bool wasHidden = m_hide;
1045+
m_hide = false;
10401046
//endCodeLine checks is there is still an open code line, if so closes it.
10411047
endCodeLine();
1048+
m_hide = wasHidden;
10421049

10431050
*m_t << "</div><!-- fragment -->";
10441051
}
10451052

10461053
void HtmlCodeGenerator::startFold(int lineNr,const QCString &startMarker,const QCString &endMarker)
10471054
{
1055+
//printf("startFold open=%d\n",m_lineOpen);
10481056
if (m_lineOpen) // if we have a hidden comment in a code fold, we need to end the line
10491057
{
10501058
*m_t << "</div>\n";
@@ -1065,6 +1073,7 @@ void HtmlCodeGenerator::startFold(int lineNr,const QCString &startMarker,const Q
10651073

10661074
void HtmlCodeGenerator::_startOpenLine()
10671075
{
1076+
//printf("_startOpenLine open=%d\n",m_lineOpen);
10681077
*m_t << "<div class=\"line\">";
10691078
bool wasHidden=m_hide;
10701079
m_hide = false;
@@ -1079,6 +1088,7 @@ void HtmlCodeGenerator::_startOpenLine()
10791088

10801089
void HtmlCodeGenerator::endFold()
10811090
{
1091+
//printf("endFold open=%d\n",m_lineOpen);
10821092
if (m_lineOpen) // if we have a hidden comment in a code fold, we need to end the line
10831093
{
10841094
*m_t << "</div>\n";

src/latexgen.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ void LatexCodeGenerator::startCodeFragment(const QCString &style)
308308
void LatexCodeGenerator::endCodeFragment(const QCString &style)
309309
{
310310
//endCodeLine checks is there is still an open code line, if so closes it.
311+
bool wasHidden = m_hide;
312+
m_hide = false;
311313
endCodeLine();
314+
m_hide = wasHidden;
312315

313316
*m_t << "\\end{" << style << "}\n";
314317
}

src/rtfgen.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,10 @@ void RTFCodeGenerator::startCodeFragment(const QCString &)
224224

225225
void RTFCodeGenerator::endCodeFragment(const QCString &)
226226
{
227+
bool wasHidden = m_hide;
228+
m_hide = false;
227229
endCodeLine();
230+
m_hide = wasHidden;
228231

229232
DBG_RTF(*m_t << "{\\comment (endCodeFragment) }\n")
230233
*m_t << "}\n";

src/scanner.l

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7324,14 +7324,21 @@ NONLopt [^\n]*
73247324
}
73257325
}
73267326
<DocCopyBlock>{CCS}|{CCE}|{CPPC} {
7327-
if (yytext[1]=='*')
7327+
if (yytext[1]=='*') // start comment
73287328
{
73297329
yyextra->nestedComment++;
73307330
}
7331-
else if (yytext[0]=='*' && yyextra->nestedComment>0)
7331+
else if (yytext[0]=='*' && yyextra->nestedComment>0) // end comment
73327332
{
73337333
yyextra->nestedComment--;
73347334
}
7335+
else if (yytext[0]=='*' && yyextra->nestedComment==0) // end comment without start
7336+
{
7337+
warn(yyextra->fileName,yyextra->yyLineNr,
7338+
"Found end of C comment inside a '{}' block without matching start of the comment!"
7339+
" Maybe the end marker for the block is missing?",
7340+
yyextra->docBlockName);
7341+
}
73357342
yyextra->docBlock << yytext;
73367343
}
73377344
<DocCopyBlock>\n { // newline

0 commit comments

Comments
 (0)