Skip to content

Commit 91f35c6

Browse files
committed
Handling C# <code> parts
In the documentation it is stated in the "XML Commands" documentation: > `<code>` > Set one or more lines of source code or program output. > Note that this command behaves like `\code ... \endcode` > for C# code, but it behaves like the HTML equivalent > `<CODE>...</CODE>` for other languages. In fact the `<code>` in C# behaved for all languages like `<CODE>` i.e. from the "HTML Commands" documentation: > `<CODE> / </CODE>` > Starts and ends a piece of text displayed in a typewriter font. Note > that only for C# code, this command is equivalent to `\code` (see > `<code>`). This has been corrected. Note the C# `<code> cannot have attributes so a special rule was needed.
1 parent 15bf1f3 commit 91f35c6

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/commentscan.l

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ struct commentscanYY_state
469469
QCString anchorTitle;
470470
QCString htmlAnchorStr;
471471
bool htmlAnchor = false;
472+
bool CScode = false;
472473
};
473474

474475

@@ -529,12 +530,14 @@ IMG [iI][mM][gG]
529530
HR [hH][rR]
530531
PARA [pP][aA][rR][aA]
531532
CODE [cC][oO][dD][eE]
533+
ENDCODE "/"{CODE}
532534
CAPTION [cC][aA][pP][tT][iI][oO][nN]
533535
CENTER [cC][eE][nN][tT][eE][rR]
534536
DIV [dD][iI][vV]
535537
DETAILS [dD][eE][tT][aA][iI][lL][sS]
536538
DETAILEDHTML {CENTER}|{DIV}|{PRE}|{UL}|{TABLE}|{OL}|{DL}|{P}|[Hh][1-6]|{IMG}|{HR}|{PARA}
537539
DETAILEDHTMLOPT {CODE}
540+
DETAILEDHTMLOPTEND {ENDCODE}
538541
SUMMARY [sS][uU][mM][mM][aA][rR][yY]
539542
REMARKS [rR][eE][mM][aA][rR][kK][sS]
540543
AHTML [aA]{BN}*
@@ -668,7 +671,35 @@ STopt [^\n@\\]*
668671
// continue with the same input
669672
REJECT;
670673
}
671-
<Comment>"<"{DETAILEDHTMLOPT}{ATTR}">" { // HTML command that ends a brief description
674+
<Comment>"<"{DETAILEDHTMLOPT}">" { // HTML <code> command that ends a brief description
675+
// without attributes
676+
if (yyextra->current->lang==SrcLangExt_CSharp)
677+
{
678+
yyextra->CScode=true;
679+
setOutput(yyscanner,OutputDoc);
680+
addOutput(yyscanner,"@code{cs}");
681+
}
682+
else
683+
{
684+
// continue with the same input
685+
REJECT;
686+
}
687+
}
688+
<Comment>"<"{DETAILEDHTMLOPTEND}">" { // HTML command that ends a brief description
689+
if (yyextra->CScode)
690+
{
691+
addOutput(yyscanner,"@endcode");
692+
yyextra->CScode=false;
693+
}
694+
else
695+
{
696+
yyextra->CScode=false;
697+
// continue with the same input
698+
REJECT;
699+
}
700+
}
701+
<Comment>"<"{DETAILEDHTMLOPT}{ATTR}">" { // HTML <code> command that ends a brief description
702+
// with attributes, so cannot be CS.
672703
if (yyextra->current->lang==SrcLangExt_CSharp)
673704
{
674705
setOutput(yyscanner,OutputDoc);

0 commit comments

Comments
 (0)