天津投入产出系统后端
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.

5 lines
16 KiB

// Released under MIT license
// Copyright (c) 2009-2010 Dominic Baggott
// Copyright (c) 2009-2010 Ash Berlin
// Copyright (c) 2011 Christoph Dorn <christoph@christophdorn.com> (http://www.christophdorn.com)
(function(K){var e=K.Markdown=function e(R){switch(typeof R){case"undefined":this.dialect=e.dialects.Gruber;break;case"object":this.dialect=R;break;default:if(R in e.dialects){this.dialect=e.dialects[R]}else{throw new Error("Unknown Markdown dialect '"+String(R)+"'")}break}this.em_state=[];this.strong_state=[];this.debug_indent=""};K.parse=function(T,R){var S=new e(R);return S.toTree(T)};K.toHTML=function u(U,T,S){var R=K.toHTMLTree(U,T,S);return K.renderJsonML(R)};K.toHTMLTree=function w(S,W,U){if(typeof S==="string"){S=this.parse(S,W)}var T=C(S),R={};if(T&&T.references){R=T.references}var V=i(S,R,U);q(V);return V};function f(){return"Markdown.mk_block( "+uneval(this.toString())+", "+uneval(this.trailing)+", "+uneval(this.lineNumber)+" )"}function H(){var R=require("util");return"Markdown.mk_block( "+R.inspect(this.toString())+", "+R.inspect(this.trailing)+", "+R.inspect(this.lineNumber)+" )"}var g=e.mk_block=function(U,S,R){if(arguments.length==1){S="\n\n"}var T=new String(U);T.trailing=S;T.inspect=H;T.toSource=f;if(R!=undefined){T.lineNumber=R}return T};function G(S){var T=0,R=-1;while((R=S.indexOf("\n",R+1))!==-1){T++}return T}e.prototype.split_blocks=function z(T,W){var U=/([\s\S]+?)($|\n(?:\s*\n|$)+)/g,V=[],R;var S=1;if((R=/^(\s*\n)/.exec(T))!=null){S+=G(R[0]);U.lastIndex=R[0].length}while((R=U.exec(T))!==null){V.push(g(R[1],R[2],S));S+=G(R[0])}return V};e.prototype.processBlock=function M(W,V){var S=this.dialect.block,R=S.__order__;if("__call__" in S){return S.__call__.call(this,W,V)}for(var U=0;U<R.length;U++){var T=S[R[U]].call(this,W,V);if(T){if(!A(T)||(T.length>0&&!(A(T[0])))){this.debug(R[U],"didn't return a proper array")}return T}}return[]};e.prototype.processInline=function h(R){return this.dialect.inline.__call__.call(this,String(R))};e.prototype.toTree=function I(T,S){var U=T instanceof Array?T:this.split_blocks(T);var V=this.tree;try{this.tree=S||this.tree||["markdown"];U:while(U.length){var R=this.processBlock(U.shift(),U);if(!R.length){continue U}this.tree.push.apply(this.tree,R)}return this.tree}finally{if(S){this.tree=V}}};e.prototype.debug=function(){var R=Array.prototype.slice.call(arguments);R.unshift(this.debug_indent);if(typeof print!=="undefined"){print.apply(print,R)}if(typeof console!=="undefined"&&typeof console.log!=="undefined"){console.log.apply(null,R)}};e.prototype.loop_re_over_block=function(U,V,T){var S,R=V.valueOf();while(R.length&&(S=U.exec(R))!=null){R=R.substr(S[0].length);T.call(this,S)}return R};e.dialects={};e.dialects.Gruber={block:{atxHeader:function s(T,S){var R=T.match(/^(#{1,6})\s*(.*?)\s*#*\s*(?:\n|$)/);if(!R){return undefined}var U=["header",{level:R[1].length}];Array.prototype.push.apply(U,this.processInline(R[2]));if(R[0].length<T.length){S.unshift(g(T.substr(R[0].length),T.trailing,T.lineNumber+2))}return[U]},setextHeader:function x(T,S){var R=T.match(/^(.*)\n([-=])\2\2+(?:\n|$)/);if(!R){return undefined}var V=(R[2]==="=")?1:2;var U=["header",{level:V},R[1]];if(R[0].length<T.length){S.unshift(g(T.substr(R[0].length),T.trailing,T.lineNumber+2))}return[U]},code:function l(W,V){var T=[],U=/^(?: {0,3}\t| {4})(.*)\n?/,S;if(!W.match(U)){return undefined}block_search:do{var R=this.loop_re_over_block(U,W.valueOf(),function(X){T.push(X[1])});if(R.length){V.unshift(g(R,W.trailing));break block_search}else{if(V.length){if(!V[0].match(U)){break block_search}T.push(W.trailing.replace(/[^\n]/g,"").substring(2));W=V.shift()}else{break block_search}}}while(true);return[["code_block",T.join("\n")]]},horizRule:function P(T,S){var R=T.match(/^(?:([\s\S]*?)\n)?[ \t]*([-_*])(?:[ \t]*\2){2,}[ \t]*(?:\n([\s\S]*))?$/);if(!R){return undefined}var U=[["hr"]];if(R[1]){U.unshift.apply(U,this.processBlock(R[1],[]))}if(R[3]){S.unshift(g(R[3]))}return U},lists:(function(){var U="[*+-]|\\d+\\.",S=/[*+-]/,aa=/\d+\./,Y=new RegExp("^( {0,3})("+U+")[ \t]+"),T="(?: {0,3}\\t| {4})";function V(ab){return new RegExp("(?:^("+T+"{0,"+ab+"} {0,3})("+U+")\\s+)|(^"+T+"{0,"+(ab-1)+"}[ ]{0,4})")}function R(ab){return ab.replace(/ {0,3}\t/g," ")}function Z(ac,ai,ah,ad){if(ai){ac.push(["para"].concat(ah));retur