Skip to content

Commit 8bce564

Browse files
committed
Prevent list items in section titles
When having the, a bit unusual, construct: ``` \section ThePage_subsection 1. The First Sub-Section ``` and we use the reference like: ``` \ref ThePage_subsection ``` we get in the LaTeX generation the error: ``` ! LaTeX Error: Something's wrong--perhaps a missing \item. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.4 \end{DoxyEnumerate}}} ``` due to the construct: ``` Check it here \mbox{\hyperlink{_the_page_ThePage_subsection}{ \begin{DoxyEnumerate} \item The First Sub-\/\+Section \end{DoxyEnumerate}}} ``` This is all because of the `1.` i.e. a list item in the section title. (all based on the discussion in: Doxygen regression when creating PDF output 1.9.6 -> master of 10.01.2023 #9781 )
1 parent 052395f commit 8bce564

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/docparser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ int DocParser::internalValidatingParseDoc(DocNodeVariant *parent,DocNodeList &ch
15991599

16001600
if (doc.isEmpty()) return retval;
16011601

1602-
tokenizer.init(doc.data(),context.fileName,context.markdownSupport);
1602+
tokenizer.init(doc.data(),context.fileName,context.markdownSupport,context.insideHtmlLink);
16031603

16041604
// first parse any number of paragraphs
16051605
bool isFirst=TRUE;

src/doctokenizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class DocTokenizer
137137
// operations on the scanner
138138
void findSections(const QCString &input,const Definition *d,
139139
const QCString &fileName);
140-
void init(const char *input,const QCString &fileName,bool markdownSupport);
140+
void init(const char *input,const QCString &fileName,bool markdownSupport, bool insideHtmlLink = false);
141141
void cleanup();
142142
void pushContext();
143143
bool popContext();

src/doctokenizer.l

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ struct doctokenizerYY_state
8080
QCString fileName;
8181
bool insidePre = false;
8282
int sharpCount=0;
83-
bool markdownSupport=TRUE;
83+
bool markdownSupport=true;
84+
bool insideHtmlLink=false;
8485

8586
// context for section finding phase
8687
const Definition *definition = 0;
@@ -408,6 +409,7 @@ SHOWDATE ([0-9]{4}"-"[0-9]{1,2}"-"[0-9]{1,2})?({WS}*[0-9]{1,2}":"[0-9]{1,2}(":"[
408409
%%
409410
<St_Para>\r /* skip carriage return */
410411
<St_Para>^{LISTITEM} { /* list item */
412+
if (yyextra->insideHtmlLink) REJECT;
411413
lineCount(yytext,yyleng);
412414
QCString text(yytext);
413415
uint32_t dashPos = static_cast<uint32_t>(text.findRev('-'));
@@ -418,7 +420,7 @@ SHOWDATE ([0-9]{4}"-"[0-9]{1,2}"-"[0-9]{1,2})?({WS}*[0-9]{1,2}":"[0-9]{1,2}(":"[
418420
return TK_LISTITEM;
419421
}
420422
<St_Para>^{MLISTITEM} { /* list item */
421-
if (!yyextra->markdownSupport || yyextra->insidePre)
423+
if (yyextra->insideHtmlLink || !yyextra->markdownSupport || yyextra->insidePre)
422424
{
423425
REJECT;
424426
}
@@ -438,7 +440,7 @@ SHOWDATE ([0-9]{4}"-"[0-9]{1,2}"-"[0-9]{1,2})?({WS}*[0-9]{1,2}":"[0-9]{1,2}(":"[
438440
}
439441
}
440442
<St_Para>^{OLISTITEM} { /* numbered list item */
441-
if (!yyextra->markdownSupport || yyextra->insidePre)
443+
if (yyextra->insideHtmlLink || !yyextra->markdownSupport || yyextra->insidePre)
442444
{
443445
REJECT;
444446
}
@@ -463,6 +465,7 @@ SHOWDATE ([0-9]{4}"-"[0-9]{1,2}"-"[0-9]{1,2})?({WS}*[0-9]{1,2}":"[0-9]{1,2}(":"[
463465
}
464466
}
465467
<St_Para>{BLANK}*(\n|"\\ilinebr"){LISTITEM} { /* list item on next line */
468+
if (yyextra->insideHtmlLink) REJECT;
466469
lineCount(yytext,yyleng);
467470
QCString text=extractPartAfterNewLine(QCString(yytext));
468471
uint32_t dashPos = static_cast<uint32_t>(text.findRev('-'));
@@ -473,7 +476,7 @@ SHOWDATE ([0-9]{4}"-"[0-9]{1,2}"-"[0-9]{1,2})?({WS}*[0-9]{1,2}":"[0-9]{1,2}(":"[
473476
return TK_LISTITEM;
474477
}
475478
<St_Para>{BLANK}*(\n|"\\ilinebr"){MLISTITEM} { /* list item on next line */
476-
if (!yyextra->markdownSupport || yyextra->insidePre)
479+
if (yyextra->insideHtmlLink || !yyextra->markdownSupport || yyextra->insidePre)
477480
{
478481
REJECT;
479482
}
@@ -493,7 +496,7 @@ SHOWDATE ([0-9]{4}"-"[0-9]{1,2}"-"[0-9]{1,2})?({WS}*[0-9]{1,2}":"[0-9]{1,2}(":"[
493496
}
494497
}
495498
<St_Para>{BLANK}*(\n|"\\ilinebr"){OLISTITEM} { /* list item on next line */
496-
if (!yyextra->markdownSupport || yyextra->insidePre)
499+
if (yyextra->insideHtmlLink || !yyextra->markdownSupport || yyextra->insidePre)
497500
{
498501
REJECT;
499502
}
@@ -519,12 +522,14 @@ SHOWDATE ([0-9]{4}"-"[0-9]{1,2}"-"[0-9]{1,2})?({WS}*[0-9]{1,2}":"[0-9]{1,2}(":"[
519522
}
520523
}
521524
<St_Para>^{ENDLIST} { /* end list */
525+
if (yyextra->insideHtmlLink) REJECT;
522526
lineCount(yytext,yyleng);
523527
size_t dotPos = static_cast<size_t>(QCString(yytext).findRev('.'));
524528
yyextra->token->indent = computeIndent(yytext,dotPos);
525529
return TK_ENDLIST;
526530
}
527531
<St_Para>{BLANK}*(\n|"\\ilinebr"){ENDLIST} { /* end list on next line */
532+
if (yyextra->insideHtmlLink) REJECT;
528533
lineCount(yytext,yyleng);
529534
QCString text=extractPartAfterNewLine(QCString(yytext));
530535
size_t dotPos = static_cast<size_t>(text.findRev('.'));
@@ -1758,7 +1763,7 @@ void DocTokenizer::findSections(const QCString &input,const Definition *d,
17581763
doctokenizerYYlex(yyscanner);
17591764
}
17601765
1761-
void DocTokenizer::init(const char *input,const QCString &fileName,bool markdownSupport)
1766+
void DocTokenizer::init(const char *input,const QCString &fileName,bool markdownSupport, bool insideHtmlLink)
17621767
{
17631768
yyscan_t yyscanner = p->yyscanner;
17641769
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
@@ -1768,6 +1773,7 @@ void DocTokenizer::init(const char *input,const QCString &fileName,bool markdown
17681773
yyextra->fileName = fileName;
17691774
yyextra->insidePre = FALSE;
17701775
yyextra->markdownSupport = markdownSupport;
1776+
yyextra->insideHtmlLink = insideHtmlLink;
17711777
BEGIN(St_Para);
17721778
}
17731779

0 commit comments

Comments
 (0)