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;
|
96
book/node_modules/kramed/lib/rules/inline.js
generated
vendored
Normal file
96
book/node_modules/kramed/lib/rules/inline.js
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
var _utils = require('../utils');
|
||||
var replace = _utils.replace;
|
||||
var merge = _utils.merge;
|
||||
var noop = _utils.noop;
|
||||
|
||||
/**
|
||||
* Inline-Level Grammar
|
||||
*/
|
||||
|
||||
var inline = {
|
||||
escape: /^\\([\\`*{}\[\]()#$+\-.!_>])/,
|
||||
autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
|
||||
url: noop,
|
||||
html: /^<!--[\s\S]*?-->|^<(\w+(?!:\/|[^\w\s@]*@)\b)*?(?:"[^"]*"|'[^']*'|[^'">])*?>([\s\S]*?)?<\/\1>|^<(\w+(?!:\/|[^\w\s@]*@)\b)(?:"[^"]*"|'[^']*'|[^'">])*?>/,
|
||||
link: /^!?\[(inside)\]\(href\)/,
|
||||
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
|
||||
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
|
||||
reffn: /^!?\[\^(inside)\]/,
|
||||
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
|
||||
em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
|
||||
code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
|
||||
br: /^ {2,}\n(?!\s*$)/,
|
||||
del: noop,
|
||||
text: /^[\s\S]+?(?=[\\<!\[_*`$]| {2,}\n|$)/,
|
||||
math: /^\$\$\s*([\s\S]*?[^\$])\s*\$\$(?!\$)/,
|
||||
};
|
||||
|
||||
inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
|
||||
inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
|
||||
|
||||
inline.link = replace(inline.link)
|
||||
('inside', inline._inside)
|
||||
('href', inline._href)
|
||||
();
|
||||
|
||||
inline.reflink = replace(inline.reflink)
|
||||
('inside', inline._inside)
|
||||
();
|
||||
|
||||
inline.reffn = replace(inline.reffn)
|
||||
('inside', inline._inside)
|
||||
();
|
||||
|
||||
/**
|
||||
* Normal Inline Grammar
|
||||
*/
|
||||
|
||||
inline.normal = merge({}, inline);
|
||||
|
||||
/**
|
||||
* Pedantic Inline Grammar
|
||||
*/
|
||||
|
||||
inline.pedantic = merge({}, inline.normal, {
|
||||
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
|
||||
em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
|
||||
});
|
||||
|
||||
/**
|
||||
* GFM Inline Grammar
|
||||
*/
|
||||
|
||||
inline.gfm = merge({}, inline.normal, {
|
||||
escape: replace(inline.escape)('])', '~|])')(),
|
||||
url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,
|
||||
del: /^~~(?=\S)([\s\S]*?\S)~~/,
|
||||
text: replace(inline.text)
|
||||
(']|', '~]|')
|
||||
('|', '|https?://|')
|
||||
()
|
||||
});
|
||||
|
||||
/**
|
||||
* GitBook Grammar
|
||||
*/
|
||||
inline.gitbook = merge({}, inline.gfm, {
|
||||
// Template variable
|
||||
tplvar: /^{{\s*(.*?)\s*(?=}})}}/,
|
||||
|
||||
// Template expression
|
||||
tplexpr: /^{%\s*(.*?)\s*(?=%})%}/,
|
||||
});
|
||||
inline.gitbook.text = replace(inline.gfm.text)
|
||||
('~]|', '~]|'+inline.gitbook.tplvar.source+'|'+inline.gitbook.tplexpr.source+'|')
|
||||
();
|
||||
|
||||
/**
|
||||
* GFM + Line Breaks Inline Grammar
|
||||
*/
|
||||
|
||||
inline.breaks = merge({}, inline.gfm, {
|
||||
br: replace(inline.br)('{2,}', '*')(),
|
||||
text: replace(inline.gfm.text)('{2,}', '*')()
|
||||
});
|
||||
|
||||
module.exports = inline;
|
Reference in New Issue
Block a user