@@ -418,6 +418,9 @@ struct commentscanYY_state
418
418
bool markdownSupport = TRUE ;
419
419
420
420
QCString raiseWarning;
421
+
422
+ QCString HtmlAnchorStr;
423
+ bool HtmlAnchor = false ;
421
424
};
422
425
423
426
@@ -486,6 +489,8 @@ DETAILEDHTML {CENTER}|{DIV}|{PRE}|{UL}|{TABLE}|{OL}|{DL}|{P}|[Hh][1-6]|{IMG}|{HR
486
489
DETAILEDHTMLOPT {CODE}
487
490
SUMMARY [sS ][uU][mM ][mM ][aA][rR][yY]
488
491
REMARKS [rR][eE][mM ][aA][rR][kK ][sS ]
492
+ AHTML [aA]{BN}*
493
+ ANCHTML ([iI][dD]|[nN][aA][mM ][eE])"="(" \" " {LABELID}" \" " |" '" {LABELID}" '" |{LABELID})
489
494
BN [ \t\n\r]
490
495
BL [ \t\r]*"\n"
491
496
B [ \t]
@@ -564,6 +569,7 @@ STopt [^\n@\\]*
564
569
%x ReadFormulaLong
565
570
%x AnchorLabel
566
571
%x HtmlComment
572
+ %x HtmlA
567
573
%x SkipLang
568
574
%x CiteLabel
569
575
%x CopyDoc
@@ -628,6 +634,65 @@ STopt [^\n@\\]*
628
634
if (yyextra->HTMLDetails ) yyextra->HTMLDetails --;
629
635
addOutput (yyscanner,yytext);
630
636
}
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
+ }
631
696
<Comment >" <" {SUMMARY }" >" { // start of a .NET XML style brief description
632
697
if (!yyextra->HTMLDetails ) setOutput (yyscanner,OutputBrief);
633
698
addOutput (yyscanner,yytext);
0 commit comments