Skip to content

Commit 67d6279

Browse files
committed
Support link / endlink command in section title
There was no handling for the `\link` / `\endlink` commands in section titles yet and this resulted in warnings like: ``` .../all.md:247: warning: unexpected command endlink pg_all:247: warning: unexpected command endlink ``` (see example with #10595)
1 parent cf77bce commit 67d6279

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/commentscan.l

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ static const std::map< std::string, DocCmdMap > docCmdMap =
386386
{ "endmanonly", { 0, CommandSpacing::Invisible, SectionHandling::Escape }},
387387
{ "endrtfonly", { 0, CommandSpacing::Invisible, SectionHandling::Escape }},
388388
{ "endxmlonly", { 0, CommandSpacing::Invisible, SectionHandling::Escape }},
389+
{ "link", { 0, CommandSpacing::Invisible, SectionHandling::Replace }},
390+
{ "endlink", { 0, CommandSpacing::Invisible, SectionHandling::Escape }},
389391
{ "ifile", { &handleIFile, CommandSpacing::Invisible, SectionHandling::Replace }},
390392
{ "iline", { &handleILine, CommandSpacing::Invisible, SectionHandling::Replace }}
391393
};
@@ -674,6 +676,7 @@ STopt [^\n@\\]*
674676
%x RaiseWarning
675677
%x RaiseWarningSection
676678
%x Qualifier
679+
%x LinkSection
677680
%x IFile
678681
%x IFileSection
679682
%x ILine
@@ -1750,6 +1753,31 @@ STopt [^\n@\\]*
17501753
}
17511754
}
17521755

1756+
<LinkSection>[^\\@\n]* {
1757+
yyextra->sectionTitle+=yytext;
1758+
}
1759+
<LinkSection>{CMD}{CMD} {
1760+
yyextra->sectionTitle+=yytext;
1761+
}
1762+
<LinkSection>{DOCNL} {
1763+
addOutput(yyscanner,yytext);
1764+
if (*yytext == '\n') yyextra->lineNr++;
1765+
yyextra->sectionTitle+=yytext;
1766+
}
1767+
<LinkSection>{CMD}"endlink" {
1768+
yyextra->sectionTitle+=yytext;
1769+
BEGIN(SectionTitle);
1770+
}
1771+
<LinkSection>. {
1772+
yyextra->sectionTitle+=yytext;
1773+
}
1774+
<LinkSection><<EOF>> {
1775+
warn(yyextra->fileName,yyextra->lineNr,
1776+
"reached end of comment while inside a '\\%s' command, missing '\\%s' command",
1777+
"link","endlink"
1778+
);
1779+
yyterminate();
1780+
}
17531781
/* ----- handle arguments of the relates(also)/addindex commands ----- */
17541782

17551783
<LineParam>{CMD}{CMD} { // escaped command
@@ -1952,6 +1980,11 @@ STopt [^\n@\\]*
19521980
addOutput(yyscanner,yytext);
19531981
BEGIN(IFileSection);
19541982
}
1983+
else if (cmdName == "link")
1984+
{
1985+
yyextra->sectionTitle+=yytext;
1986+
BEGIN(LinkSection);
1987+
}
19551988
else
19561989
{
19571990
yyextra->sectionTitle+=yytext;

0 commit comments

Comments
 (0)