Skip to content

Commit fec62a5

Browse files
committed
issue #9200 Doxygen cannot resolve link to HTML anchor page
Convert HTML type of anchors to doxygen type of anchors as long as this is possible (`{LABELID}`).
1 parent b2a018c commit fec62a5

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

src/commentscan.l

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ struct commentscanYY_state
418418
bool markdownSupport = TRUE;
419419

420420
QCString raiseWarning;
421+
422+
QCString HtmlAnchorStr;
423+
bool HtmlAnchor = false;
421424
};
422425

423426

@@ -486,6 +489,8 @@ DETAILEDHTML {CENTER}|{DIV}|{PRE}|{UL}|{TABLE}|{OL}|{DL}|{P}|[Hh][1-6]|{IMG}|{HR
486489
DETAILEDHTMLOPT {CODE}
487490
SUMMARY [sS][uU][mM][mM][aA][rR][yY]
488491
REMARKS [rR][eE][mM][aA][rR][kK][sS]
492+
AHTML [aA]{BN}*
493+
ANCHTML ([iI][dD]|[nN][aA][mM][eE])"="("\""{LABELID}"\""|"'"{LABELID}"'"|{LABELID})
489494
BN [ \t\n\r]
490495
BL [ \t\r]*"\n"
491496
B [ \t]
@@ -564,6 +569,7 @@ STopt [^\n@\\]*
564569
%x ReadFormulaLong
565570
%x AnchorLabel
566571
%x HtmlComment
572+
%x HtmlA
567573
%x SkipLang
568574
%x CiteLabel
569575
%x CopyDoc
@@ -628,6 +634,65 @@ STopt [^\n@\\]*
628634
if (yyextra->HTMLDetails) yyextra->HTMLDetails--;
629635
addOutput(yyscanner,yytext);
630636
}
637+
<Comment>"<"{AHTML} { // potential start of HTML anchor, see issue 9200
638+
yyextra->HtmlAnchorStr = yytext;
639+
yyextra->HtmlAnchor = false;
640+
BEGIN(HtmlA);
641+
}
642+
<HtmlA>{ANCHTML} { // only labels that can be converted to doxygen anchor
643+
yyextra->HtmlAnchorStr += yytext;
644+
QCString tag(yytext);
645+
int s=tag.find("=");
646+
char c=tag[s+1];
647+
QCString id;
648+
if (c=='\'' || c=='"') // valid start
649+
{
650+
int e=tag.find(c,s+2);
651+
if (e!=-1) // found matching end
652+
{
653+
id=tag.mid(s+2,e-s-2); // extract id
654+
addAnchor(yyscanner,id);
655+
}
656+
}
657+
else
658+
{
659+
id=tag.mid(s+1);
660+
addAnchor(yyscanner,id);
661+
}
662+
if (!id.isEmpty() && !yyextra->HtmlAnchor)
663+
{
664+
// only use first analogous to what is in docparser
665+
addOutput(yyscanner,"@anchor ");
666+
addOutput(yyscanner,id.data());
667+
addOutput(yyscanner," ");
668+
yyextra->HtmlAnchor = true;
669+
}
670+
}
671+
<HtmlA>("\""[^\n\"]*"\""|"'"[^\n']*"'") {
672+
yyextra->HtmlAnchorStr += yytext;
673+
}
674+
<HtmlA>">"|"/>" {
675+
if (!yyextra->HtmlAnchor)
676+
{
677+
addOutput(yyscanner,yyextra->HtmlAnchorStr);
678+
addOutput(yyscanner,yytext);
679+
}
680+
else
681+
{
682+
if (yyleng == 1) // to keep <a></a> pairs, otherwise single </a> present
683+
{
684+
addOutput(yyscanner,"<a>");
685+
}
686+
}
687+
BEGIN(Comment);
688+
}
689+
<HtmlA>{DOCNL} { // newline
690+
yyextra->HtmlAnchorStr += yytext;
691+
if (*yytext == '\n') yyextra->lineNr++;
692+
}
693+
<HtmlA>. { // catch-all for anything else
694+
yyextra->HtmlAnchorStr += yytext;
695+
}
631696
<Comment>"<"{SUMMARY}">" { // start of a .NET XML style brief description
632697
if (!yyextra->HTMLDetails) setOutput(yyscanner,OutputBrief);
633698
addOutput(yyscanner,yytext);

0 commit comments

Comments
 (0)