add gfm code blocks
This commit is contained in:
parent
f43be5e5e0
commit
a6a3239df8
@ -12,6 +12,7 @@
|
||||
var block = {
|
||||
newline: /^\n+/,
|
||||
code: /^ {4,}[^\n]*(?:\n {4,}[^\n]*|\n)*(?=\n| *$)/,
|
||||
gfm_code: /^ *``` *(\w+)? *\n([^\0]+?)\s*```(?= *\n| *$)/,
|
||||
hr: /^( *[\-*_]){3,} *\n/,
|
||||
heading: /^ *(#{1,6}) *([^\0]+?) *#* *\n+/,
|
||||
lheading: /^([^\n]+)\n *(=|-){3,}/,
|
||||
@ -82,6 +83,17 @@ block.token = function(str, tokens) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// gfm_code
|
||||
if (cap = block.gfm_code.exec(str)) {
|
||||
str = str.substring(cap[0].length);
|
||||
tokens.push({
|
||||
type: 'code',
|
||||
lang: cap[1],
|
||||
text: cap[2]
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
// heading
|
||||
if (cap = block.heading.exec(str)) {
|
||||
str = str.substring(cap[0].length);
|
||||
|
Loading…
x
Reference in New Issue
Block a user