UNPKG

markdown-more

Version:

Helpers for creating markdown-js filters

1 lines 28.3 kB
!function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){var n=r(1).markdown,i=r(2);e.exports=function(){function e(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}function t(e,t,r){var n,i=0,o=e.length;for(i;i<o;i++)(n=e[i])(t,r,t)}function r(e,t,r,n){return t>e.length&&(t=e.length),n||(n=r,r=0),Array.prototype.splice.apply(e,[t,r].concat(n)),e}function o(e,r){if(!e)return"";r=r||{};var o={str:e};g.before&&g.before.length&&t(g.before,o,r);var l=n.parse(o.str,r&&r.dialect||i);a(r,l),g.transform&&g.transform.length&&t(g.transform,l,r);var s=n.toHTMLTree(l);g.html&&g.html.length&&t(g.html,s,r);var c={str:n.renderJsonML(s)};return g.after&&g.after.length&&t(g.after,c,r),c.str}function l(e,t){if(!t)return s(e);if(!g[e])throw new Error('hook "'+e+'" does not exist');return g[e].push(t),s(e)}function s(e){return function(t){return l(e,t)}}function a(e,t){var n=t[1].references;!function t(i,o,l){var s,a,c,u,f=0;if("string"==typeof i){if(0==o||"inlinecode"==l[0]||!i||/^\s+?\n?$/.test(i))return;c="string"}else{if(!Array.isArray(i))return;if(c=i[0],"link"!==c||d.test(i[1].href)){if("link_ref"===c){var a=i[1].ref;n&&n[a]||(i[0]="shortcode",c="shortcode")}}else i[1].label=i[1].href,i[0]="shortcode",delete i[1].href,c="shortcode";if("shortcode"===c&&v.test(i[2])){var h=v.exec(i[2]),p=h[1];if(g.command[p]){var b=(h[2]&&h[2].split("|")||[]).concat(i[1].label&&i[1].label.split("|")||[]);ret=g.command[p](p,b,e),ret?(l[o]=ret,c="string"==typeof ret&&"string"||ret[0]):(l[o]="",c="null")}}var m=0;for(m;m<i.length;m++)t(i[m],m,i)}if((u=g.json[c])&&(s=u.length))for(f=0;f<s;f++)ret=u[f](l[o],e,l,o),ret&&(Array.isArray(ret)?r(l,o,1,ret):l[o]=ret)}(t)}function c(e,t){g.json[e]||(g.json[e]=[]),g.json[e].push(t)}function u(t,r){t instanceof RegExp||(t=new RegExp("^"+e(t)+"$","g"));var n=function(e,i,o,l){var s=e[2],a=e[1];if(t.test(s)){var c=r.call(n,s,a,i,e,o,l);return c}};n.regExp=t,c("shortcode",n)}function f(e,t){var r=function(e,r,n){return t.apply(n,r)};g.command[e]=r}function h(e){var t=function(r,n,i){if(Array.isArray(r))r=r.map(function(e,r){return t(e,n,i)});else if(r&&"string"==typeof r){var o=e.call(t,r,n,i);if(o)return o}return r};c("string",t)}function p(e,t){h(function(r,n,i){var o=e(n);if(r.match(o)){var l=[""],s=0;return r.replace(o,function(e){var i,o=1,a=arguments.length-2,c=[],u=arguments[a],f=r.slice(s,u);for(s=u+e.length,o;o<a;o++)c.push(arguments[o]);c.push(e),f&&l.push(f);var i=t.apply(n,c);i&&l.push(i)}),s<r.length&&l.push(r.slice(s)),l}})}var g={before:[],json:{},command:{},html:[],after:[],transform:[]},d=/^((((http|ftp)s?:)?\/\/)|\.\/)[^\s]+$/,v=/^([a-zA-Z0-9]+)(?:\s(.+)$)?/;return o.register=l,o.markdown=n,o.registerJsonFilter=c,o.registerShortcode=u,o.registerStringFilter=h,o.registerCommandFilter=f,o.registerTokenFilter=p,o.escapeRegExp=e,o}()},function(e,t,r){t.markdown=r(3),t.parse=t.markdown.toHTML},function(e,t,r){var n=r(1).markdown,i=e.exports=n.Markdown.subclassDialect(n.Markdown.dialects.Maruku),o={js:"javascript",htm:"markup",html:"markup"};i.inline["`"]=function(e){var t=e.match(/(`+)(?:(\w+)\s*?\n)?(([\s\S]*?)\1)/);if(t&&t[3]){var r=t[1].length+t[3].length,e=t[4];if(t[1].length>2){if(t[2]){r+=t[2].length+1;var n=t[2].replace(/\s/g,"").toLowerCase();return n=o[n]?o[n]:n,[r,["code_block",{class:"language-"+n},e]]}return[r,["code_block",e]]}return[r,["inlinecode",e]]}return[1,"`"]}},function(e,t,r){!function(e){function t(){return"Markdown.mk_block( "+uneval(this.toString())+", "+uneval(this.trailing)+", "+uneval(this.lineNumber)+" )"}function n(){var e=r(7);return"Markdown.mk_block( "+e.inspect(this.toString())+", "+e.inspect(this.trailing)+", "+e.inspect(this.lineNumber)+" )"}function i(e){for(var t=0,r=-1;(r=e.indexOf("\n",r+1))!==-1;)t++;return t}function o(e,t){function r(e){this.len_after=e,this.name="close_"+t}var n=e+"_state",i="strong"==e?"em_state":"strong_state";return function(o,l){if(this[n][0]==t)return this[n].shift(),[o.length,new r(o.length-t.length)];var s=this[i].slice(),a=this[n].slice();this[n].unshift(t);var c=this.processInline(o.substr(t.length)),u=c[c.length-1];this[n].shift();if(u instanceof r){c.pop();var f=o.length-u.len_after;return[f,[e].concat(c)]}return this[i]=s,this[n]=a,[t.length,t]}}function l(e){for(var t=e.split(""),r=[""],n=!1;t.length;){var i=t.shift();switch(i){case" ":n?r[r.length-1]+=i:r.push("");break;case"'":case'"':n=!n;break;case"\\":i=t.shift();default:r[r.length-1]+=i}}return r}function s(e){return b(e)&&e.length>1&&"object"==typeof e[1]&&!b(e[1])?e[1]:void 0}function c(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function u(e){if("string"==typeof e)return c(e);var t=e.shift(),r={},n=[];for(!e.length||"object"!=typeof e[0]||e[0]instanceof Array||(r=e.shift());e.length;)n.push(u(e.shift()));var i="";for(var o in r)i+=" "+o+'="'+c(r[o])+'"';return"img"==t||"br"==t||"hr"==t?"<"+t+i+"/>":"<"+t+i+">"+n.join("")+"</"+t+">"}function f(e,t,r){var n;r=r||{};var i=e.slice(0);"function"==typeof r.preprocessTreeNode&&(i=r.preprocessTreeNode(i,t));var o=s(i);if(o){i[1]={};for(n in o)i[1][n]=o[n];o=i[1]}if("string"==typeof i)return i;switch(i[0]){case"header":i[0]="h"+i[1].level,delete i[1].level;break;case"bulletlist":i[0]="ul";break;case"numberlist":i[0]="ol";break;case"listitem":i[0]="li";break;case"para":i[0]="p";break;case"markdown":i[0]="html",o&&delete o.references;break;case"code_block":i[0]="pre",n=o?2:1;var l=["code"];l.push.apply(l,i.splice(n,i.length-n)),i[n]=l;break;case"inlinecode":i[0]="code";break;case"img":i[1].src=i[1].href,delete i[1].href;break;case"linebreak":i[0]="br";break;case"link":i[0]="a";break;case"link_ref":i[0]="a";var a=t[o.ref];if(!a)return o.original;delete o.ref,o.href=a.href,a.title&&(o.title=a.title),delete o.original;break;case"img_ref":i[0]="img";var a=t[o.ref];if(!a)return o.original;delete o.ref,o.src=a.href,a.title&&(o.title=a.title),delete o.original}if(n=1,o){for(var c in i[1]){n=2;break}1===n&&i.splice(n,1)}for(;n<i.length;++n)i[n]=f(i[n],t,r);return i}function h(e){for(var t=s(e)?2:1;t<e.length;)"string"==typeof e[t]?t+1<e.length&&"string"==typeof e[t+1]?e[t]+=e.splice(t+1,1)[0]:++t:(h(e[t]),++t)}var g=e.Markdown=function(e){switch(typeof e){case"undefined":this.dialect=g.dialects.Gruber;break;case"object":this.dialect=e;break;default:if(!(e in g.dialects))throw new Error("Unknown Markdown dialect '"+String(e)+"'");this.dialect=g.dialects[e]}this.em_state=[],this.strong_state=[],this.debug_indent=""};e.parse=function(e,t){var r=new g(t);return r.toTree(e)},e.toHTML=function(t,r,n){var i=e.toHTMLTree(t,r,n);return e.renderJsonML(i)},e.toHTMLTree=function(e,t,r){"string"==typeof e&&(e=this.parse(e,t));var n=s(e),i={};n&&n.references&&(i=n.references);var o=f(e,i,r);return h(o),o};var d=g.mk_block=function(e,r,i){1==arguments.length&&(r="\n\n");var o=new String(e);return o.trailing=r,o.inspect=n,o.toSource=t,void 0!=i&&(o.lineNumber=i),o};g.prototype.split_blocks=function(e,t){e=e.replace(/(\r\n|\n|\r)/g,"\n");var r,n=/([\s\S]+?)($|\n#|\n(?:\s*\n|$)+)/g,o=[],l=1;for(null!=(r=/^(\s*\n)/.exec(e))&&(l+=i(r[0]),n.lastIndex=r[0].length);null!==(r=n.exec(e));)"\n#"==r[2]&&(r[2]="\n",n.lastIndex--),o.push(d(r[1],r[2],l)),l+=i(r[0]);return o},g.prototype.processBlock=function(e,t){var r=this.dialect.block,n=r.__order__;if("__call__"in r)return r.__call__.call(this,e,t);for(var i=0;i<n.length;i++){var o=r[n[i]].call(this,e,t);if(o)return(!b(o)||o.length>0&&!b(o[0]))&&this.debug(n[i],"didn't return a proper array"),o}return[]},g.prototype.processInline=function(e){return this.dialect.inline.__call__.call(this,String(e))},g.prototype.toTree=function(e,t){var r=e instanceof Array?e:this.split_blocks(e),n=this.tree;try{for(this.tree=t||this.tree||["markdown"];r.length;){var i=this.processBlock(r.shift(),r);i.length&&this.tree.push.apply(this.tree,i)}return this.tree}finally{t&&(this.tree=n)}},g.prototype.debug=function(){var e=Array.prototype.slice.call(arguments);e.unshift(this.debug_indent),"undefined"!=typeof print&&print.apply(print,e),"undefined"!=typeof console&&"undefined"!=typeof console.log&&console.log.apply(null,e)},g.prototype.loop_re_over_block=function(e,t,r){for(var n,i=t.valueOf();i.length&&null!=(n=e.exec(i));)i=i.substr(n[0].length),r.call(this,n);return i},g.dialects={},g.dialects.Gruber={block:{atxHeader:function(e,t){var r=e.match(/^(#{1,6})\s*(.*?)\s*#*\s*(?:\n|$)/);if(r){var n=["header",{level:r[1].length}];return Array.prototype.push.apply(n,this.processInline(r[2])),r[0].length<e.length&&t.unshift(d(e.substr(r[0].length),e.trailing,e.lineNumber+2)),[n]}},setextHeader:function(e,t){var r=e.match(/^(.*)\n([-=])\2\2+(?:\n|$)/);if(r){var n="="===r[2]?1:2,i=["header",{level:n},r[1]];return r[0].length<e.length&&t.unshift(d(e.substr(r[0].length),e.trailing,e.lineNumber+2)),[i]}},code:function(e,t){var r=[],n=/^(?: {0,3}\t| {4})(.*)\n?/;if(e.match(n)){e:for(;;){var i=this.loop_re_over_block(n,e.valueOf(),function(e){r.push(e[1])});if(i.length){t.unshift(d(i,e.trailing));break e}if(!t.length)break e;if(!t[0].match(n))break e;r.push(e.trailing.replace(/[^\n]/g,"").substring(2)),e=t.shift()}return[["code_block",r.join("\n")]]}},horizRule:function(e,t){var r=e.match(/^(?:([\s\S]*?)\n)?[ \t]*([-_*])(?:[ \t]*\2){2,}[ \t]*(?:\n([\s\S]*))?$/);if(r){var n=[["hr"]];return r[1]&&n.unshift.apply(n,this.processBlock(r[1],[])),r[3]&&t.unshift(d(r[3])),n}},lists:function(){function e(e){return new RegExp("(?:^("+a+"{0,"+e+"} {0,3})("+o+")\\s+)|(^"+a+"{0,"+(e-1)+"}[ ]{0,4})")}function t(e){return e.replace(/ {0,3}\t/g," ")}function r(e,t,r,n){if(t)return void e.push(["para"].concat(r));var i=e[e.length-1]instanceof Array&&"para"==e[e.length-1][0]?e[e.length-1]:e;n&&e.length>1&&r.unshift(n);for(var o=0;o<r.length;o++){var l=r[o],s="string"==typeof l;s&&i.length>1&&"string"==typeof i[i.length-1]?i[i.length-1]+=l:i.push(l)}}function n(e,t){for(var r=new RegExp("^("+a+"{"+e+"}.*?\\n?)*$"),n=new RegExp("^"+a+"{"+e+"}","gm"),i=[];t.length>0&&r.exec(t[0]);){var o=t.shift(),l=o.replace(n,"");i.push(d(l,o.trailing,o.lineNumber))}return i}function i(e,t,r){var n=e.list,i=n[n.length-1];if(!(i[1]instanceof Array&&"para"==i[1][0]))if(t+1==r.length)i.push(["para"].concat(i.splice(1,i.length-1)));else{var o=i.pop();i.push(["para"].concat(i.splice(1,i.length-1)),o)}}var o="[*+-]|\\d+\\.",l=/[*+-]/,s=new RegExp("^( {0,3})("+o+")[ \t]+"),a="(?: {0,3}\\t| {4})";return function(o,a){function c(e){var t=l.exec(e[2])?["bulletlist"]:["numberlist"];return p.push({list:t,indent:e[1]}),t}var u=o.match(s);if(u){for(var f,h,p=[],g=c(u),d=!1,b=[p[0].list];;){for(var m=o.split(/(?=\n)/),y="",_=0;_<m.length;_++){var k="",w=m[_].replace(/^\n/,function(e){return k=e,""}),x=e(p.length);if(u=w.match(x),void 0!==u[1]){y.length&&(r(f,d,this.processInline(y),k),d=!1,y=""),u[1]=t(u[1]);var j=Math.floor(u[1].length/4)+1;if(j>p.length)g=c(u),f.push(g),f=g[1]=["listitem"];else{var S=!1;for(h=0;h<p.length;h++)if(p[h].indent==u[1]){g=p[h].list,p.splice(h+1,p.length-(h+1)),S=!0;break}S||(j++,j<=p.length?(p.splice(j,p.length-j),g=p[j-1].list):(g=c(u),f.push(g))),f=["listitem"],g.push(f)}k=""}w.length>u[0].length&&(y+=k+w.substr(u[0].length))}y.length&&(r(f,d,this.processInline(y),k),d=!1,y="");var $=n(p.length,a);$.length>0&&(v(p,i,this),f.push.apply(f,this.toTree($,[])));var E=a[0]&&a[0].valueOf()||"";if(!E.match(s)&&!E.match(/^ /))break;o=a.shift();var O=this.dialect.block.horizRule(o,a);if(O){b.push.apply(b,O);break}v(p,i,this),d=!0}return b}}}(),blockquote:function(e,t){if(e.match(/^>/m)){var r=[];if(">"!=e[0]){for(var n=e.split(/\n/),i=[],o=e.lineNumber;n.length&&">"!=n[0][0];)i.push(n.shift()),o++;var l=d(i.join("\n"),"\n",e.lineNumber);r.push.apply(r,this.processBlock(l,[])),e=d(n.join("\n"),e.trailing,o)}for(;t.length&&">"==t[0][0];){var a=t.shift();e=d(e+e.trailing+a,a.trailing,e.lineNumber)}var c=e.replace(/^> ?/gm,""),u=(this.tree,this.toTree(c,["blockquote"])),f=s(u);return f&&f.references&&(delete f.references,m(f)&&u.splice(1,1)),r.push(u),r}},referenceDefn:function(e,t){var r=/^\s*\[(.*?)\]:\s*(\S+)(?:\s+(?:(['"])(.*?)\3|\((.*?)\)))?\n?/;if(e.match(r)){s(this.tree)||this.tree.splice(1,0,{});var n=s(this.tree);void 0===n.references&&(n.references={});var i=this.loop_re_over_block(r,e,function(e){e[2]&&"<"==e[2][0]&&">"==e[2][e[2].length-1]&&(e[2]=e[2].substring(1,e[2].length-1));var t=n.references[e[1].toLowerCase()]={href:e[2]};void 0!==e[4]?t.title=e[4]:void 0!==e[5]&&(t.title=e[5])});return i.length&&t.unshift(d(i,e.trailing)),[]}},para:function(e,t){return[["para"].concat(this.processInline(e))]}}},g.dialects.Gruber.inline={__oneElement__:function(e,t,r){var n,i;t=t||this.dialect.inline.__patterns__;var o=new RegExp("([\\s\\S]*?)("+(t.source||t)+")");if(n=o.exec(e),!n)return[e.length,e];if(n[1])return[n[1].length,n[1]];var i;return n[2]in this.dialect.inline&&(i=this.dialect.inline[n[2]].call(this,e.substr(n.index),n,r||[])),i=i||[n[2].length,n[2]]},__call__:function(e,t){function r(e){"string"==typeof e&&"string"==typeof i[i.length-1]?i[i.length-1]+=e:i.push(e)}for(var n,i=[];e.length>0;)n=this.dialect.inline.__oneElement__.call(this,e,t,i),e=e.substr(n.shift()),v(n,r);return i},"]":function(){},"}":function(){},__escape__:/^\\[\\`\*_{}\[\]()#\+.!\-]/,"\\":function(e){return this.dialect.inline.__escape__.exec(e)?[2,e.charAt(1)]:[1,"\\"]},"![":function(e){var t=e.match(/^!\[(.*?)\][ \t]*\([ \t]*([^")]*?)(?:[ \t]+(["'])(.*?)\3)?[ \t]*\)/);if(t){t[2]&&"<"==t[2][0]&&">"==t[2][t[2].length-1]&&(t[2]=t[2].substring(1,t[2].length-1)),t[2]=this.dialect.inline.__call__.call(this,t[2],/\\/)[0];var r={alt:t[1],href:t[2]||""};return void 0!==t[4]&&(r.title=t[4]),[t[0].length,["img",r]]}return t=e.match(/^!\[(.*?)\][ \t]*\[(.*?)\]/),t?[t[0].length,["img_ref",{alt:t[1],ref:t[2].toLowerCase(),original:t[0]}]]:[2,"!["]},"[":function e(t){var r=String(t),n=g.DialectHelpers.inline_until_char.call(this,t.substr(1),"]");if(!n)return[1,"["];var e,i,o=1+n[0],l=n[1];t=t.substr(o);var s=t.match(/^\s*\([ \t]*([^"']*)(?:[ \t]+(["'])(.*?)\2)?[ \t]*\)/);if(s){var a=s[1];if(o+=s[0].length,a&&"<"==a[0]&&">"==a[a.length-1]&&(a=a.substring(1,a.length-1)),!s[3])for(var c=1,u=0;u<a.length;u++)switch(a[u]){case"(":c++;break;case")":0==--c&&(o-=a.length-u,a=a.substring(0,u))}return a=this.dialect.inline.__call__.call(this,a,/\\/)[0],i={href:a||""},void 0!==s[3]&&(i.title=s[3]),e=["link",i].concat(l),[o,e]}return s=t.match(/^\s*\[(.*?)\]/),s?(o+=s[0].length,i={ref:(s[1]||String(l)).toLowerCase(),original:r.substr(0,o)},e=["link_ref",i].concat(l),[o,e]):1==l.length&&"string"==typeof l[0]?(i={ref:l[0].toLowerCase(),original:r.substr(0,o)},e=["link_ref",i,l[0]],[o,e]):[1,"["]},"<":function(e){var t;return null!=(t=e.match(/^<(?:((https?|ftp|mailto):[^>]+)|(.*?@.*?\.[a-zA-Z]+))>/))?t[3]?[t[0].length,["link",{href:"mailto:"+t[3]},t[3]]]:"mailto"==t[2]?[t[0].length,["link",{href:t[1]},t[1].substr("mailto:".length)]]:[t[0].length,["link",{href:t[1]},t[1]]]:[1,"<"]},"`":function(e){var t=e.match(/(`+)(([\s\S]*?)\1)/);return t&&t[2]?[t[1].length+t[2].length,["inlinecode",t[3]]]:[1,"`"]}," \n":function(e){return[3,["linebreak"]]}},g.dialects.Gruber.inline["**"]=o("strong","**"),g.dialects.Gruber.inline.__=o("strong","__"),g.dialects.Gruber.inline["*"]=o("em","*"),g.dialects.Gruber.inline._=o("em","_"),g.buildBlockOrder=function(e){var t=[];for(var r in e)"__order__"!=r&&"__call__"!=r&&t.push(r);e.__order__=t},g.buildInlinePatterns=function(e){var t=[];for(var r in e)if(!r.match(/^__.*__$/)){var n=r.replace(/([\\.*+?|()\[\]{}])/g,"\\$1").replace(/\n/,"\\n");t.push(1==r.length?n:"(?:"+n+")")}t=t.join("|"),e.__patterns__=t;var i=e.__call__;e.__call__=function(e,r){return void 0!=r?i.call(this,e,r):i.call(this,e,t)}},g.DialectHelpers={},g.DialectHelpers.inline_until_char=function(e,t){for(var r=0,n=[];;){if(e.charAt(r)==t)return r++,[r,n];if(r>=e.length)return null;var i=this.dialect.inline.__oneElement__.call(this,e.substr(r));r+=i[0],n.push.apply(n,i.slice(1))}},g.subclassDialect=function(e){function t(){}function r(){}return t.prototype=e.block,r.prototype=e.inline,{block:new t,inline:new r}},g.buildBlockOrder(g.dialects.Gruber.block),g.buildInlinePatterns(g.dialects.Gruber.inline),g.dialects.Maruku=g.subclassDialect(g.dialects.Gruber),g.dialects.Maruku.processMetaHash=function(e){for(var t=l(e),r={},n=0;n<t.length;++n)if(/^#/.test(t[n]))r.id=t[n].substring(1);else if(/^\./.test(t[n]))r.class?r.class=r.class+t[n].replace(/./," "):r.class=t[n].substring(1);else if(/\=/.test(t[n])){var i=t[n].split(/\=/);r[i[0]]=i[1]}return r},g.dialects.Maruku.block.document_meta=function(e,t){if(!(e.lineNumber>1)&&e.match(/^(?:\w+:.*\n)*\w+:.*$/)){s(this.tree)||this.tree.splice(1,0,{});var r=e.split(/\n/);for(p in r){var n=r[p].match(/(\w+):\s*(.*)$/),i=n[1].toLowerCase(),o=n[2];this.tree[1][i]=o}return[]}},g.dialects.Maruku.block.block_meta=function(e,t){var r=e.match(/(^|\n) {0,3}\{:\s*((?:\\\}|[^\}])*)\s*\}$/);if(r){var n,i=this.dialect.processMetaHash(r[2]);if(""===r[1]){var o=this.tree[this.tree.length-1];if(n=s(o),"string"==typeof o)return;n||(n={},o.splice(1,0,n));for(a in i)n[a]=i[a];return[]}var l=e.replace(/\n.*$/,""),c=this.processBlock(l,[]);n=s(c[0]),n||(n={},c[0].splice(1,0,n));for(a in i)n[a]=i[a];return c}},g.dialects.Maruku.block.definition_list=function(e,t){var r,n,i=/^((?:[^\s:].*\n)+):\s+([\s\S]+)$/,o=["dl"];if(n=e.match(i)){for(var l=[e];t.length&&i.exec(t[0]);)l.push(t.shift());for(var s=0;s<l.length;++s){var n=l[s].match(i),a=n[1].replace(/\n$/,"").split(/\n/),c=n[2].split(/\n:\s+/);for(r=0;r<a.length;++r)o.push(["dt",a[r]]);for(r=0;r<c.length;++r)o.push(["dd"].concat(this.processInline(c[r].replace(/(\n)\s+/,"$1"))))}return[o]}},g.dialects.Maruku.block.table=function e(t,r){var n,i,o=function(e,t){t=t||"\\s",t.match(/^[\\|\[\]{}?*.+^$]$/)&&(t="\\"+t);for(var r,n=[],i=new RegExp("^((?:\\\\.|[^\\\\"+t+"])*)"+t+"(.*)");r=e.match(i);)n.push(r[1]),e=r[2];return n.push(e),n},l=/^ {0,3}\|(.+)\n {0,3}\|\s*([\-:]+[\-| :]*)\n((?:\s*\|.*(?:\n|$))*)(?=\n|$)/,s=/^ {0,3}(\S(?:\\.|[^\\|])*\|.*)\n {0,3}([\-:]+\s*\|[\-| :]*)\n((?:(?:\\.|[^\\|])*\|.*(?:\n|$))*)(?=\n|$)/;if(i=t.match(l))i[3]=i[3].replace(/^\s*\|/gm,"");else if(!(i=t.match(s)))return;var e=["table",["thead",["tr"]],["tbody"]];i[2]=i[2].replace(/\|\s*$/,"").split("|");var a=[];for(v(i[2],function(e){e.match(/^\s*-+:\s*$/)?a.push({align:"right"}):e.match(/^\s*:-+\s*$/)?a.push({align:"left"}):e.match(/^\s*:-+:\s*$/)?a.push({align:"center"}):a.push({})}),i[1]=o(i[1].replace(/\|\s*$/,""),"|"),n=0;n<i[1].length;n++)e[1][1].push(["th",a[n]||{}].concat(this.processInline(i[1][n].trim())));return v(i[3].replace(/\|\s*$/gm,"").split("\n"),function(t){var r=["tr"];for(t=o(t,"|"),n=0;n<t.length;n++)r.push(["td",a[n]||{}].concat(this.processInline(t[n].trim())));e[2].push(r)},this),[e]},g.dialects.Maruku.inline["{:"]=function(e,t,r){if(!r.length)return[2,"{:"];var n=r[r.length-1];if("string"==typeof n)return[2,"{:"];var i=e.match(/^\{:\s*((?:\\\}|[^\}])*)\s*\}/);if(!i)return[2,"{:"];var o=this.dialect.processMetaHash(i[1]),l=s(n);l||(l={},n.splice(1,0,l));for(var a in o)l[a]=o[a];return[i[0].length,""]},g.dialects.Maruku.inline.__escape__=/^\\[\\`\*_{}\[\]()#\+.!\-|:]/,g.buildBlockOrder(g.dialects.Maruku.block),g.buildInlinePatterns(g.dialects.Maruku.inline);var v,b=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)};v=Array.prototype.forEach?function(e,t,r){return e.forEach(t,r)}:function(e,t,r){for(var n=0;n<e.length;n++)t.call(r||e,e[n],n,e)};var m=function(e){for(var t in e)if(hasOwnProperty.call(e,t))return!1;return!0};e.renderJsonML=function(e,t){t=t||{},t.root=t.root||!1;var r=[];if(t.root)r.push(u(e));else for(e.shift(),!e.length||"object"!=typeof e[0]||e[0]instanceof Array||e.shift();e.length;)r.push(u(e.shift()));return r.join("\n\n")}}(function(){return t}())},function(e,t){function r(){throw new Error("setTimeout has not been defined")}function n(){throw new Error("clearTimeout has not been defined")}function i(e){if(u===setTimeout)return setTimeout(e,0);if((u===r||!u)&&setTimeout)return u=setTimeout,setTimeout(e,0);try{return u(e,0)}catch(t){try{return u.call(null,e,0)}catch(t){return u.call(this,e,0)}}}function o(e){if(f===clearTimeout)return clearTimeout(e);if((f===n||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}function l(){d&&p&&(d=!1,p.length?g=p.concat(g):v=-1,g.length&&s())}function s(){if(!d){var e=i(l);d=!0;for(var t=g.length;t;){for(p=g,g=[];++v<t;)p&&p[v].run();v=-1,t=g.length}p=null,d=!1,o(e)}}function a(e,t){this.fun=e,this.array=t}function c(){}var u,f,h=e.exports={};!function(){try{u="function"==typeof setTimeout?setTimeout:r}catch(e){u=r}try{f="function"==typeof clearTimeout?clearTimeout:n}catch(e){f=n}}();var p,g=[],d=!1,v=-1;h.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];g.push(new a(e,t)),1!==g.length||d||i(s)},a.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=c,h.addListener=c,h.once=c,h.off=c,h.removeListener=c,h.removeAllListeners=c,h.emit=c,h.prependListener=c,h.prependOnceListener=c,h.listeners=function(e){return[]},h.binding=function(e){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t,r){(function(e,n){function i(e,r){var n={seen:[],stylize:l};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),d(r)?n.showHidden=r:r&&t._extend(n,r),k(n.showHidden)&&(n.showHidden=!1),k(n.depth)&&(n.depth=2),k(n.colors)&&(n.colors=!1),k(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=o),a(n,e,n.depth)}function o(e,t){var r=i.styles[t];return r?"["+i.colors[r][0]+"m"+e+"["+i.colors[r][1]+"m":e}function l(e,t){return e}function s(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}function a(e,r,n){if(e.customInspect&&r&&$(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,e);return y(i)||(i=a(e,i,n)),i}var o=c(e,r);if(o)return o;var l=Object.keys(r),d=s(l);if(e.showHidden&&(l=Object.getOwnPropertyNames(r)),S(r)&&(l.indexOf("message")>=0||l.indexOf("description")>=0))return u(r);if(0===l.length){if($(r)){var v=r.name?": "+r.name:"";return e.stylize("[Function"+v+"]","special")}if(w(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(j(r))return e.stylize(Date.prototype.toString.call(r),"date");if(S(r))return u(r)}var b="",m=!1,_=["{","}"];if(g(r)&&(m=!0,_=["[","]"]),$(r)){var k=r.name?": "+r.name:"";b=" [Function"+k+"]"}if(w(r)&&(b=" "+RegExp.prototype.toString.call(r)),j(r)&&(b=" "+Date.prototype.toUTCString.call(r)),S(r)&&(b=" "+u(r)),0===l.length&&(!m||0==r.length))return _[0]+b+_[1];if(n<0)return w(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special");e.seen.push(r);var x;return x=m?f(e,r,n,d,l):l.map(function(t){return h(e,r,n,d,t,m)}),e.seen.pop(),p(x,b,_)}function c(e,t){if(k(t))return e.stylize("undefined","undefined");if(y(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return m(t)?e.stylize(""+t,"number"):d(t)?e.stylize(""+t,"boolean"):v(t)?e.stylize("null","null"):void 0}function u(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,r,n,i){for(var o=[],l=0,s=t.length;l<s;++l)A(t,String(l))?o.push(h(e,t,r,n,String(l),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(h(e,t,r,n,i,!0))}),o}function h(e,t,r,n,i,o){var l,s,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?s=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(s=e.stylize("[Setter]","special")),A(n,i)||(l="["+i+"]"),s||(e.seen.indexOf(c.value)<0?(s=v(r)?a(e,c.value,null):a(e,c.value,r-1),s.indexOf("\n")>-1&&(s=o?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n"))):s=e.stylize("[Circular]","special")),k(l)){if(o&&i.match(/^\d+$/))return s;l=JSON.stringify(""+i),l.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(l=l.substr(1,l.length-2),l=e.stylize(l,"name")):(l=l.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),l=e.stylize(l,"string"))}return l+": "+s}function p(e,t,r){var n=0,i=e.reduce(function(e,t){return n++,t.indexOf("\n")>=0&&n++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function g(e){return Array.isArray(e)}function d(e){return"boolean"==typeof e}function v(e){return null===e}function b(e){return null==e}function m(e){return"number"==typeof e}function y(e){return"string"==typeof e}function _(e){return"symbol"==typeof e}function k(e){return void 0===e}function w(e){return x(e)&&"[object RegExp]"===O(e)}function x(e){return"object"==typeof e&&null!==e}function j(e){return x(e)&&"[object Date]"===O(e)}function S(e){return x(e)&&("[object Error]"===O(e)||e instanceof Error)}function $(e){return"function"==typeof e}function E(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function O(e){return Object.prototype.toString.call(e)}function M(e){return e<10?"0"+e.toString(10):e.toString(10)}function T(){var e=new Date,t=[M(e.getHours()),M(e.getMinutes()),M(e.getSeconds())].join(":");return[e.getDate(),L[e.getMonth()],t].join(" ")}function A(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var z=/%[sdj%]/g;t.format=function(e){if(!y(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(i(arguments[r]));return t.join(" ")}for(var r=1,n=arguments,o=n.length,l=String(e).replace(z,function(e){if("%%"===e)return"%";if(r>=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),s=n[r];r<o;s=n[++r])l+=v(s)||!x(s)?" "+s:" "+i(s);return l},t.deprecate=function(r,i){function o(){if(!l){if(n.throwDeprecation)throw new Error(i);n.traceDeprecation?console.trace(i):console.error(i),l=!0}return r.apply(this,arguments)}if(k(e.process))return function(){return t.deprecate(r,i).apply(this,arguments)};if(n.noDeprecation===!0)return r;var l=!1;return o};var N,D={};t.debuglog=function(e){if(k(N)&&(N=n.env.NODE_DEBUG||""),e=e.toUpperCase(),!D[e])if(new RegExp("\\b"+e+"\\b","i").test(N)){var r=n.pid;D[e]=function(){var n=t.format.apply(t,arguments);console.error("%s %d: %s",e,r,n)}}else D[e]=function(){};return D[e]},t.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=g,t.isBoolean=d,t.isNull=v,t.isNullOrUndefined=b,t.isNumber=m,t.isString=y,t.isSymbol=_,t.isUndefined=k,t.isRegExp=w,t.isObject=x,t.isDate=j,t.isError=S,t.isFunction=$,t.isPrimitive=E,t.isBuffer=r(6);var L=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];t.log=function(){console.log("%s - %s",T(),t.format.apply(t,arguments))},t.inherits=r(5),t._extend=function(e,t){if(!t||!x(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}).call(t,function(){return this}(),r(4))}]);