Skip to content

Commit 852adf3

Browse files
committed
Support for Plus sign code fence directives - GitHub flavor
- Support plus sign (for e.g. `C++`) in file extension of fenced code block - small spelling correction
1 parent ee1bb44 commit 852adf3

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

doc/markdown.dox

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,8 @@ which will produce:
453453
int func(int a,int b) { return a*b; }
454454
~~~~~~~~~~~~~~~
455455

456-
The dot is optional, the curly braces are optional when the that language name begins with a
457-
alphabetical character and further characters are alphanumerical characters.
456+
The dot is optional, the curly braces are optional when the that language name begins with an
457+
alphabetical character and further characters are alphanumerical characters or a plus sign.
458458

459459
Another way to denote fenced code blocks is to use 3 or more backticks (```):
460460

src/doctokenizer.l

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ BLANK [ \t\r]
180180
BLANKopt {BLANK}*
181181
ID [$a-z_A-Z\x80-\xFF][$a-z_A-Z0-9\x80-\xFF]*
182182
LABELID [a-z_A-Z\x80-\xFF][a-z_A-Z0-9\x80-\xFF\-]*
183+
CODEID [a-zA-Z][a-zA-Z0-9+]*
183184
PHPTYPE [?]?[\\:a-z_A-Z0-9\x80-\xFF\-]+
184185
CITESCHAR [a-z_A-Z0-9\x80-\xFF\-\?]
185186
CITEECHAR [a-z_A-Z0-9\x80-\xFF\-\+:\/\?]
@@ -736,13 +737,13 @@ SHOWDATE ([0-9]{4}"-"[0-9]{1,2}"-"[0-9]{1,2})?({WS}*[0-9]{1,2}":"[0-9]{1,2}(":"[
736737
return Token::make_TK_NEWPARA();
737738
}
738739
}
739-
<St_CodeOpt>{BLANK}*"{"(".")?{LABELID}"}" {
740+
<St_CodeOpt>{BLANK}*"{"(".")?{CODEID}"}" {
740741
yyextra->token.name = yytext;
741742
int i=yyextra->token.name.find('{'); /* } to keep vi happy */
742743
yyextra->token.name = yyextra->token.name.mid(i+1,yyextra->token.name.length()-i-2);
743744
BEGIN(St_Code);
744745
}
745-
<St_iCodeOpt>{BLANK}*"{"(".")?{LABELID}"}" {
746+
<St_iCodeOpt>{BLANK}*"{"(".")?{CODEID}"}" {
746747
yyextra->token.name = yytext;
747748
int i=yyextra->token.name.find('{'); /* } to keep vi happy */
748749
yyextra->token.name = yyextra->token.name.mid(i+1,yyextra->token.name.length()-i-2);

src/markdown.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static QCString escapeSpecialChars(const QCString &s)
284284
}
285285

286286
/** helper function to convert presence of left and/or right alignment markers
287-
* to a alignment value
287+
* to an alignment value
288288
*/
289289
static Alignment markersToAlignment(bool leftMarker,bool rightMarker)
290290
{
@@ -2231,7 +2231,7 @@ static bool isFencedCodeBlock(std::string_view data,size_t refIndent,
22312231
AUTO_TRACE("data='{}' refIndent={}",Trace::trunc(data),refIndent);
22322232
const char dot = '.';
22332233
auto isAlphaChar = [ ](char c) { return (c>='A' && c<='Z') || (c>='a' && c<='z'); };
2234-
auto isAlphaNChar = [ ](char c) { return (c>='A' && c<='Z') || (c>='a' && c<='z') || (c>='0' && c<='9'); };
2234+
auto isAlphaNChar = [ ](char c) { return (c>='A' && c<='Z') || (c>='a' && c<='z') || (c>='0' && c<='9') || (c=='+'); };
22352235
auto isLangChar = [&](char c) { return c==dot || isAlphaChar(c); };
22362236
// rules: at least 3 ~~~, end of the block same amount of ~~~'s, otherwise
22372237
// return FALSE

0 commit comments

Comments
 (0)