/** * 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[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=e.offsetHeight,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 typeof document.body.innerText=="string"?(t=t.replace(/ /g," "),e.innerText=t):(t=t.replace(//g,">"),t=t.replace(/\n/g,"
"),t=t.replace(/\s\s/g,"  "),e.innerHTML=t),!0}function p(){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 d(){var t=e.navigator;return t.userAgent.indexOf("Safari")>-1&&t.userAgent.indexOf("Chrome")==-1}function v(e){var t={};return e&&t.toString.call(e)==="[object Function]"}function m(){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"&&!v(e)&&(e={}),r===n&&(e=this,--n);for(;n=5||Math.abs(g.x-t.pageX)>=5)h.style.display="block",v&&clearTimeout(v),v=e.setTimeout(function(){h.style.display="none"},1e3);g={y:t.pageY,x:t.pageX}}function k(e){e.keyCode==n.settings.shortcut.modifier&&(S=!0),e.keyCode==17&&(x=!0),S===!0&&e.keyCode==n.settings.shortcut.preview&&!n.is("fullscreen")&&(e.preventDefault(),n.is("edit")?n.preview():n.edit()),S===!0&&e.keyCode==n.settings.shortcut.fullscreen&&(e.preventDefault(),n._goFullscreen(E)),S===!0&&e.keyCode!==n.settings.shortcut.modifier&&(S=!1),e.keyCode==27&&n.is("fullscreen")&&n._exitFullscreen(E),x===!0&&e.keyCode==83&&(n.save(),e.preventDefault(),x=!1),e.metaKey&&e.keyCode==83&&(n.save(),e.preventDefault())}function L(e){e.keyCode==n.settings.shortcut.modifier&&(S=!1),e.keyCode==17&&(x=!1)}if(this.is("loaded"))return this;var n=this,o,u,f,c,h,v,m,g={y:-1,x:-1},y,b,w=!1,E,S=!1,x=!1,T,N;n.settings.useNativeFullscreen&&(w=document.body.webkitRequestFullScreen?!0:!1),d()&&(w=!1),!n.is("edit")&&!n.is("preview")&&(n._eeState.edit=!0),t=t||function(){},o={chrome:'
'+' '+''+"
"+"
",previewer:'
'},n.element.innerHTML='',n.element.style.height=n.element.offsetHeight+"px",u=document.getElementById(n._instanceId),n.iframeElement=u,n.iframe=l(u),n.iframe.open(),n.iframe.write(o.chrome),n.editorIframe=n.iframe.getElementById("epiceditor-editor-frame"),n.previewerIframe=n.iframe.getElementById("epiceditor-previewer-frame"),n.editorIframeDocument=l(n.editorIframe),n.editorIframeDocument.open(),n.editorIframeDocument.write(""),n.editorIframeDocument.close(),n.previewerIframeDocument=l(n.previewerIframe),n.previewerIframeDocument.open(),n.previewerIframeDocument.write(o.previewer),f=n.previewerIframeDocument.createElement("base"),f.target="_blank",n.previewerIframeDocument.getElementsByTagName("head")[0].appendChild(f),n.previewerIframeDocument.close(),n.reflow(),a(n.settings.basePath+n.settings.theme.base,n.iframe,"theme"),a(n.settings.basePath+n.settings.theme.editor,n.editorIframeDocument,"theme"),a(n.settings.basePath+n.settings.theme.preview,n.previewerIframeDocument,"theme"),n.iframe.getElementById("epiceditor-wrapper").style.position="relative",n.editor=n.editorIframeDocument.body,n.previewer=n.previewerIframeDocument.getElementById("epiceditor-preview"),n.editor.contentEditable=!0,n.iframe.body.style.height=this.element.offsetHeight+"px",this.previewerIframe.style.display="none",p()>-1&&(this.previewer.style.height=parseInt(i(this.previewer,"height"),10)+2),this.open(n.settings.file.name),n.settings.focusOnLoad&&n.iframe.addEventListener("readystatechange",function(){n.iframe.readyState=="complete"&&n.editorIframeDocument.body.focus()}),c=n.iframe.getElementById("epiceditor-utilbar"),y={},n._goFullscreen=function(t){if(n.is("fullscreen")){n._exitFullscreen(t);return}w&&t.webkitRequestFullScreen(),b=n.is("edit"),n._eeState.fullscreen=!0,n._eeState.edit=!0,n._eeState.preview=!0;var r=e.innerWidth,o=e.innerHeight,u=e.outerWidth,a=e.outerHeight;w||(a=e.innerHeight),y.editorIframe=s(n.editorIframe,"save",{width:u/2+"px",height:a+"px","float":"left",cssFloat:"left",styleFloat:"left",display:"block"}),y.previewerIframe=s(n.previewerIframe,"save",{width:u/2+"px",height:a+"px","float":"right",cssFloat:"right",styleFloat:"right",display:"block"}),y.element=s(n.element,"save",{position:"fixed",top:"0",left:"0",width:"100%","z-index":"9999",zIndex:"9999",border:"none",margin:"0",background:i(n.editor,"background-color"),height:o+"px"}),y.iframeElement=s(n.iframeElement,"save",{width:u+"px",height:o+"px"}),c.style.visibility="hidden",w||(document.body.style.overflow="hidden"),n.preview(),n.editorIframeDocument.body.focus(),n.emit("fullscreenenter")},n._exitFullscreen=function(e){s(n.element,"apply",y.element),s(n.iframeElement,"apply",y.iframeElement),s(n.editorIframe,"apply",y.editorIframe),s(n.previewerIframe,"apply",y.previewerIframe),n.element.style.width=n._eeState.reflowWidth?n._eeState.reflowWidth:"",n.element.style.height=n._eeState.reflowHeight?n._eeState.reflowHeight:"",c.style.visibility="visible",w?document.webkitCancelFullScreen():document.body.style.overflow="auto",n._eeState.fullscreen=!1,b?n.edit():n.preview(),n.reflow(),n.emit("fullscreenexit")},n.editor.addEventListener("keyup",function(){m&&e.clearTimeout(m),m=e.setTimeout(function(){n.is("fullscreen")&&n.preview()},250)}),E=n.iframeElement,c.addEventListener("click",function(e){var t=e.target.className;t.indexOf("epiceditor-toggle-preview-btn")>-1?n.preview():t.indexOf("epiceditor-toggle-edit-btn")>-1?n.edit():t.indexOf("epiceditor-fullscreen-btn")>-1&&n._goFullscreen(E)}),document.body.webkitRequestFullScreen&&E.addEventListener("webkitfullscreenchange",function(){document.webkitIsFullScreen||n._exitFullscreen(E)},!1),h=n.iframe.getElementById("epiceditor-utilbar"),h.style.display="none",h.addEventListener("mouseover",function(){v&&clearTimeout(v)}),T=[n.previewerIframeDocument,n.editorIframeDocument];for(N=0;N"+t.lexer(e[1])+"":''+f(e[1])+'"}function s(){return i=r.pop()}function o(){switch(i.type){case"space":return"";case"hr":return"
\n";case"heading":return""+t.lexer(i.text)+"\n";case"code":return v.highlight&&(i.code=v.highlight(i.text,i.lang),i.code!=null&&i.code!==i.text&&(i.escaped=!0,i.text=i.code)),i.escaped||(i.text=f(i.text,!0)),"
"+i.text+"
\n";case"blockquote_start":var e="";while(s().type!=="blockquote_end")e+=o();return"
\n"+e+"
\n";case"list_start":var n=i.ordered?"ol":"ul",e="";while(s().type!=="list_end")e+=o();return"<"+n+">\n"+e+"\n";case"list_item_start":var e="";while(s().type!=="list_item_end")e+=i.type==="text"?u():o();return"
  • "+e+"
  • \n";case"loose_item_start":var e="";while(s().type!=="list_item_end")e+=o();return"
  • "+e+"
  • \n";case"html":return v.sanitize?t.lexer(i.text):!i.pre&&!v.pedantic?t.lexer(i.text):i.text;case"paragraph":return"

    "+t.lexer(i.text)+"

    \n";case"text":return"

    "+u()+"

    \n"}}function u(){var e=i.text,n;while((n=r[r.length-1])&&n.type==="text")e+="\n"+s().text;return t.lexer(e)}function a(e){r=e.reverse();var t="";while(s())t+=o();return r=null,i=null,t}function f(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function l(e){var t="",n=e.length,r=0,i;for(;r.5&&(i="x"+i.toString(16)),t+="&#"+i+";";return t}function c(){var e="(?!(?: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+";return e}function h(e,t){return e=e.source,t=t||"",function n(r,i){return r?(e=e.replace(r,i.source||i),n):new RegExp(e,t)}}function p(){}function d(t,n){return g(n),a(e.lexer(t))}function g(n){n||(n=m);if(v===n)return;v=n,v.gfm?(e.fences=e.gfm.fences,e.paragraph=e.gfm.paragraph,t.text=t.gfm.text,t.url=t.gfm.url):(e.fences=e.normal.fences,e.paragraph=e.normal.paragraph,t.text=t.normal.text,t.url=t.normal.url),v.pedantic?(t.em=t.pedantic.em,t.strong=t.pedantic.strong):(t.em=t.normal.em,t.strong=t.normal.strong)}var e={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:p,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,lheading:/^([^\n]+)\n *(=|-){3,} *\n*/,blockquote:/^( *>[^\n]+(\n[^\n]+)*\n*)+/,list:/^( *)(bull) [^\0]+?(?:hr|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,def:/^ *\[([^\]]+)\]: *([^\s]+)(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,paragraph:/^([^\n]+\n?(?!body))+\n*/,text:/^[^\n]+/};e.bullet=/(?:[*+-]|\d+\.)/,e.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,e.item=h(e.item,"gm")(/bull/g,e.bullet)(),e.list=h(e.list)(/bull/g,e.bullet)("hr",/\n+(?=(?: *[-*_]){3,} *(?:\n+|$))/)(),e.html=h(e.html)("comment",//)("closed",/<(tag)[^\0]+?<\/\1>/)("closing",/])*?>/)(/tag/g,c())(),e.paragraph=function(){var t=e.paragraph.source,n=[];return function r(t){return t=e[t]?e[t].source:t,n.push(t.replace(/(^|[^\[])\^/g,"$1")),r}("hr")("heading")("lheading")("blockquote")("<"+c())("def"),new RegExp(t.replace("body",n.join("|")))}(),e.normal={fences:e.fences,paragraph:e.paragraph},e.gfm={fences:/^ *``` *(\w+)? *\n([^\0]+?)\s*``` *(?:\n+|$)/,paragraph:/^/},e.gfm.paragraph=h(e.paragraph)("(?!","(?!"+e.gfm.fences.source.replace(/(^|[^\[])\^/g,"$1")+"|")(),e.lexer=function(t){var n=[];return n.links={},t=t.replace(/\r\n|\r/g,"\n").replace(/\t/g," "),e.token(t,n,!0)},e.token=function(t,n,r){var t=t.replace(/^ +$/gm,""),i,s,o,u,a,f,l;while(t){if(o=e.newline.exec(t))t=t.substring(o[0].length),o[0].length>1&&n.push({type:"space"});if(o=e.code.exec(t)){t=t.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),n.push({type:"code",text:v.pedantic?o:o.replace(/\n+$/,"")});continue}if(o=e.fences.exec(t)){t=t.substring(o[0].length),n.push({type:"code",lang:o[1],text:o[2]});continue}if(o=e.heading.exec(t)){t=t.substring(o[0].length),n.push({type:"heading",depth:o[1].length,text:o[2]});continue}if(o=e.lheading.exec(t)){t=t.substring(o[0].length),n.push({type:"heading",depth:o[2]==="="?1:2,text:o[1]});continue}if(o=e.hr.exec(t)){t=t.substring(o[0].length),n.push({type:"hr"});continue}if(o=e.blockquote.exec(t)){t=t.substring(o[0].length),n.push({type:"blockquote_start"}),o=o[0].replace(/^ *> ?/gm,""),e.token(o,n,r),n.push({type:"blockquote_end"});continue}if(o=e.list.exec(t)){t=t.substring(o[0].length),n.push({type:"list_start",ordered:isFinite(o[2])}),o=o[0].match(e.item),i=!1,l=o.length,f=0;for(;f])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:p,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([^\0]+?)__(?!_)|^\*\*([^\0]+?)\*\*(?!\*)/,em:/^\b_((?:__|[^\0])+?)_\b|^\*((?:\*\*|[^\0])+?)\*(?!\*)/,code:/^(`+)([^\0]*?[^`])\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,text:/^[^\0]+?(?=[\\?(?:\s+['"]([^\0]*?)['"])?\s*/,t.link=h(t.link)("inside",t._linkInside)("href",t._linkHref)(),t.reflink=h(t.reflink)("inside",t._linkInside)(),t.normal={url:t.url,strong:t.strong,em:t.em,text:t.text},t.pedantic={strong:/^__(?=\S)([^\0]*?\S)__(?!_)|^\*\*(?=\S)([^\0]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([^\0]*?\S)_(?!_)|^\*(?=\S)([^\0]*?\S)\*(?!\*)/},t.gfm={url:/^(https?:\/\/[^\s]+[^.,:;"')\]\s])/,text:/^[^\0]+?(?=[\\'+u+"";continue}if(c=t.url.exec(e)){e=e.substring(c[0].length),u=f(c[1]),a=u,i+=''+u+"";continue}if(c=t.tag.exec(e)){e=e.substring(c[0].length),i+=v.sanitize?f(c[0]):c[0];continue}if(c=t.link.exec(e)){e=e.substring(c[0].length),i+=n(c,{href:c[2],title:c[3]});continue}if((c=t.reflink.exec(e))||(c=t.nolink.exec(e))){e=e.substring(c[0].length),o=(c[2]||c[1]).replace(/\s+/g," "),o=s[o.toLowerCase()];if(!o||!o.href){i+=c[0][0],e=c[0].substring(1)+e;continue}i+=n(c,o);continue}if(c=t.strong.exec(e)){e=e.substring(c[0].length),i+=""+t.lexer(c[2]||c[1])+"";continue}if(c=t.em.exec(e)){e=e.substring(c[0].length),i+=""+t.lexer(c[2]||c[1])+"";continue}if(c=t.code.exec(e)){e=e.substring(c[0].length),i+=""+f(c[2],!0)+"";continue}if(c=t.br.exec(e)){e=e.substring(c[0].length),i+="
    ";continue}if(c=t.text.exec(e)){e=e.substring(c[0].length),i+=f(c[0]);continue}}return i};var r,i;p.exec=p;var v,m;d.options=d.setOptions=function(e){return m=e,g(e),d},d.setOptions({gfm:!0,pedantic:!1,sanitize:!1,highlight:null}),d.parser=function(e,t){return g(t),a(e)},d.lexer=function(t,n){return g(n),e.lexer(t)},d.parse=d,typeof module!="undefined"?module.exports=d:this.marked=d}.call(function(){return this||(typeof window!="undefined"?window:global)}());