/** * EpicEditor - An Embeddable JavaScript Markdown Editor (https://github.com/OscarGodson/EpicEditor) * Copyright (c) 2011-2012, Oscar Godson. (MIT Licensed) */(function(e,t){function n(e,t){for(var n in t)t.hasOwnProperty(n)&&e.setAttribute(n,t[n])}function r(e,t){for(var n in t)t.hasOwnProperty(n)&&(e.style[n]=t[n])}function i(t,n){var r=t,i=null;return e.getComputedStyle?i=document.defaultView.getComputedStyle(r,null).getPropertyValue(n):r.currentStyle&&(i=r.currentStyle[n]),i}function s(e,t,n){var s={},o;if(t==="save"){for(o in n)n.hasOwnProperty(o)&&(s[o]=i(e,o));r(e,n)}else t==="apply"&&r(e,n);return s}function o(e){var t=parseInt(i(e,"border-left-width"),10)+parseInt(i(e,"border-right-width"),10),n=parseInt(i(e,"padding-left"),10)+parseInt(i(e,"padding-right"),10),r=e.offsetWidth,s;return isNaN(t)&&(t=0),s=t+n+r,s}function u(e){var t=parseInt(i(e,"border-top-width"),10)+parseInt(i(e,"border-bottom-width"),10),n=parseInt(i(e,"padding-top"),10)+parseInt(i(e,"padding-bottom"),10),r=parseInt(i(e,"height"),10),s;return isNaN(t)&&(t=0),s=t+n+r,s}function a(e,t,r){r=r||"";var i=t.getElementsByTagName("head")[0],s=t.createElement("link");n(s,{type:"text/css",id:r,rel:"stylesheet",href:e,name:e,media:"screen"}),i.appendChild(s)}function f(e,t,n){e.className=e.className.replace(t,n)}function l(e){return e.contentDocument||e.contentWindow.document}function c(e){var t;return typeof document.body.innerText=="string"?t=e.innerText:(t=e.innerHTML.replace(/
/gi,"\n"),t=t.replace(/<(?:.|\n)*?>/gm,""),t=t.replace(/</gi,"<"),t=t.replace(/>/gi,">")),t}function h(e,t){return t=t.replace(//g,">"),t=t.replace(/\n/g,"
"),t=t.replace(/
\s/g,"
 "),t=t.replace(/\s\s\s/g,"   "),t=t.replace(/\s\s/g,"  "),t=t.replace(/^ /," "),e.innerHTML=t,!0}function p(e){return e.replace(/\u00a0/g," ").replace(/ /g," ")}function d(){var e=-1,t=navigator.userAgent,n;return navigator.appName=="Microsoft Internet Explorer"&&(n=/MSIE ([0-9]{1,}[\.0-9]{0,})/,n.exec(t)!=null&&(e=parseFloat(RegExp.$1,10))),e}function v(){var t=e.navigator;return t.userAgent.indexOf("Safari")>-1&&t.userAgent.indexOf("Chrome")==-1}function m(){var t=e.navigator;return t.userAgent.indexOf("Firefox")>-1&&t.userAgent.indexOf("Seamonkey")==-1}function g(e){var t={};return e&&t.toString.call(e)==="[object Function]"}function y(){var e=arguments[0]||{},n=1,r=arguments.length,i=!1,s,o,u,a;typeof e=="boolean"&&(i=e,e=arguments[1]||{},n=2),typeof e!="object"&&!g(e)&&(e={}),r===n&&(e=this,--n);for(;n0&&(n.settings.textarea=c[0],r(n.settings.textarea,{display:"none"}))}return n.settings.file.name||(typeof n.settings.container=="string"?n.settings.file.name=n.settings.container:typeof n.settings.container=="object"&&(n.element.id?n.settings.file.name=n.element.id:(b._data.unnamedEditors||(b._data.unnamedEditors=[]),b._data.unnamedEditors.push(n),n.settings.file.name="__epiceditor-untitled-"+b._data.unnamedEditors.length))),n.settings.button.bar==="show"&&(n.settings.button.bar=!0),n.settings.button.bar==="hide"&&(n.settings.button.bar=!1),n._instanceId="epiceditor-"+Math.round(Math.random()*1e5),n._storage={},n._canSave=!0,n._defaultFileSchema=function(){return{content:n.settings.file.defaultContent,created:new Date,modified:new Date}},localStorage&&n.settings.clientSideStorage&&(this._storage=localStorage,this._storage[n.settings.localStorageName]&&n.getFiles(n.settings.file.name)===t&&(o=n._defaultFileSchema(),o.content=n.settings.file.defaultContent)),this._storage[n.settings.localStorageName]||(a={},a[n.settings.file.name]=n._defaultFileSchema(),a=JSON.stringify(a),this._storage[n.settings.localStorageName]=a),n._previewDraftLocation="__draft-",n._storage[n._previewDraftLocation+n.settings.localStorageName]=n._storage[n.settings.localStorageName],n._eeState={fullscreen:!1,preview:!1,edit:!1,loaded:!1,unloaded:!1},n.events||(n.events={}),this}b.prototype.load=function(t){function M(t){if(o.settings.button.bar!=="auto")return;if(Math.abs(y.y-t.pageY)>=5||Math.abs(y.x-t.pageX)>=5)p.style.display="block",m&&clearTimeout(m),m=e.setTimeout(function(){p.style.display="none"},1e3);y={y:t.pageY,x:t.pageX}}function _(e){e.keyCode==o.settings.shortcut.modifier&&(C=!0),e.keyCode==17&&(k=!0),e.keyCode==18&&(k=!1),C===!0&&e.keyCode==o.settings.shortcut.preview&&!o.is("fullscreen")&&(e.preventDefault(),o.is("edit")&&o._previewEnabled?o.preview():o._editEnabled&&o.edit()),C===!0&&e.keyCode==o.settings.shortcut.fullscreen&&o._fullscreenEnabled&&(e.preventDefault(),o._goFullscreen(N)),C===!0&&e.keyCode!==o.settings.shortcut.modifier&&(C=!1),e.keyCode==27&&o.is("fullscreen")&&o._exitFullscreen(N),k===!0&&e.keyCode==83&&(o.save(),e.preventDefault(),k=!1),e.metaKey&&e.keyCode==83&&(o.save(),e.preventDefault())}function D(e){e.keyCode==o.settings.shortcut.modifier&&(C=!1),e.keyCode==17&&(k=!1)}function P(t){var n;t.clipboardData?(t.preventDefault(),n=t.clipboardData.getData("text/plain"),o.editorIframeDocument.execCommand("insertText",!1,n)):e.clipboardData&&(t.preventDefault(),n=e.clipboardData.getData("Text"),n=n.replace(//g,">"),n=n.replace(/\n/g,"
"),n=n.replace(/\r/g,""),n=n.replace(/
\s/g,"
 "),n=n.replace(/\s\s\s/g,"   "),n=n.replace(/\s\s/g,"  "),o.editorIframeDocument.selection.createRange().pasteHTML(n))}if(this.is("loaded"))return this;var o=this,u,f,c,h,p,m,g,y={y:-1,x:-1},b,w,E=!1,S=!1,x=!1,T=!1,N,C=!1,k=!1,L,A,O;o._eeState.startup=!0,o.settings.useNativeFullscreen&&(S=document.body.webkitRequestFullScreen?!0:!1,x=document.body.mozRequestFullScreen?!0:!1,T=document.body.requestFullscreen?!0:!1,E=S||x||T),v()&&(E=!1,S=!1),!o.is("edit")&&!o.is("preview")&&(o._eeState.edit=!0),t=t||function(){},u={chrome:'
'+(o._previewEnabled?' ':"")+(o._editEnabled?' ':"")+(o._fullscreenEnabled?'':"")+"
"+"
",previewer:'
',editor:""},f=document.createElement("iframe"),n(f,{scrolling:"no",frameborder:0,id:o._instanceId}),o.element.appendChild(f),o.element.style.height=o.element.offsetHeight+"px",o.iframeElement=f,o.iframe=l(f),o.iframe.open(),o.iframe.write(u.chrome),o.editorIframe=o.iframe.getElementById("epiceditor-editor-frame"),o.previewerIframe=o.iframe.getElementById("epiceditor-previewer-frame"),o.editorIframeDocument=l(o.editorIframe),o.editorIframeDocument.open(),o.editorIframeDocument.write(u.editor),o.editorIframeDocument.close(),o.previewerIframeDocument=l(o.previewerIframe),o.previewerIframeDocument.open(),o.previewerIframeDocument.write(u.previewer),c=o.previewerIframeDocument.createElement("base"),c.target="_blank",o.previewerIframeDocument.getElementsByTagName("head")[0].appendChild(c),o.previewerIframeDocument.close(),o.reflow(),a(o.settings.theme.base,o.iframe,"theme"),a(o.settings.theme.editor,o.editorIframeDocument,"theme"),a(o.settings.theme.preview,o.previewerIframeDocument,"theme"),o.iframe.getElementById("epiceditor-wrapper").style.position="relative",o.editorIframe.style.position="absolute",o.previewerIframe.style.position="absolute",o.editor=o.editorIframeDocument.body,o.previewer=o.previewerIframeDocument.getElementById("epiceditor-preview"),o.editor.contentEditable=!0,o.iframe.body.style.height=this.element.offsetHeight+"px",o.previewerIframe.style.left="-999999px",this.editorIframeDocument.body.style.wordWrap="break-word",d()>-1&&(this.previewer.style.height=parseInt(i(this.previewer,"height"),10)+2),this.open(o.settings.file.name),o.settings.focusOnLoad&&o.iframe.addEventListener("readystatechange",function(){o.iframe.readyState=="complete"&&o.focus()}),o.previewerIframeDocument.addEventListener("click",function(t){var n=t.target,r=o.previewerIframeDocument.body;n.nodeName=="A"&&n.hash&&n.hostname==e.location.hostname&&(t.preventDefault(),n.target="_self",r.querySelector(n.hash)&&(r.scrollTop=r.querySelector(n.hash).offsetTop))}),h=o.iframe.getElementById("epiceditor-utilbar"),b={},o._goFullscreen=function(t,n){n=n||function(){};var r=0;this._fixScrollbars("auto");if(o.is("fullscreen")){o._exitFullscreen(t,n);return}E&&(S?(t.webkitRequestFullScreen(),r=750):x?t.mozRequestFullScreen():T&&t.requestFullscreen()),w=o.is("edit"),setTimeout(function(){o._eeState.fullscreen=!0,o._eeState.edit=!0,o._eeState.preview=!0;var t=e.innerWidth,r=e.innerHeight,u=e.outerWidth,a=e.outerHeight;E||(a=e.innerHeight),b.editorIframe=s(o.editorIframe,"save",{width:u/2+"px",height:a+"px","float":"left",cssFloat:"left",styleFloat:"left",display:"block",position:"static",left:""}),b.previewerIframe=s(o.previewerIframe,"save",{width:u/2+"px",height:a+"px","float":"right",cssFloat:"right",styleFloat:"right",display:"block",position:"static",left:""}),b.element=s(o.element,"save",{position:"fixed",top:"0",left:"0",width:"100%","z-index":"9999",zIndex:"9999",border:"none",margin:"0",background:i(o.editor,"background-color"),height:r+"px"}),b.iframeElement=s(o.iframeElement,"save",{width:u+"px",height:r+"px"}),h.style.visibility="hidden",E||(document.body.style.overflow="hidden"),o.preview(),o.focus(),o.emit("fullscreenenter"),n.call(o)},r)},o._exitFullscreen=function(e,t){t=t||function(){},this._fixScrollbars(),s(o.element,"apply",b.element),s(o.iframeElement,"apply",b.iframeElement),s(o.editorIframe,"apply",b.editorIframe),s(o.previewerIframe,"apply",b.previewerIframe),o.element.style.width=o._eeState.reflowWidth?o._eeState.reflowWidth:"",o.element.style.height=o._eeState.reflowHeight?o._eeState.reflowHeight:"",h.style.visibility="visible",o._eeState.fullscreen=!1,E?S?document.webkitCancelFullScreen():x?document.mozCancelFullScreen():T&&document.exitFullscreen():document.body.style.overflow="auto",w?o.edit():o.preview(),o.reflow(),o.emit("fullscreenexit"),t.call(o)},o.editor.addEventListener("keyup",function(){g&&e.clearTimeout(g),g=e.setTimeout(function(){o.is("fullscreen")&&o.preview()},250)}),N=o.iframeElement,h.addEventListener("click",function(e){var t=e.target.className;t.indexOf("epiceditor-toggle-preview-btn")>-1?o.preview():t.indexOf("epiceditor-toggle-edit-btn")>-1?o.edit():t.indexOf("epiceditor-fullscreen-btn")>-1&&o._goFullscreen(N)}),S?document.addEventListener("webkitfullscreenchange",function(){!document.webkitIsFullScreen&&o._eeState.fullscreen&&o._exitFullscreen(N)},!1):x?document.addEventListener("mozfullscreenchange",function(){!document.mozFullScreen&&o._eeState.fullscreen&&o._exitFullscreen(N)},!1):T&&document.addEventListener("fullscreenchange",function(){document.fullscreenElement==null&&o._eeState.fullscreen&&o._exitFullscreen(N)},!1),p=o.iframe.getElementById("epiceditor-utilbar"),o.settings.button.bar!==!0&&(p.style.display="none"),p.addEventListener("mouseover",function(){m&&clearTimeout(m)}),L=[o.previewerIframeDocument,o.editorIframeDocument];for(A=0;Ai&&(n=i,a=!0),a?this._fixScrollbars("auto"):this._fixScrollbars("hidden"),n!=this.oldHeight&&(this.getElement("container").style.height=n+"px",this.reflow(),this.settings.autogrow.scroll&&e.scrollBy(0,n-this.oldHeight),this.oldHeight=n))},b.prototype._fixScrollbars=function(e){var t;this.settings.autogrow?t="hidden":t="auto",t=e||t,this.getElement("editor").documentElement.style.overflow=t,this.getElement("previewer").documentElement.style.overflow=t},b.version="0.2.2",b._data={},typeof e.define=="function"&&e.define.amd?e.define(function(){return b}):e.EpicEditor=b})(window),function(){function t(t){this.tokens=[],this.tokens.links={},this.options=t||c.defaults,this.rules=e.normal,this.options.gfm&&(this.options.tables?this.rules=e.tables:this.rules=e.gfm)}function r(e,t){this.options=t||c.defaults,this.links=e,this.rules=n.normal,this.renderer=this.options.renderer||new i,this.renderer.options=this.options;if(!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.options.breaks?this.rules=n.breaks:this.rules=n.gfm:this.options.pedantic&&(this.rules=n.pedantic)}function i(e){this.options=e||{}}function s(e){this.tokens=[],this.token=null,this.options=e||c.defaults,this.options.renderer=this.options.renderer||new i,this.renderer=this.options.renderer,this.renderer.options=this.options}function o(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function u(e){return e.replace(/&([#\w]+);/g,function(e,t){return t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function a(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=i.source||i,i=i.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,i),n):new RegExp(e,t)}}function f(){}function l(e){var t=1,n,r;for(;tAn error occured:

"+o(h.message+"",!0)+"
";throw h}}var e={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:f,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:f,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:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:f,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};e.bullet=/(?:[*+-]|\d+\.)/,e.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,e.item=a(e.item,"gm")(/bull/g,e.bullet)(),e.list=a(e.list)(/bull/g,e.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+e.def.source+")")(),e.blockquote=a(e.blockquote)("def",e.def)(),e._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",e.html=a(e.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,e._tag)(),e.paragraph=a(e.paragraph)("hr",e.hr)("heading",e.heading)("lheading",e.lheading)("blockquote",e.blockquote)("tag","<"+e._tag)("def",e.def)(),e.normal=l({},e),e.gfm=l({},e.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/}),e.gfm.paragraph=a(e.paragraph)("(?!","(?!"+e.gfm.fences.source.replace("\\1","\\2")+"|"+e.list.source.replace("\\1","\\3")+"|")(),e.tables=l({},e.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),t.rules=e,t.lex=function(e,n){var r=new t(n);return r.lex(e)},t.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},t.prototype.token=function(t,n,r){var t=t.replace(/^ +$/gm,""),i,s,o,u,a,f,l,c,h;while(t){if(o=this.rules.newline.exec(t))t=t.substring(o[0].length),o[0].length>1&&this.tokens.push({type:"space"});if(o=this.rules.code.exec(t)){t=t.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?o:o.replace(/\n+$/,"")});continue}if(o=this.rules.fences.exec(t)){t=t.substring(o[0].length),this.tokens.push({type:"code",lang:o[2],text:o[3]});continue}if(o=this.rules.heading.exec(t)){t=t.substring(o[0].length),this.tokens.push({type:"heading",depth:o[1].length,text:o[2]});continue}if(n&&(o=this.rules.nptable.exec(t))){t=t.substring(o[0].length),f={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/\n$/,"").split("\n")};for(c=0;c ?/gm,""),this.token(o,n,!0),this.tokens.push({type:"blockquote_end"});continue}if(o=this.rules.list.exec(t)){t=t.substring(o[0].length),u=o[2],this.tokens.push({type:"list_start",ordered:u.length>1}),o=o[0].match(this.rules.item),i=!1,h=o.length,c=0;for(;c1&&a.length>1)&&(t=o.slice(c+1).join("\n")+t,c=h-1)),s=i||/\n\n(?!\s*$)/.test(f),c!==h-1&&(i=f.charAt(f.length-1)==="\n",s||(s=i)),this.tokens.push({type:s?"loose_item_start":"list_item_start"}),this.token(f,!1,r),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"});continue}if(o=this.rules.html.exec(t)){t=t.substring(o[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:o[1]==="pre"||o[1]==="script"||o[1]==="style",text:o[0]});continue}if(!r&&n&&(o=this.rules.def.exec(t))){t=t.substring(o[0].length),this.tokens.links[o[1].toLowerCase()]={href:o[2],title:o[3]};continue}if(n&&(o=this.rules.table.exec(t))){t=t.substring(o[0].length),f={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(c=0;c])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:f,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:f,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,n.link=a(n.link)("inside",n._inside)("href",n._href)(),n.reflink=a(n.reflink)("inside",n._inside)(),n.normal=l({},n),n.pedantic=l({},n.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),n.gfm=l({},n.normal,{escape:a(n.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:a(n.text)("]|","~]|")("|","|https?://|")()}),n.breaks=l({},n.gfm,{br:a(n.br)("{2,}","*")(),text:a(n.gfm.text)("{2,}","*")()}),r.rules=n,r.output=function(e,t,n){var i=new r(t,n);return i.output(e)},r.prototype.output=function(e){var t="",n,r,i,s;while(e){if(s=this.rules.escape.exec(e)){e=e.substring(s[0].length),t+=s[1];continue}if(s=this.rules.autolink.exec(e)){e=e.substring(s[0].length),s[2]==="@"?(r=s[1].charAt(6)===":"?this.mangle(s[1].substring(7)):this.mangle(s[1]),i=this.mangle("mailto:")+r):(r=o(s[1]),i=r),t+=this.renderer.link(i,null,r);continue}if(!this.inLink&&(s=this.rules.url.exec(e))){e=e.substring(s[0].length),r=o(s[1]),i=r,t+=this.renderer.link(i,null,r);continue}if(s=this.rules.tag.exec(e)){!this.inLink&&/^/i.test(s[0])&&(this.inLink=!1),e=e.substring(s[0].length),t+=this.options.sanitize?o(s[0]):s[0];continue}if(s=this.rules.link.exec(e)){e=e.substring(s[0].length),this.inLink=!0,t+=this.outputLink(s,{href:s[2],title:s[3]}),this.inLink=!1;continue}if((s=this.rules.reflink.exec(e))||(s=this.rules.nolink.exec(e))){e=e.substring(s[0].length),n=(s[2]||s[1]).replace(/\s+/g," "),n=this.links[n.toLowerCase()];if(!n||!n.href){t+=s[0].charAt(0),e=s[0].substring(1)+e;continue}this.inLink=!0,t+=this.outputLink(s,n),this.inLink=!1;continue}if(s=this.rules.strong.exec(e)){e=e.substring(s[0].length),t+=this.renderer.strong(this.output(s[2]||s[1]));continue}if(s=this.rules.em.exec(e)){e=e.substring(s[0].length),t+=this.renderer.em(this.output(s[2]||s[1]));continue}if(s=this.rules.code.exec(e)){e=e.substring(s[0].length),t+=this.renderer.codespan(o(s[2],!0));continue}if(s=this.rules.br.exec(e)){e=e.substring(s[0].length),t+=this.renderer.br();continue}if(s=this.rules.del.exec(e)){e=e.substring(s[0].length),t+=this.renderer.del(this.output(s[1])); continue}if(s=this.rules.text.exec(e)){e=e.substring(s[0].length),t+=o(this.smartypants(s[0]));continue}if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}return t},r.prototype.outputLink=function(e,t){var n=o(t.href),r=t.title?o(t.title):null;return e[0].charAt(0)!=="!"?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,o(e[1]))},r.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/--/g,"—").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},r.prototype.mangle=function(e){var t="",n=e.length,r=0,i;for(;r.5&&(i="x"+i.toString(16)),t+="&#"+i+";";return t},i.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);r!=null&&r!==e&&(n=!0,e=r)}return t?'
'+(n?e:o(e,!0))+"\n
\n":"
"+(n?e:o(e,!0))+"\n
"},i.prototype.blockquote=function(e){return"
\n"+e+"
\n"},i.prototype.html=function(e){return e},i.prototype.heading=function(e,t,n){return"'+e+"\n"},i.prototype.hr=function(){return this.options.xhtml?"
\n":"
\n"},i.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"\n"},i.prototype.listitem=function(e){return"
  • "+e+"
  • \n"},i.prototype.paragraph=function(e){return"

    "+e+"

    \n"},i.prototype.table=function(e,t){return"\n\n"+e+"\n"+"\n"+t+"\n"+"
    \n"},i.prototype.tablerow=function(e){return"\n"+e+"\n"},i.prototype.tablecell=function(e,t){var n=t.header?"th":"td",r=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return r+e+"\n"},i.prototype.strong=function(e){return""+e+""},i.prototype.em=function(e){return""+e+""},i.prototype.codespan=function(e){return""+e+""},i.prototype.br=function(){return this.options.xhtml?"
    ":"
    "},i.prototype.del=function(e){return""+e+""},i.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(u(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(i){return""}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0)return""}var s='
    ",s},i.prototype.image=function(e,t,n){var r=''+n+'":">",r},s.parse=function(e,t,n){var r=new s(t,n);return r.parse(e)},s.prototype.parse=function(e){this.inline=new r(e.links,this.options,this.renderer),this.tokens=e.reverse();var t="";while(this.next())t+=this.tok();return t},s.prototype.next=function(){return this.token=this.tokens.pop()},s.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},s.prototype.parseText=function(){var e=this.token.text;while(this.peek().type==="text")e+="\n"+this.next().text;return this.inline.output(e)},s.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e="",t="",n,r,i,s,o;i="";for(n=0;n