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
81 KiB

/*! remarkable 1.2.0 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}({"./":[function(e,r){"use strict";r.exports=e("./lib/")},{"./lib/":9}],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
for(t=this.block.parse(e,this.options,r),s=0,i=t.length;i>s;s++)n=t[s],"inline"===n.type&&(n.children=this.inline.parse(n.content,this.options,r));return t},t.prototype.render=function(e){var r={references:{}};return this.renderer.render(this.parse(e,r),this.options,r)},r.exports=t},{"./common/utils":5,"./configs/commonmark":6,"./configs/default":7,"./configs/full":8,"./linkifier":10,"./parser_block":12,"./parser_inline":13,"./renderer":15,"./typographer":44}],10:[function(e,r){"use strict";function t(){this._rules=[],this.options={},this.ruler=new s(this.rulesUpdate.bind(this));for(var e=0;e<i.length;e++)this.ruler.after(i[e])}var n=e("./common/utils").assign,s=e("./ruler"),i=[e("./rules_text/linkify")];t.prototype.rulesUpdate=function(){this._rules=this.ruler.getRules()},t.prototype.set=function(e){n(this.options,e)},t.prototype.process=function(e){var r,t,n;for(n=this._rules,r=0,t=n.length;t>r;r++)n[r](this,e)},r.exports=t},{"./common/utils":5,"./ruler":16,"./rules_text/linkify":41}],11:[function(e,r){"use strict";function t(e,r){var t,n,s,i=-1,o=e.posMax,l=e.pos,a=e.isInLabel;if(e.isInLabel)return-1;if(e.labelUnmatchedScopes)return e.labelUnmatchedScopes--,-1;for(e.pos=r+1,e.isInLabel=!0,t=1;e.pos<o;){if(s=e.src.charCodeAt(e.pos),91===s)t++;else if(93===s&&(t--,0===t)){n=!0;break}e.parser.skipToken(e)}return n?(i=e.pos,e.labelUnmatchedScopes=0):e.labelUnmatchedScopes=t-1,e.pos=l,e.isInLabel=a,i}function n(e,r){var t,n,s=e.posMax,i="";if(60===e.src.charCodeAt(r)){for(r++;s>r;){if(t=e.src.charCodeAt(r),10===t)return!1;if(62===t)return e.pos=r+1,e.linkContent=i,!0;92===t&&s>r+1?(r++,i+=e.src[r++]):i+=e.src[r++]}return!1}for(n=0;s>r&&(t=e.src.charCodeAt(r),32!==t)&&!(32>t||127===t);)if(92===t&&s>r+1)r++,i+=e.src[r++];else{if(40===t&&(n++,n>1))break;if(41===t&&(n--,0>n))break;i+=e.src[r++]}return i.length&&e.parser.validateLink(i)?(e.pos=r,e.linkContent=i,!0):!1}function s(e,r){var t,n,s=e.posMax,i=e.src.charCodeAt(r);if(34!==i&&39!==i&&40!==i)return!1;for(r++,t="",40===i&&(i=41);s>r;){if(n=e.src.charCodeAt(r),n===i)return e.pos=r+1,e.linkContent=t,!0;92===n&&s>r+1?(r++,t+=e.src[r++]):t+=e.src[r++]}return!1}function i(e){return e.trim().replace(/\s+/g," ").toLowerCase()}r.exports.parseLinkLabel=t,r.exports.parseLinkDestination=n,r.exports.parseLinkTitle=s,r.exports.normalizeReference=i},{}],12:[function(e,r){"use strict";function t(){this._rules=[],this._rulesParagraphTerm=[],this._rulesBlockquoteTerm=[],this._rulesListTerm=[],this.ruler=new n(this.rulesUpdate.bind(this));for(var e=0;e<i.length;e++)this.ruler.after(i[e][0],i[e].slice(1))}var n=e("./ruler"),s=e("./rules_block/state_block"),i=[];i.push([e("./rules_block/code")]),i.push([e("./rules_block/fences"),"paragraph","blockquote","list"]),i.push([e("./rules_block/blockquote"),"paragraph","blockquote","list"]),i.push([e("./rules_block/hr"),"paragraph","blockquote","list"]),i.push([e("./rules_block/list"),"paragraph","blockquote"]),i.push([e("./rules_block/heading"),"paragraph","blockquote"]),i.push([e("./rules_block/lheading")]),i.push([e("./rules_block/htmlblock"),"paragraph","blockquote"]),i.push([e("./rules_block/table"),"paragraph"]),i.push([e("./rules_block/paragraph")]),t.prototype.rulesUpdate=function(){this._rules=this.ruler.getRules(),this._rulesParagraphTerm=this.ruler.getRules("paragraph"),this._rulesBlockquoteTerm=this.ruler.getRules("blockquote"),this._rulesListTerm=this.ruler.getRules("list")},t.prototype.tokenize=function(e,r,t){for(var n,s,i=this._rules,o=this._rules.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(!n)throw new Error("No matching rules found");if(l===e.line)throw new Error("None of rules updated state.line");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){var n,i=0,c=0;return e?(e=e.replace(a," "),e=e.replace(l,"\n"),e.indexOf(" ")>=0&&(e=e.replace(o,function(r,t)
if(10!==e.src.charCodeAt(s))return!1;for(t=e.pending.length-1,n=e.posMax,r||(t>=0&&32===e.pending.charCodeAt(t)?t>=1&&32===e.pending.charCodeAt(t-1)?(e.pending=e.pending.replace(/ +$/,""),e.push({type:"hardbreak",level:e.level})):(e.pending=e.pending.slice(0,-1),e.push({type:"softbreak",level:e.level})):e.push({type:"softbreak",level:e.level})),s++;n>s&&32===e.src.charCodeAt(s);)s++;return e.pos=s,!0}},{}],39:[function(e,r){"use strict";function t(e,r,t,n){this.src=e,this.env=n,this.options=t,this.parser=r,this.tokens=[],this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache=[],this.isInLabel=!1,this.linkLevel=0,this.linkContent="",this.labelUnmatchedScopes=0}t.prototype.pushPending=function(){this.tokens.push({type:"text",content:this.pending,level:this.pendingLevel}),this.pending=""},t.prototype.push=function(e){this.pending&&this.pushPending(),this.tokens.push(e),this.pendingLevel=this.level},t.prototype.cacheSet=function(e,r){for(var t=this.cache.length;e>=t;t++)this.cache.push(0);this.cache[e]=r},t.prototype.cacheGet=function(e){return e<this.cache.length?this.cache[e]:0},r.exports=t},{}],40:[function(e,r){r.exports=function(e,r){var t=e.src.slice(e.pos).match(e.parser.textMatch);return t?(r||(e.pending+=t[0]),e.pos+=t[0].length,!0):!1}},{}],41:[function(e,r){"use strict";function t(e){return/^<a[>\s]/i.test(e)}function n(e){return/^<\/a\s*>/i.test(e)}var s=e("autolinker"),i=[],o=new s({stripPrefix:!1,replaceFn:function(e,r){return"url"===r.getType()&&i.push({text:r.matchedText,url:r.getUrl()}),!1}});r.exports=function(e,r){var s,l,a,c,u,p,h,f=0,d=r.tokens;for(s=d.length-1;s>=0;s--)if(l=d[s],"link_close"!==l.type){if("htmltag"===l.type&&(t(l.content)&&f>0&&f--,n(l.content)&&f++),!(f>0)&&"text"===l.type&&(l.content.indexOf("://")||l.content.indexOf("www"))){if(a=l.content,i=[],o.link(a),!i.length)continue;for(c=[],h=l.level,u=0;u<i.length;u++)r.parser.validateLink(i[u].url)&&(p=a.indexOf(i[u].text),-1!==p&&(p&&(h=h,c.push({type:"text",content:a.slice(0,p),level:h})),c.push({type:"link_open",href:i[u].url,title:"",level:h++}),c.push({type:"text",content:i[u].text,level:h}),c.push({type:"link_close",level:--h}),a=a.slice(p+i[u].text.length)));a.length&&c.push({type:"text",content:a,level:h}),r.tokens=d=[].concat(d.slice(0,s),c,d.slice(s+1))}}else{for(s--;"link_open"!==d[s].type&&d[s].level!==l.level;)s--;s--}}},{autolinker:45}],42:[function(e,r){"use strict";r.exports=function(e,r){var t,n,s,i=r.tokens,o=e.options;for(t=i.length-1;t>=0;t--)n=i[t],"text"===n.type&&(s=n.content,s.indexOf("(")>=0&&(o.copyright&&(s=s.replace(/\(c\)/gi,"©")),o.trademark&&(s=s.replace(/\(tm\)/gi,"™")),o.registered&&(s=s.replace(/\(r\)/gi,"®")),o.paragraph&&(s=s.replace(/\(p\)/gi,"§"))),o.plusminus&&s.indexOf("+-")>=0&&(s=s.replace(/\+-/g,"±")),o.ellipsis&&s.indexOf("..")>=0&&(s=s.replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..")),o.dupes&&(s.indexOf("????")>=0||s.indexOf("!!!!")>=0||s.indexOf(",,")>=0)&&(s=s.replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",")),o.dashes&&s.indexOf("--")>=0&&(s=s.replace(/(^|[^-])---([^-]|$)/gm,"$1—$2").replace(/(^|\s)--(\s|$)/gm,"$1–$2").replace(/(^|[^-\s])--([^-\s]|$)/gm,"$1–$2")),n.content=s)}},{}],43:[function(e,r){"use strict";function t(e,r){return 0>r||r>=e.length?!1:!i.test(e[r])}function n(e,r,t,n){e[r]||(e[r]={}),e[r][t]=n}var s=/['"]/g,i=/[-\s()\[\]]/,o="’";r.exports=function(e,r){var i,l,a,c,u,p,h,f,d,g,m,b,v,k,y,x,w=e.options,q={},A=r.tokens,_=[];for(i=0;i<A.length;i++){for(l=A[i],h=A[i].level,v=_.length-1;v>=0&&!(_[v].level<=h);v--);if(_.length=v+1,"text"===l.type)for(a=l.content,u=0,p=a.length;p>u&&(s.lastIndex=u,c=s.exec(a));)if(f=!t(a,c.index-1),u=c.index+c[0].length,k="'"===c[0],d=!t(a,u),d||f){if(m=!d,b=!f)for(v=_.length-1;v>=0&&(g=_[v],!(_[v].level<h));v--)if(g.single===k&&_[v].level===h){g=_[v],x=k?w.singleQuotes:w.doubleQuotes,x&&(n(q,g.token,g.start,x[0]),n(q,i,c.index,x[1])),_.length=v,m=!1;break}m?_.push({token:i,start:c.index,end:u,single:k,level:h}):b&&k&&n(q,i,c.index,o)}else k&&n(q,i,c.index,o)}for(y=function(e,r){ret