Skip to content

Commit

Permalink
Added documentation for ``` style fenced code block and more robust p…
Browse files Browse the repository at this point in the history
…arsing
  • Loading branch information
Dimitri van Heesch committed Apr 5, 2015
1 parent ba37d86 commit 39ba42c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 6 additions & 0 deletions doc/markdown.doc
Expand Up @@ -390,6 +390,12 @@ int func(int a,int b) { return a*b; }

The curly braces and dot are optional by the way.

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

```
also a fenced code block
```

\subsection md_header_id Header Id Attributes

Standard Markdown has no support for labeling headers, which
Expand Down
10 changes: 5 additions & 5 deletions src/pre.l
Expand Up @@ -2452,7 +2452,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
<SkipCComment>[\\@][\\@]("f{"|"f$"|"f[") {
outputArray(yytext,(int)yyleng);
}
<SkipCComment>"~~~"[~]* {
<SkipCComment>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
static bool markdownSupport = Config_getBool("MARKDOWN_SUPPORT");
if (!markdownSupport)
{
Expand All @@ -2465,7 +2465,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
BEGIN(SkipVerbatim);
}
}
<SkipCComment>"```"[`]* {
<SkipCComment>^({B}*"*"+)?{B}{0,3}"```"[`]* {
static bool markdownSupport = Config_getBool("MARKDOWN_SUPPORT");
if (!markdownSupport)
{
Expand Down Expand Up @@ -2612,14 +2612,14 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
BEGIN(SkipCComment);
}
}
<SkipVerbatim>"~~~"[~]* {
<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
outputArray(yytext,(int)yyleng);
if (g_fenceSize==yyleng)
{
BEGIN(SkipCComment);
}
}
<SkipVerbatim>"```"[`]* {
<SkipVerbatim>^({B}*"*"+)?{B}{0,3}"```"[`]* {
outputArray(yytext,(int)yyleng);
if (g_fenceSize==yyleng)
{
Expand All @@ -2629,7 +2629,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
<SkipVerbatim>"*/"|"/*" {
outputArray(yytext,(int)yyleng);
}
<SkipCComment,SkipVerbatim>[^*\\@\x06~\n\/]+ {
<SkipCComment,SkipVerbatim>[^*\\@\x06~`\n\/]+ {
outputArray(yytext,(int)yyleng);
}
<SkipCComment,SkipVerbatim>\n {
Expand Down
8 changes: 4 additions & 4 deletions src/scanner.l
Expand Up @@ -6264,14 +6264,14 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
g_nestedComment=FALSE;
BEGIN(DocCopyBlock);
}
<DocBlock>"~~~"[~]* {
<DocBlock>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
docBlock+=yytext;
docBlockName="~~~";
g_fencedSize=yyleng;
g_nestedComment=FALSE;
BEGIN(DocCopyBlock);
}
<DocBlock>"```"[`]* {
<DocBlock>^({B}*"*"+)?{B}{0,3}"```"[`]* {
docBlock+=yytext;
docBlockName="```";
g_fencedSize=yyleng;
Expand Down Expand Up @@ -6389,14 +6389,14 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
REJECT;
}
}
<DocCopyBlock>"~~~"[~]* {
<DocCopyBlock>^({B}*"*"+)?{B}{0,3}"~~~"[~]* {
docBlock+=yytext;
if (g_fencedSize==yyleng)
{
BEGIN(DocBlock);
}
}
<DocCopyBlock>"```"[`]* {
<DocCopyBlock>^({B}*"*"+)?{B}{0,3}"```"[`]* {
docBlock+=yytext;
if (g_fencedSize==yyleng)
{
Expand Down

0 comments on commit 39ba42c

Please sign in to comment.