@@ -176,6 +176,7 @@ MAILADDR ("mailto:")?[a-z_A-Z0-9\x80-\xff.+-]+"@"[a-z_A-Z0-9\x80-\xff-]+("."[a
176176%x SkipString
177177%x SkipVerbString
178178%x SkipChar
179+ %x SkipLang
179180%x SComment
180181%x CComment
181182%x CNComment
@@ -982,10 +983,44 @@ SLASHopt [/]*
982983 BEGIN(SkipString);
983984 }
984985 */
986+ <CComment,CNComment>{CMD}" ~" [a-z_A-Z-]* { // language switch command
987+ if (yyextra->lang !=SrcLangExt::Markdown) REJECT;
988+ QCString langId = QCString (yytext).mid (2 );
989+ if (!langId.isEmpty () &&
990+ qstricmp (Config_getEnumAsString (OUTPUT_LANGUAGE),langId)!=0 )
991+ { // enable language specific section
992+ if (!Config_isAvailableEnum (OUTPUT_LANGUAGE,langId))
993+ {
994+ warn (yyextra->fileName ,yyextra->lineNr ,
995+ " non supported language '{}' specified in '{}'" ,langId,QCString (yytext).stripWhiteSpace ());
996+ }
997+ BEGIN (SkipLang);
998+ }
999+ }
9851000<CComment,CNComment>{CMD}{CMD} |
9861001<CComment,CNComment>. {
9871002 copyToOutput (yyscanner,yytext,yyleng);
9881003 }
1004+ <SkipLang>{CMD}" ~" [a-zA-Z-]* { /* language switch */
1005+ QCString langId (&yytext[2 ]);
1006+ if (!langId.isEmpty () && !Config_isAvailableEnum (OUTPUT_LANGUAGE,langId))
1007+ {
1008+ warn (yyextra->fileName ,yyextra->lineNr ,
1009+ " non supported language '{}' specified in '{}'" ,langId,QCString (yytext).stripWhiteSpace ());
1010+ }
1011+ else if (langId.isEmpty () ||
1012+ qstricmp (Config_getEnumAsString (OUTPUT_LANGUAGE),langId)==0 )
1013+ { // enable language specific section
1014+ BEGIN (CComment);
1015+ }
1016+ }
1017+ <SkipLang>[^*@\\\n]* { /* any character not a *, @, backslash or new line */
1018+ }
1019+ <SkipLang>\n { /* new line in language block, needed for keeping track of line numbers */
1020+ copyToOutput (yyscanner,yytext,yyleng);
1021+ }
1022+ <SkipLang>. { /* any other character */
1023+ }
9891024<SComment>^[ \t]*{CPPC}" /" {SLASHopt}/\n {
9901025 replaceComment (yyscanner,0 );
9911026 }
0 commit comments