Skip to content

Commit b3c28ea

Browse files
committed
issue #10935 \snippet{doc} tag in Doxygen v1.11 adds incorrect paragraph with a break before snippet text
1 parent 7b32bc3 commit b3c28ea

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

src/commentcnv.l

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,7 @@ SLASHopt [/]*
10701070
if (!parseIncludeOptions(yyscanner,std::string_view{yytext,static_cast<size_t>(yyleng)})) REJECT;
10711071
yyextra->includeCtx = YY_START;
10721072
yyextra->firstIncludeLine = true;
1073+
yyextra->insertCommentCol = yyextra->col;
10731074
if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
10741075
{
10751076
if (yyextra->includeCtx==ReadLine)
@@ -1078,12 +1079,14 @@ SLASHopt [/]*
10781079
}
10791080
yyextra->insertCppCommentMarker = yyextra->mlBrief;
10801081
}
1082+
//printf("insertCommentCol=%d\n",yyextra->insertCommentCol);
10811083
BEGIN(IncludeDoc);
10821084
}
10831085
<CComment,ReadLine,IncludeFile>[\\@]("snippet"{OPTS}|"snippetdoc"{OPTS}*) {
10841086
if (!parseIncludeOptions(yyscanner,std::string_view{yytext,static_cast<size_t>(yyleng)})) REJECT;
10851087
yyextra->includeCtx = YY_START;
10861088
yyextra->firstIncludeLine = true;
1089+
yyextra->insertCommentCol = yyextra->col;
10871090
if (!yyextra->insertCppCommentMarker && (yyextra->includeCtx==ReadLine || yyextra->includeCtx==IncludeFile))
10881091
{
10891092
if (yyextra->includeCtx==ReadLine)
@@ -1092,6 +1095,7 @@ SLASHopt [/]*
10921095
}
10931096
yyextra->insertCppCommentMarker = yyextra->mlBrief;
10941097
}
1098+
//printf("insertCommentCol=%d\n",yyextra->insertCommentCol);
10951099
BEGIN(SnippetDoc);
10961100
}
10971101
<IncludeDoc,SnippetDoc>{B}*
@@ -1623,7 +1627,7 @@ static void insertCommentStart(yyscan_t yyscanner)
16231627
//printf("insertCommentStart col=%d mlBrief=%d insertCppCommentMarker=%d\n",yyextra->insertCommentCol,yyextra->mlBrief,yyextra->insertCppCommentMarker);
16241628
if (yyextra->insertCommentCol>=2)
16251629
{
1626-
int count=yyextra->insertCommentCol-2;
1630+
int count=yyextra->insertCommentCol;
16271631
std::string marker;
16281632
if (yyextra->lang==SrcLangExt::Python) // need to insert #
16291633
{
@@ -1633,6 +1637,10 @@ static void insertCommentStart(yyscan_t yyscanner)
16331637
{
16341638
marker="!! ";
16351639
}
1640+
else if (yyextra->lang==SrcLangExt::Markdown)
1641+
{
1642+
marker=" ";
1643+
}
16361644
else if (yyextra->insertCppCommentMarker) // need to insert ///
16371645
{
16381646
count--;
@@ -1642,6 +1650,7 @@ static void insertCommentStart(yyscan_t yyscanner)
16421650
{
16431651
marker="* ";
16441652
}
1653+
count-=marker.length();
16451654
for (int i=0;i<count;i++)
16461655
{
16471656
copyToOutput(yyscanner," ");

src/commentscan.l

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -898,10 +898,10 @@ STopt [^\n@\\]*
898898
);
899899
yyextra->inInternalDocs = FALSE;
900900
}
901-
<Comment>{B}*"\\ilinebr"{B}* { // preserve spacing around \\ilinebr
901+
<Comment>{B}*"\\ilinebr "{B}* { // preserve spacing around \\ilinebr
902902
addOutput(yyscanner,yytext);
903903
}
904-
<Comment>(\n|\\ilinebr)/({B}*(\n|{IFILELINE}?\\ilinebr))+ { // at least one blank line (or blank line command)
904+
<Comment>(\n|"\\ilinebr ")/({B}*(\n|{IFILELINE}?"\\ilinebr "))+ { // at least one blank line (or blank line command)
905905
if (yyextra->inContext==OutputBrief)
906906
{
907907
endBrief(yyscanner);
@@ -1103,7 +1103,7 @@ STopt [^\n@\\]*
11031103
<Comment>".."[\.]?/[^ \t\n] { // internal ellipsis
11041104
addOutput(yyscanner,yytext);
11051105
}
1106-
<Comment>(\n|\\ilinebr)({B}*(\n|\\ilinebr))+ { // at least one blank line (or blank line command)
1106+
<Comment>(\n|"\\ilinebr ")({B}*(\n|"\\ilinebr "))+ { // at least one blank line (or blank line command)
11071107
if (yyextra->inContext==OutputXRef)
11081108
{
11091109
// see bug 613024, we need to put the newlines after ending the XRef section.
@@ -1112,7 +1112,7 @@ STopt [^\n@\\]*
11121112
for (i=0;i<(yy_size_t)yyleng;)
11131113
{
11141114
if (yytext[i]=='\n') addOutput(yyscanner,'\n'),i++;
1115-
else if (strcmp(yytext+i,"\\ilinebr")==0) addOutput(yyscanner," \\ilinebr"),i+=8;
1115+
else if (strncmp(yytext+i,"\\ilinebr ",9)==0) addOutput(yyscanner,"\\ilinebr "),i+=9;
11161116
else i++;
11171117
}
11181118
}
@@ -1122,7 +1122,7 @@ STopt [^\n@\\]*
11221122
for (i=0;i<(yy_size_t)yyleng;)
11231123
{
11241124
if (yytext[i]=='\n') addOutput(yyscanner,'\n'),i++;
1125-
else if (strcmp(yytext+i,"\\ilinebr")==0) addOutput(yyscanner," \\ilinebr"),i+=8;
1125+
else if (strncmp(yytext+i,"\\ilinebr ",9)==0) addOutput(yyscanner,"\\ilinebr "),i+=9;
11261126
else i++;
11271127
}
11281128
setOutput(yyscanner,OutputDoc);
@@ -4265,7 +4265,7 @@ static void addCite(yyscan_t yyscanner)
42654265
}
42664266

42674267
//-----------------------------------------------------------------------------
4268-
static const reg::Ex nonBrief_re(R"( *[\\@]ifile \"[^\"]*\" [\\@]iline (\d+) [\\@]ilinebr( *\n*))");
4268+
static const reg::Ex nonBrief_re(R"( *[\\@]ifile \"[^\"]*\" [\\@]iline (\d+) [\\@]ilinebr ([ \n]*))");
42694269

42704270
// strip trailing whitespace (excluding newlines) from string s
42714271
static void stripTrailingWhiteSpace(QCString &s)
@@ -4412,7 +4412,7 @@ static inline void setOutput(yyscan_t yyscanner,OutputContext ctx)
44124412
{
44134413
if (match[2].str()[i] == '\n') cnt++;
44144414
}
4415-
if (cnt)
4415+
if (cnt>0)
44164416
{
44174417
yyextra->current->brief = yyextra->current->brief.left(yyextra->current->brief.length()-cnt);
44184418
// set warning line correct

src/doctokenizer.l

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ SHOWDATE ([0-9]{4}"-"[0-9]{1,2}"-"[0-9]{1,2})?({WS}*[0-9]{1,2}":"[0-9]{1,2}(":"[
796796
}
797797
lineCount(yytext,yyleng);
798798
}
799+
<St_Para,St_Param>({BLANK}*(\n|"\\ilinebr"))+{BLANK}*(\n|"\\ilinebr"){BLANK}*/" \\ifile" | // we don't want to count the space before \ifile
799800
<St_Para,St_Param>({BLANK}*(\n|"\\ilinebr"))+{BLANK}*(\n|"\\ilinebr"){BLANK}* {
800801
lineCount(yytext,yyleng);
801802
if (yyextra->insidePre)
@@ -808,6 +809,7 @@ SHOWDATE ([0-9]{4}"-"[0-9]{1,2}"-"[0-9]{1,2})?({WS}*[0-9]{1,2}":"[0-9]{1,2}(":"[
808809
yyextra->token.indent=computeIndent(yytext,yyleng);
809810
int i;
810811
// put back the indentation (needed for list items)
812+
//printf("token.indent=%d\n",yyextra->token.indent);
811813
for (i=0;i<yyextra->token.indent;i++)
812814
{
813815
unput(' ');

0 commit comments

Comments
 (0)