summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2015-04-05 14:22:37 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2015-04-05 14:22:37 (GMT)
commitba37d860547b6eec4d48077be573388686587e0e (patch)
treef7394631291ec37b7c4f31a92ab3e8f7c83cf872
parentadf51b6b92a3dd1931ff166d3ee84c952cedebf2 (diff)
parentbb93db0d60fd4cd123dfc886ecd20167068db6ba (diff)
downloadDoxygen-ba37d860547b6eec4d48077be573388686587e0e.zip
Doxygen-ba37d860547b6eec4d48077be573388686587e0e.tar.gz
Doxygen-ba37d860547b6eec4d48077be573388686587e0e.tar.bz2
Merge pull request #326 from halex2005/UseGithubFencedCodeBlockSyntax
add support for github flavored fenced code blocks
-rw-r--r--src/markdown.cpp8
-rw-r--r--src/pre.l20
-rw-r--r--src/scanner.l14
3 files changed, 39 insertions, 3 deletions
diff --git a/src/markdown.cpp b/src/markdown.cpp
index 5ecb198..32691d4 100644
--- a/src/markdown.cpp
+++ b/src/markdown.cpp
@@ -1366,7 +1366,9 @@ static bool isFencedCodeBlock(const char *data,int size,int refIndent,
int startTildes=0;
while (i<size && data[i]==' ') indent++,i++;
if (indent>=refIndent+4) return FALSE; // part of code block
- while (i<size && data[i]=='~') startTildes++,i++;
+ char tildaChar='~';
+ if (i<size && data[i]=='`') tildaChar='`';
+ while (i<size && data[i]==tildaChar) startTildes++,i++;
if (startTildes<3) return FALSE; // not enough tildes
if (i<size && data[i]=='{') i++; // skip over optional {
int startLang=i;
@@ -1376,11 +1378,11 @@ static bool isFencedCodeBlock(const char *data,int size,int refIndent,
start=i;
while (i<size)
{
- if (data[i]=='~')
+ if (data[i]==tildaChar)
{
end=i-1;
int endTildes=0;
- while (i<size && data[i]=='~') endTildes++,i++;
+ while (i<size && data[i]==tildaChar) endTildes++,i++;
while (i<size && data[i]==' ') i++;
if (i==size || data[i]=='\n')
{
diff --git a/src/pre.l b/src/pre.l
index 7c2ec2b..92912e6 100644
--- a/src/pre.l
+++ b/src/pre.l
@@ -2465,6 +2465,19 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
BEGIN(SkipVerbatim);
}
}
+<SkipCComment>"```"[`]* {
+ static bool markdownSupport = Config_getBool("MARKDOWN_SUPPORT");
+ if (!markdownSupport)
+ {
+ REJECT;
+ }
+ else
+ {
+ outputArray(yytext,(int)yyleng);
+ g_fenceSize=yyleng;
+ BEGIN(SkipVerbatim);
+ }
+ }
<SkipCComment>[\\@][\\@]("verbatim"|"latexonly"|"htmlonly"|"xmlonly"|"docbookonly"|"rtfonly"|"manonly"|"dot"|"code"("{"[^}]*"}")?){BN}+ {
outputArray(yytext,(int)yyleng);
g_yyLineNr+=QCString(yytext).contains('\n');
@@ -2606,6 +2619,13 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
BEGIN(SkipCComment);
}
}
+<SkipVerbatim>"```"[`]* {
+ outputArray(yytext,(int)yyleng);
+ if (g_fenceSize==yyleng)
+ {
+ BEGIN(SkipCComment);
+ }
+ }
<SkipVerbatim>"*/"|"/*" {
outputArray(yytext,(int)yyleng);
}
diff --git a/src/scanner.l b/src/scanner.l
index 2e111cb..c309289 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -6271,6 +6271,13 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
g_nestedComment=FALSE;
BEGIN(DocCopyBlock);
}
+<DocBlock>"```"[`]* {
+ docBlock+=yytext;
+ docBlockName="```";
+ g_fencedSize=yyleng;
+ g_nestedComment=FALSE;
+ BEGIN(DocCopyBlock);
+ }
<DocBlock>{B}*"<code>" {
if (insideCS)
{
@@ -6389,6 +6396,13 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
BEGIN(DocBlock);
}
}
+<DocCopyBlock>"```"[`]* {
+ docBlock+=yytext;
+ if (g_fencedSize==yyleng)
+ {
+ BEGIN(DocBlock);
+ }
+ }
<DocCopyBlock>[^\<@/*\]~\$\\\n]+ { // any character that is not special
docBlock+=yytext;
}