0
0
Fork 0
mirror of https://gitlab.com/Oreolek/salet-module.git synced 2024-07-02 23:05:02 +03:00
salet-module/test/lib/marked.min.js

1 line
16 KiB
JavaScript
Raw Normal View History

2016-09-26 07:48:27 +03:00
(function(){var d={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:l,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:l,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+|$)/,table:l,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};d.bullet=/(?:[*+-]|\d+\.)/;d.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;d.item=c(d.item,"gm")(/bull/g,d.bullet)();d.list=c(d.list)(/bull/g,d.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+d.def.source+")")();d.blockquote=c(d.blockquote)("def",d.def)();d._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";d.html=c(d.html)("comment",/<!--[\s\S]*?-->/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,d._tag)();d.paragraph=c(d.paragraph)("hr",d.hr)("heading",d.heading)("lheading",d.lheading)("blockquote",d.blockquote)("tag","<"+d._tag)("def",d.def)();d.normal=i({},d);d.gfm=i({},d.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/});d.gfm.paragraph=c(d.paragraph)("(?!","(?!"+d.gfm.fences.source.replace("\\1","\\2")+"|"+d.list.source.replace("\\1","\\3")+"|")();d.tables=i({},d.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function b(m){this.tokens=[];this.tokens.links={};this.options=m||a.defaults;this.rules=d.normal;if(this.options.gfm){if(this.options.tables){this.rules=d.tables}else{this.rules=d.gfm}}}b.rules=d;b.lex=function(o,m){var n=new b(m);return n.lex(o)};b.prototype.lex=function(m){m=m.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(m,true)};b.prototype.token=function(n,t,x){var n=n.replace(/^ +$/gm,""),r,p,v,s,u,w,m,q,o;while(n){if(v=this.rules.newline.exec(n)){n=n.substring(v[0].length);if(v[0].length>1){this.tokens.push({type:"space"})}}if(v=this.rules.code.exec(n)){n=n.substring(v[0].length);v=v[0].replace(/^ {4}/gm,"");this.tokens.push({type:"code",text:!this.options.pedantic?v.replace(/\n+$/,""):v});continue}if(v=this.rules.fences.exec(n)){n=n.substring(v[0].length);this.tokens.push({type:"code",lang:v[2],text:v[3]||""});continue}if(v=this.rules.heading.exec(n)){n=n.substring(v[0].length);this.tokens.push({type:"heading",depth:v[1].length,text:v[2]});continue}if(t&&(v=this.rules.nptable.exec(n))){n=n.substring(v[0].length);w={type:"table",header:v[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:v[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:v[3].replace(/\n$/,"").split("\n")};for(q=0;q<w.align.length;q++){if(/^ *-+: *$/.test(w.align[q])){w.align[q]="right"}else{if(/^ *:-+: *$/.test(w.align[q])){w.align[q]="center"}else{if(/^ *:-+ *$/.test(w.align[q])){w.align[q]="left"}else{w.align[q]=null}}}}for(q=0;q<w.cells.length;q++){w.cells[q]=w.cells[q].split(/ *\| */)}this.tokens.push(w);continue}if(v=this.rules.lheading.exec(n)){n=n.substring(v[0].length);this.tokens.push({type:"heading",depth:v[2]==="="?1:2,text:v[1]});continue}if(v=this.rules.hr.exec(n)){n=n.substring(v[0].length);this.tokens.push({type:"hr"});continue}if(v=this.rules.blockquote.exec(n)){n=n.substring(v[0].length);this.tokens.push({type:"blockquote_start"});v=v[0].replace(/^ *> ?/gm,"");this.token(v,t,true);this.tokens.push({type:"blockquote_end"});continue}if(v=this.rules.list.exec(n)){n=n.substring(v[0].length);s=v[2];this.tokens.push({type:"list_start",ordered:s.length>1});v=v[0].match(this.rules.item);r=false;o=v.length;q=0;for(;q<o;q++){w=v[q];m=w.length;w=w.replace(/^ *([*+-]|\d+\.) +/,"");if(~w.indexOf("\n ")){m-=w.length;w=!this.options.peda