(function(){var f,l,o,p;var x=new Array;var g={">":"right","<":"left","=":"center","<>":"justify","~":"bottom","^":"top"};var B={"'":"&#8217;"," - ":" &#8211; ","--":"&#8212;"," x ":" &#215; ","\\.\\.\\.":"&#8230;","\\(C\\)":"&#169;","\\(R\\)":"&#174;","\\(TM\\)":"&#8482;"};var r={b:"\\*\\*",i:"__",em:"_",strong:"\\*",cite:"\\?\\?",sup:"\\^",sub:"~",span:"\\%",del:"-",code:"@",ins:"\\+",del:"-"};var t="\n\n";var d=0,k="",q="",c=0,y="";var b=/^p(\S*)\.\s*(.*)/;var n=/^fn(\d+)\.\s*(.*)/;var C=/^bq\.(\.)?\s*/;var A=/^table\s*{(.*)}\..*/;var h=/^\{(\S+)\}\.\s*\|/;var s=window.textilize=function(O){var F=O.split(/\r?\n/);p="";f=l=o=0;for(var V=0;V<F.length;V++){if(F[V].indexOf("[")==0){var T=F[V].indexOf("]");x[F[V].substring(1,T)]=F[V].substring(T+1)}}for(V=0;V<F.length;V++){if(F[V].indexOf("[")==0){continue}if(y=b.exec(F[V])){u(1);f=1;p+=F[V].replace(b,"<p"+e(y[1])+">"+w(y[2]));continue}if(y=/^h(\d)(\S*)\.\s*(.*)/.exec(F[V])){u(1);p+=D("h"+y[1],e(y[2]),w(y[3]))+t;continue}if(y=n.exec(F[V])){u(1);f=1;p+=F[V].replace(n,'<p id="fn'+y[1]+'"><sup>'+y[1]+"</sup>"+w(y[2]));continue}if(F[V].indexOf("*")==0){k="<ul>";q="</ul>"}else{if(F[V].indexOf("#")==0){k="<ol>";q="</ol>"}else{while(d>0){p+=q;if(d>1){p+="</li>"}else{p+="\n"}p+="\n";d--}k=""}}if(k){u(1);var T=/^([*#]+)\s*(.*)/.exec(F[V]);var R=T[1].length;while(R<d){p+=q+"</li>\n";d--}while(d<R){p=p.replace(/<\/li>\n$/,"\n");p+=k;d++}p+=D("li","",w(T[2]))+"\n";continue}if(F[V].match(A)){u(1);c=1;p+=F[V].replace(A,'<table style="$1;">\n');continue}if((F[V].indexOf("|")==0)||(F[V].match(h))){u(1);if(!c){p+="<table>\n";c=1}var M="";var Q="";var E=h.exec(F[V]);if(E){M=a("style",E[1]);F[V]=F[V].replace(h,"|")}var H=F[V].split("|");for(j=1;j<H.length-1;j++){var J="td";if(H[j].indexOf("_.")==0){J="th";H[j]=H[j].substring(2)}H[j]=w(H[j]);var U=/^([<>=^~\/\\\{]+.*?)\.(.*)/.exec(H[j]);var P="",S="";if(U!=null){H[j]=U[2];var I=/\\(\d+)/.exec(U[1]);if(I!=null){P+=a("colspan",I[1])}var L=/\/(\d+)/.exec(U[1]);if(L!=null){P+=a("rowspan",L[1])}var G=/([\^~])/.exec(U[1]);if(G!=null){S+="vertical-align:"+g[G[1]]+";"}var N=/(<>|=|<|>)/.exec(U[1]);if(N!=null){S+="text-align:"+g[N[1]]+";"}var K=/\{([^\}]+)\}/.exec(U[1]);if(K!=null){S+=K[1]}if(S!=""){P+=a("style",S)}}Q+=D(J,P,H[j])}p+="\t"+D("tr",M,Q)+"\n";continue}if(c){p+="</table>"+t;c=0}if(F[V]==""){u()}else{if(!f){if(y=C.exec(F[V])){F[V]=F[V].replace(C,"");p+="<blockquote>";l=1;if(y[1]){o=1}}p+="<p>"+w(F[V]);f=1}else{p+=w(F[V])}}}u();return p};function w(E){for(i in B){E=E.replace(new RegExp(i,"g"),B[i])}for(i in r){E=v(E,RegExp("^"+r[i]+"(.+?)"+r[i]),i,"");E=v(E,RegExp(" "+r[i]+"(.+?)"+r[i]),i," ")}E=E.replace(/\[(\d+)\]/g,'<sup><a href="#fn$1">$1</a></sup>');E=E.replace(/([A-Z]+)\((.*?)\)/g,'<acronym title="$2">$1</acronym>');E=E.replace(/\"([^\"]+)\":((http|https|mailto):\S+)/g,'<a href="$2">$1</a>');E=z(E,/!([^!\s]+)!:(\S+)/);E=z(E,/!([^!\s]+)!/);E=E.replace(/"([^\"]+)":(\S+)/g,function(G,F,H){return D("a",a("href",x[H]),F)});E=E.replace(/(=)?"([^\"]+)"/g,function(G,F,H){return(F)?G:"&#8220;"+H+"&#8221;"});return E}function v(H,G,F,I){while(m=G.exec(H)){var E=e(m[1]);m[1]=m[1].replace(/^[\[\{\(]\S+[\]\}\)]/g,"");m[1]=m[1].replace(/^[<>=()]+/,"");H=H.replace(G,I+D(F,E,m[1]))}return H}function z(F,L){var J=L.exec(F);if(J!=null){var G="";var M="";var E=/\((.*)\)$/.exec(J[1]);if(E!=null){G=a("alt",E[1])+a("title",E[1]);J[1]=J[1].replace(/\((.*)\)$/,"")}if(J[1].match(/^[><]/)){M="float:"+((J[1].indexOf(">")==0)?"right;":"left;");J[1]=J[1].replace(/^[><]/,"")}var K=/(\(+)/.exec(J[1]);if(K){M+="padding-left:"+K[1].length+"em;"}var H=/(\)+)/.exec(J[1]);if(H){M+="padding-right:"+H[1].length+"em;"}if(M){G+=a("style",M)}var I='<img src="'+J[1]+'"'+G+" />";if(J.length>2){I=D("a",a("href",J[2]),I)}F=F.replace(L,I)}return F}function e(K){var J="";var E="";if(!K){return""}var F=/\[(\w\w)\]/.exec(K);if(F!=null){E+=a("lang",F[1])}var L=/\((\S+)\)/.exec(K);if(L!=null){K=K.replace(/\((\S+)\)/,"");E+=L[1].replace(/#(.*)$/,' id="$1"').replace(/^(\S+)/,' class="$1"')}var G=/(<>|=|<|>)/.exec(K);if(G){J+="text-align:"+g[G[1]]+";"}var M=/\{(\S+)\}/.exec(K);if(M){J+=M[1];if(!M[1].match(/;$/)){J+=";"}}var I=/(\(+)/.exec(K);if(I){J+="padding-left:"+I[1].length+"em;"}var H=/(\)+)/.exec(K);if(H){J+="padding-right:"+H[1].length+"em;"}if(J){E+=a("style",J)}return E}function a(E,F){return" "+E+'="'+F+'"'}function D(F,E,G){return"<"+F+E+">"+G+"</"+F+">"}function u(E){if(E){o=0}if(f){p+="</p>"+t;f=0}if(l&&!o){p+="</blockquote>"+t;l=0}}})();
