Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed https://markdown-it.github.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4 lines
86 KiB

/*! remarkable 1.4.1 https://github.com//jonschlinkert/remarkable @license MIT */
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r;"undefined"!=typeof window?r=window:"undefined"!=typeof global?r=global:"undefined"!=typeof self&&(r=self),r.Remarkable=e()}}(function(){var e;return function r(e,t,n){function s(o,l){if(!t[o]){if(!e[o]){var a="function"==typeof require&&require;if(!l&&a)return a(o,!0);if(i)return i(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=t[o]={exports:{}};e[o][0].call(u.exports,function(r){var t=e[o][1][r];return s(t?t:r)},u,u.exports,r,e,t,n)}return t[o].exports}for(var i="function"==typeof require&&require,o=0;o<n.length;o++)s(n[o]);return s}({1:[function(e,r){"use strict";r.exports={Aacute:"Á",aacute:"á",Abreve:"Ă",abreve:"ă",ac:"∾",acd:"∿",acE:"∾̳",Acirc:"Â",acirc:"â",acute:"´",Acy:"А",acy:"а",AElig:"Æ",aelig:"æ",af:"⁡",Afr:"𝔄",afr:"𝔞",Agrave:"À",agrave:"à",alefsym:"ℵ",aleph:"ℵ",Alpha:"Α",alpha:"α",Amacr:"Ā",amacr:"ā",amalg:"⨿",AMP:"&",amp:"&",And:"⩓",and:"∧",andand:"⩕",andd:"⩜",andslope:"⩘",andv:"⩚",ang:"∠",ange:"⦤",angle:"∠",angmsd:"∡",angmsdaa:"⦨",angmsdab:"⦩",angmsdac:"⦪",angmsdad:"⦫",angmsdae:"⦬",angmsdaf:"⦭",angmsdag:"⦮",angmsdah:"⦯",angrt:"∟",angrtvb:"⊾",angrtvbd:"⦝",angsph:"∢",angst:"Å",angzarr:"⍼",Aogon:"Ą",aogon:"ą",Aopf:"𝔸",aopf:"𝕒",ap:"≈",apacir:"⩯",apE:"⩰",ape:"≊",apid:"≋",apos:"'",ApplyFunction:"⁡",approx:"≈",approxeq:"≊",Aring:"Å",aring:"å",Ascr:"𝒜",ascr:"𝒶",Assign:"≔",ast:"*",asymp:"≈",asympeq:"≍",Atilde:"Ã",atilde:"ã",Auml:"Ä",auml:"ä",awconint:"∳",awint:"⨑",backcong:"≌",backepsilon:"϶",backprime:"‵",backsim:"∽",backsimeq:"⋍",Backslash:"∖",Barv:"⫧",barvee:"⊽",Barwed:"⌆",barwed:"⌅",barwedge:"⌅",bbrk:"⎵",bbrktbrk:"⎶",bcong:"≌",Bcy:"Б",bcy:"б",bdquo:"„",becaus:"∵",Because:"∵",because:"∵",bemptyv:"⦰",bepsi:"϶",bernou:"ℬ",Bernoullis:"ℬ",Beta:"Β",beta:"β",beth:"ℶ",between:"≬",Bfr:"𝔅",bfr:"𝔟",bigcap:"⋂",bigcirc:"◯",bigcup:"⋃",bigodot:"⨀",bigoplus:"⨁",bigotimes:"⨂",bigsqcup:"⨆",bigstar:"★",bigtriangledown:"▽",bigtriangleup:"△",biguplus:"⨄",bigvee:"⋁",bigwedge:"⋀",bkarow:"⤍",blacklozenge:"⧫",blacksquare:"▪",blacktriangle:"▴",blacktriangledown:"▾",blacktriangleleft:"◂",blacktriangleright:"▸",blank:"␣",blk12:"▒",blk14:"░",blk34:"▓",block:"█",bne:"=⃥",bnequiv:"≡⃥",bNot:"⫭",bnot:"⌐",Bopf:"𝔹",bopf:"𝕓",bot:"⊥",bottom:"⊥",bowtie:"⋈",boxbox:"⧉",boxDL:"╗",boxDl:"╖",boxdL:"╕",boxdl:"┐",boxDR:"╔",boxDr:"╓",boxdR:"╒",boxdr:"┌",boxH:"═",boxh:"─",boxHD:"╦",boxHd:"╤",boxhD:"╥",boxhd:"┬",boxHU:"╩",boxHu:"╧",boxhU:"╨",boxhu:"┴",boxminus:"⊟",boxplus:"⊞",boxtimes:"⊠",boxUL:"╝",boxUl:"╜",boxuL:"╛",boxul:"┘",boxUR:"╚",boxUr:"╙",boxuR:"╘",boxur:"└",boxV:"║",boxv:"│",boxVH:"╬",boxVh:"╫",boxvH:"╪",boxvh:"┼",boxVL:"╣",boxVl:"╢",boxvL:"╡",boxvl:"┤",boxVR:"╠",boxVr:"╟",boxvR:"╞",boxvr:"├",bprime:"‵",Breve:"˘",breve:"˘",brvbar:"¦",Bscr:"ℬ",bscr:"𝒷",bsemi:"⁏",bsim:"∽",bsime:"⋍",bsol:"\\",bsolb:"⧅",bsolhsub:"⟈",bull:"•",bullet:"•",bump:"≎",bumpE:"⪮",bumpe:"≏",Bumpeq:"≎",bumpeq:"≏",Cacute:"Ć",cacute:"ć",Cap:"⋒",cap:"∩",capand:"⩄",capbrcup:"⩉",capcap:"⩋",capcup:"⩇",capdot:"⩀",CapitalDifferentialD:"ⅅ",caps:"∩︀",caret:"⁁",caron:"ˇ",Cayleys:"ℭ",ccaps:"⩍",Ccaron:"Č",ccaron:"č",Ccedil:"Ç",ccedil:"ç",Ccirc:"Ĉ",ccirc:"ĉ",Cconint:"∰",ccups:"⩌",ccupssm:"⩐",Cdot:"Ċ",cdot:"ċ",cedil:"¸",Cedilla:"¸",cemptyv:"⦲",cent:"¢",CenterDot:"·",centerdot:"·",Cfr:"ℭ",cfr:"𝔠",CHcy:"Ч",chcy:"ч",check:"✓",checkmark:"✓",Chi:"Χ",chi:"χ",cir:"○",circ:"ˆ",circeq:"≗",circlearrowleft:"↺",circlearrowright:"↻",circledast:"⊛",circledcirc:"⊚",circleddash:"⊝",CircleDot:"⊙",circledR:"®",circledS:"Ⓢ",CircleMinus:"⊖",CirclePlus:"⊕"
}return n?(i=e.pos,e.labelUnmatchedScopes=0):e.labelUnmatchedScopes=t-1,e.pos=l,e.isInLabel=a,i}},{}],13:[function(e,r){"use strict";var t=e("../common/utils").unescapeMd;r.exports=function(e,r){var n,s=r,i=e.posMax,o=e.src.charCodeAt(r);if(34!==o&&39!==o&&40!==o)return!1;for(r++,40===o&&(o=41);i>r;){if(n=e.src.charCodeAt(r),n===o)return e.pos=r+1,e.linkContent=t(e.src.slice(s+1,r)),!0;92===n&&i>r+1?r+=2:r++}return!1}},{"../common/utils":5}],14:[function(e,r){"use strict";function t(e,r,t){this.src=r,this.env=t,this.options=e.options,this.tokens=[],this.inlineMode=!1,this.inline=e.inline,this.block=e.block,this.renderer=e.renderer,this.typographer=e.typographer}function n(e,r){r||i(e)||(r=e||{},e="default"),this.inline=new c,this.block=new a,this.core=new l,this.renderer=new o,this.ruler=new u,this.options={},this.configure(p[e]),r&&this.set(r)}var s=e("./common/utils").assign,i=e("./common/utils").isString,o=e("./renderer"),l=e("./parser_core"),a=e("./parser_block"),c=e("./parser_inline"),u=e("./ruler"),p={"default":e("./configs/default"),full:e("./configs/full"),commonmark:e("./configs/commonmark")};n.prototype.set=function(e){s(this.options,e)},n.prototype.configure=function(e){var r=this;if(!e)throw new Error("Wrong `remarkable` preset, check name/content");e.options&&r.set(e.options),e.components&&Object.keys(e.components).forEach(function(t){e.components[t].rules&&r[t].ruler.enable(e.components[t].rules,!0)})},n.prototype.use=function(e,r){return e(this,r),this},n.prototype.parse=function(e,r){var n=new t(this,e,r);return this.core.process(n),n.tokens},n.prototype.render=function(e,r){return r=r||{},this.renderer.render(this.parse(e,r),this.options,r)},n.prototype.parseInline=function(e,r){var n=new t(this,e,r);return n.inlineMode=!0,this.core.process(n),n.tokens},n.prototype.renderInline=function(e,r){return r=r||{},this.renderer.render(this.parseInline(e,r),this.options,r)},r.exports=n},{"./common/utils":5,"./configs/commonmark":6,"./configs/default":7,"./configs/full":8,"./parser_block":15,"./parser_core":16,"./parser_inline":17,"./renderer":18,"./ruler":19}],15:[function(e,r){"use strict";function t(){this.ruler=new n;for(var e=0;e<i.length;e++)this.ruler.push(i[e][0],i[e][1],{alt:(i[e][2]||[]).slice()})}var n=e("./ruler"),s=e("./rules_block/state_block"),i=[["code",e("./rules_block/code")],["fences",e("./rules_block/fences"),["paragraph","blockquote","list"]],["blockquote",e("./rules_block/blockquote"),["paragraph","blockquote","list"]],["hr",e("./rules_block/hr"),["paragraph","blockquote","list"]],["list",e("./rules_block/list"),["paragraph","blockquote"]],["heading",e("./rules_block/heading"),["paragraph","blockquote"]],["lheading",e("./rules_block/lheading")],["htmlblock",e("./rules_block/htmlblock"),["paragraph","blockquote"]],["table",e("./rules_block/table"),["paragraph"]],["paragraph",e("./rules_block/paragraph")]];t.prototype.tokenize=function(e,r,t){for(var n,s,i=this.ruler.getRules(""),o=i.length,l=r,a=!1;t>l&&(e.line=l=e.skipEmptyLines(l),!(l>=t))&&!(e.tShift[l]<e.blkIndent);){for(s=0;o>s&&!(n=i[s](e,l,t,!1));s++);if(e.tight=!a,e.isEmpty(e.line-1)&&(a=!0),l=e.line,t>l&&e.isEmpty(l)){if(a=!0,l++,t>l&&"list"===e.parentType&&e.isEmpty(l))break;e.line=l}}};var o=/[\n\t]/g,l=/\r[\n\u0085]|[\u2424\u2028\u0085]/g,a=/\u00a0/g;t.prototype.parse=function(e,r,t,n){var i,c=0,u=0;return e?(e=e.replace(a," "),e=e.replace(l,"\n"),e.indexOf(" ")>=0&&(e=e.replace(o,function(r,t){var n;return 10===e.charCodeAt(t)?(c=t+1,u=0,r):(n=" ".slice((t-c-u)%4),u=t-c+1,n)})),i=new s(e,this,r,t,n),void this.tokenize(i,i.line,i.lineMax)):[]},r.exports=t},{"./ruler":19,"./rules_block/blockquote":20,"./rules_block/code":21,"./rules_block/fences":22,"./rules_block/heading":23,"./rules_block/hr":24,"./rules_block/htmlblock":25,"./rules_block/lheading":26,"./rules_block/list":27,"./rules_block/paragraph":28,"./rules_block/state_block":29,"./rules_block/table":30}],16:[function(e,r){"use strict";function t(){this.options={},this.ruler=new n;for(var e=0;e<s.length;e++)this.ruler.push(s[e][0],s[e][1])}var n=e("./ruler"),s=[["block",e
break}e.parser.skipToken(e)}return t?(e.posMax=e.pos,e.pos=a+2,r||(e.push({type:"del_open",level:e.level++}),e.parser.tokenize(e),e.push({type:"del_close",level:--e.level})),e.pos=e.posMax+2,e.posMax=l,!0):(e.pos=a,!1)}},{}],42:[function(e,r){"use strict";function t(e){return e>=48&&57>=e||e>=65&&90>=e||e>=97&&122>=e}function n(e,r){var n,s,i,o=r,l=!0,a=!0,c=e.posMax,u=e.src.charCodeAt(r);for(n=r>0?e.src.charCodeAt(r-1):-1;c>o&&e.src.charCodeAt(o)===u;)o++;return o>=c&&(l=!1),i=o-r,i>=4?l=a=!1:(s=c>o?e.src.charCodeAt(o):-1,(32===s||10===s)&&(l=!1),(32===n||10===n)&&(a=!1),95===u&&(t(n)&&(l=!1),t(s)&&(a=!1))),{can_open:l,can_close:a,delims:i}}r.exports=function(e,r){var t,s,i,o,l,a,c,u=e.posMax,p=e.pos,h=e.src.charCodeAt(p);if(95!==h&&42!==h)return!1;if(r)return!1;if(c=n(e,p),t=c.delims,!c.can_open)return e.pos+=t,r||(e.pending+=e.src.slice(p,e.pos)),!0;if(e.level>=e.options.maxNesting)return!1;for(e.pos=p+t,a=[t];e.pos<u;)if(e.src.charCodeAt(e.pos)!==h)e.parser.skipToken(e);else{if(c=n(e,e.pos),s=c.delims,c.can_close){for(o=a.pop(),l=s;o!==l;){if(o>l){a.push(o-l);break}if(l-=o,0===a.length)break;e.pos+=o,o=a.pop()}if(0===a.length){t=o,i=!0;break}e.pos+=s;continue}c.can_open&&a.push(s),e.pos+=s}return i?(e.posMax=e.pos,e.pos=p+t,r||((2===t||3===t)&&e.push({type:"strong_open",level:e.level++}),(1===t||3===t)&&e.push({type:"em_open",level:e.level++}),e.parser.tokenize(e),(1===t||3===t)&&e.push({type:"em_close",level:--e.level}),(2===t||3===t)&&e.push({type:"strong_close",level:--e.level})),e.pos=e.posMax+t,e.posMax=u,!0):(e.pos=p,!1)}},{}],43:[function(e,r){"use strict";var t=e("../common/entities"),n=e("../common/utils").isValidEntityCode,s=e("../common/utils").fromCodePoint,i=/^&#((?:x[a-f0-9]{1,8}|[0-9]{1,8}));/i,o=/^&([a-z][a-z0-9]{1,31});/i;r.exports=function(e,r){var l,a,c,u=e.pos,p=e.posMax;if(38!==e.src.charCodeAt(u))return!1;if(p>u+1)if(l=e.src.charCodeAt(u+1),35===l){if(c=e.src.slice(u).match(i))return r||(a="x"===c[1][0].toLowerCase()?parseInt(c[1].slice(1),16):parseInt(c[1],10),e.pending+=s(n(a)?a:65533)),e.pos+=c[0].length,!0}else if(c=e.src.slice(u).match(o),c&&t.hasOwnProperty(c[1]))return r||(e.pending+=t[c[1]]),e.pos+=c[0].length,!0;return r||(e.pending+="&"),e.pos++,!0}},{"../common/entities":1,"../common/utils":5}],44:[function(e,r){"use strict";for(var t=[],n=0;256>n;n++)t.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(e){t[e.charCodeAt(0)]=1}),r.exports=function(e,r){var n,s=e.pos,i=e.posMax;if(92!==e.src.charCodeAt(s))return!1;if(s++,i>s){if(n=e.src.charCodeAt(s),256>n&&0!==t[n])return r||(e.pending+=e.src[s]),e.pos+=2,!0;if(10===n){for(r||e.push({type:"hardbreak",level:e.level}),s++;i>s&&32===e.src.charCodeAt(s);)s++;return e.pos=s,!0}}return r||(e.pending+="\\"),e.pos++,!0}},{}],45:[function(e,r){"use strict";function t(e){var r=32|e;return r>=97&&122>=r}var n=e("../common/html_re").HTML_TAG_RE;r.exports=function(e,r){var s,i,o,l=e.pos;return e.options.html?(o=e.posMax,60!==e.src.charCodeAt(l)||l+2>=o?!1:(s=e.src.charCodeAt(l+1),(33===s||63===s||47===s||t(s))&&(i=e.src.slice(l).match(n))?(r||e.push({type:"htmltag",content:e.src.slice(l,l+i[0].length),level:e.level}),e.pos+=i[0].length,!0):!1)):!1}},{"../common/html_re":3}],46:[function(e,r){"use strict";r.exports=function(e,r){var t,n,s,i,o,l=e.posMax,a=e.pos;if(43!==e.src.charCodeAt(a))return!1;if(r)return!1;if(a+4>=l)return!1;if(43!==e.src.charCodeAt(a+1))return!1;if(e.level>=e.options.maxNesting)return!1;if(i=a>0?e.src.charCodeAt(a-1):-1,o=e.src.charCodeAt(a+2),43===i)return!1;if(43===o)return!1;if(32===o||10===o)return!1;for(n=a+2;l>n&&43===e.src.charCodeAt(n);)n++;if(n!==a+2)return e.pos+=n-a,r||(e.pending+=e.src.slice(a,n)),!0;for(e.pos=a+2,s=1;e.pos+1<l;){if(43===e.src.charCodeAt(e.pos)&&43===e.src.charCodeAt(e.pos+1)&&(i=e.src.charCodeAt(e.pos-1),o=e.pos+2<l?e.src.charCodeAt(e.pos+2):-1,43!==o&&43!==i&&(32!==i&&10!==i?s--:32!==o&&10!==o&&s++,0>=s))){t=!0;break}e.parser.skipToken(e)}return t?(e.posMax=e.pos,e.pos=a+2,r||(e.push({type:"ins_open",level:e.level++}),e.parser.tokenize(e),e.push({type:"ins_close",level:--e.