fix
This commit is contained in:
101
book/node_modules/kramed/lib/rules/block.js
generated
vendored
Normal file
101
book/node_modules/kramed/lib/rules/block.js
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
var _utils = require('../utils');
|
||||
var replace = _utils.replace;
|
||||
var merge = _utils.merge;
|
||||
var noop = _utils.noop;
|
||||
|
||||
|
||||
/**
|
||||
* Block-Level Grammar
|
||||
*/
|
||||
|
||||
var block = {
|
||||
newline: /^\n+/,
|
||||
code: /^((?: {4}|\t)[^\n]+\n*)+/,
|
||||
fences: noop,
|
||||
yamlHeader: noop,
|
||||
hr: /^( *[-*_]){3,} *(?:\n|$)/,
|
||||
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n|$)/,
|
||||
nptable: noop,
|
||||
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n|$)/,
|
||||
blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
|
||||
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
|
||||
html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
|
||||
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n|$)/,
|
||||
footnote: /^\[\^([^\]]+)\]: ([^\n]+)/,
|
||||
table: noop,
|
||||
paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def|math))+)\n*/,
|
||||
text: /^[^\n]+/,
|
||||
math: /^ *(\${2,}) *([\s\S]+?)\s*\1 *(?:\n|$)/,
|
||||
};
|
||||
|
||||
block._bullet = /(?:[*+-]|\d+\.)/;
|
||||
block._item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
|
||||
block._item = replace(block._item, 'gm')
|
||||
(/bull/g, block._bullet)
|
||||
();
|
||||
|
||||
block.list = replace(block.list)
|
||||
(/bull/g, block._bullet)
|
||||
('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))')
|
||||
('def', '\\n+(?=' + block.def.source + ')')
|
||||
('footnote', block.footnote)
|
||||
();
|
||||
|
||||
block.blockquote = replace(block.blockquote)
|
||||
('def', block.def)
|
||||
();
|
||||
|
||||
block._tag = '(?!(?:'
|
||||
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
|
||||
+ '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
|
||||
+ '|span|br|wbr|ins|del|img)\\b)\\w+(?!:\\/|[^\\w\\s@]*@)\\b';
|
||||
|
||||
block.html = replace(block.html)
|
||||
('comment', /<!--[\s\S]*?-->/)
|
||||
('closed', /<(tag)[\s\S]+?<\/\1>/)
|
||||
('closing', /<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)
|
||||
(/tag/g, block._tag)
|
||||
();
|
||||
|
||||
block.paragraph = replace(block.paragraph)
|
||||
('hr', block.hr)
|
||||
('heading', block.heading)
|
||||
('lheading', block.lheading)
|
||||
('blockquote', block.blockquote)
|
||||
('tag', '<' + block._tag)
|
||||
('def', block.def)
|
||||
('math', block.math)
|
||||
();
|
||||
|
||||
/**
|
||||
* Normal Block Grammar
|
||||
*/
|
||||
|
||||
block.normal = merge({}, block);
|
||||
|
||||
/**
|
||||
* GFM Block Grammar
|
||||
*/
|
||||
|
||||
block.gfm = merge({}, block.normal, {
|
||||
fences: /^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n|$)/,
|
||||
paragraph: /^/,
|
||||
yamlHeader: /^ *(?=```)/,
|
||||
});
|
||||
|
||||
block.gfm.paragraph = replace(block.paragraph)
|
||||
('(?!', '(?!'
|
||||
+ block.gfm.fences.source.replace('\\1', '\\2') + '|'
|
||||
+ block.list.source.replace('\\1', '\\3') + '|')
|
||||
();
|
||||
|
||||
/**
|
||||
* GFM + Tables Block Grammar
|
||||
*/
|
||||
|
||||
block.tables = merge({}, block.gfm, {
|
||||
nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
|
||||
table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
|
||||
});
|
||||
|
||||
module.exports = block;
|
Reference in New Issue
Block a user