Ctrl+Q",quoteexample:"Blockquote",code:"Code Sample Ctrl+K",codeexample:"enter code here",image:"Image Ctrl+G",imagedescription:"enter image description here",imagedialog:"Insert Image
http://example.com/images/diagram.jpg \"optional title\"
Need free image hosting?
",olist:"Numbered List Ctrl+O",ulist:"Bulleted List Ctrl+U",litem:"List item",heading:"Heading / Ctrl+H",headingexample:"Heading",hr:"Horizontal Rule
Ctrl+R",undo:"Undo - Ctrl+Z",redo:"Redo - Ctrl+Y",redomac:"Redo - Ctrl+Shift+Z",help:"Markdown Editing Help"},f="http://",l="http://";Markdown.Editor=function(e,t,n){n=n||{},typeof n.handler=="function"&&(n={helpButton:n}),n.strings=n.strings||{},n.helpButton&&(n.strings.help=n.strings.help||n.helpButton.title);var i=function(e){return n.strings[e]||a[e]};t=t||"";var s=this.hooks=new Markdown.HookCollection;s.addNoop("onPreviewRefresh"),s.addNoop("postBlockquoteCreation"),s.addFalse("insertImageDialog"),s.addFalse("insertLinkDialog"),this.getConverter=function(){return e};var o=this,u;this.run=function(){if(u)return;u=new h(t);var a=new g(s,i),f=new v(e,u,function(){s.onPreviewRefresh()}),l,c;/\?noundo/.test(r.location.href)||(l=new p(function(){f.refresh(),c&&c.setUndoRedoButtonStates()},u),this.textOperation=function(e){l.setCommandMode(),e(),o.refreshPreview()}),c=new m(t,u,l,f,a,n.helpButton,i),c.setUndoRedoButtonStates();var d=o.refreshPreview=function(){f.refresh(!0)};d()}},c.prototype.findTags=function(t,n){var r=this,i;t&&(i=e.extendRegExp(t,"","$"),this.before=this.before.replace(i,function(e){return r.startTag=r.startTag+e,""}),i=e.extendRegExp(t,"^",""),this.selection=this.selection.replace(i,function(e){return r.startTag=r.startTag+e,""})),n&&(i=e.extendRegExp(n,"","$"),this.selection=this.selection.replace(i,function(e){return r.endTag=e+r.endTag,""}),i=e.extendRegExp(n,"^",""),this.after=this.after.replace(i,function(e){return r.endTag=e+r.endTag,""}))},c.prototype.trimWhitespace=function(e){var t,n,r=this;e?t=n="":(t=function(e){return r.before+=e,""},n=function(e){return r.after=e+r.after,""}),this.selection=this.selection.replace(/^(\s*)/,t).replace(/(\s*)$/,n)},c.prototype.skipLines=function(e,t,n){e===undefined&&(e=1),t===undefined&&(t=1),e++,t++;var r,s;navigator.userAgent.match(/Chrome/)&&"X".match(/()./),this.selection=this.selection.replace(/(^\n*)/,""),this.startTag=this.startTag+i.$1,this.selection=this.selection.replace(/(\n*$)/,""),this.endTag=this.endTag+i.$1,this.startTag=this.startTag.replace(/(^\n*)/,""),this.before=this.before+i.$1,this.endTag=this.endTag.replace(/(\n*$)/,""),this.after=this.after+i.$1;if(this.before){r=s="";while(e--)r+="\\n?",s+="\n";n&&(r="\\n*"),this.before=this.before.replace(new i(r+"$",""),s)}if(this.after){r=s="";while(t--)r+="\\n?",s+="\n";n&&(r="\\n*"),this.after=this.after.replace(new i(r,""),s)}},e.isVisible=function(e){if(window.getComputedStyle)return window.getComputedStyle(e,null).getPropertyValue("display")!=="none";if(e.currentStyle)return e.currentStyle.display!=="none"},e.addEvent=function(e,t,n){e.attachEvent?e.attachEvent("on"+t,n):e.addEventListener(t,n,!1)},e.removeEvent=function(e,t,n){e.detachEvent?e.detachEvent("on"+t,n):e.removeEventListener(t,n,!1)},e.fixEolChars=function(e){return e=e.replace(/\r\n/g,"\n"),e=e.replace(/\r/g,"\n"),e},e.extendRegExp=function(e,t,n){if(t===null||t===undefined)t="";if(n===null||n===undefined)n="";var r=e.toString(),s;return r=r.replace(/\/([gim]*)$/,function(e,t){return s=t,""}),r=r.replace(/(^\/|\/$)/g,""),r=t+r+n,new i(r,s)},t.getTop=function(e,t){var n=e.offsetTop;if(!t)while(e=e.offsetParent)n+=e.offsetTop;return n},t.getHeight=function(e){return e.offsetHeight||e.scrollHeight},t.getWidth=function(e){return e.offsetWidth||e.scrollWidth},t.getPageSize=function(){var e,t,n,i;self.innerHeight&&self.scrollMaxY?(e=r.body.scrollWidth,t=self.innerHeight+self.scrollMaxY):r.body.scrollHeight>r.body.offsetHeight?(e=r.body.scrollWidth,t=r.body.scrollHeight):(e=r.body.offsetWidth,t=r.body.offsetHeight),self.innerHeight?(n=self.innerWidth,i=self.innerHeight):r.documentElement&&r.documentElement.clientHeight?(n=r.documentElement.clientWidth,i=r.documentElement.clientHeight):r.body&&(n=r.body.clientWidth,i=r.body.clientHeight);var s=Math.max(e,n),o=Math.max(t,i);return[s,o,n,i]},n.createBackground=function(){var e=r.createElement("div"),n=e.style;e.className="wmd-prompt-background",n.position="absolute",n.top="0",n.zIndex="1000",u.isIE?n.filter="alpha(opacity=50)":n.opacity="0.5";var i=t.getPageSize();return n.height=i[1]+"px",u.isIE?(n.left=r.documentElement.scrollLeft,n.width=r.documentElement.clientWidth):(n.left="0",n.width="100%"),r.body.appendChild(e),e},n.prompt=function(n,i,s){var o,a;i===undefined&&(i="");var f=function(e){var t=e.charCode||e.keyCode;t===27&&l(!0)},l=function(t){e.removeEvent(r.body,"keydown",f);var n=a.value;return t?n=null:(n=n.replace(/^http:\/\/(https?|ftp):\/\//,"$1://"),/^(?:https?|ftp):\/\//.test(n)||(n="http://"+n)),o.parentNode.removeChild(o),s(n),!1},c=function(){o=r.createElement("div"),o.className="wmd-prompt-dialog",o.style.padding="10px;",o.style.position="fixed",o.style.width="400px",o.style.zIndex="1001";var s=r.createElement("div");s.innerHTML=n,s.style.padding="5px",o.appendChild(s);var c=r.createElement("form"),h=c.style;c.onsubmit=function(){return l(!1)},h.padding="0",h.margin="0",h.cssFloat="left",h.width="100%",h.textAlign="center",h.position="relative",o.appendChild(c),a=r.createElement("input"),a.type="text",a.value=i,h=a.style,h.display="block",h.width="80%",h.marginLeft=h.marginRight="auto",c.appendChild(a);var p=r.createElement("input");p.type="button",p.onclick=function(){return l(!1)},p.value="OK",h=p.style,h.margin="10px",h.display="inline",h.width="7em";var d=r.createElement("input");d.type="button",d.onclick=function(){return l(!0)},d.value="Cancel",h=d.style,h.margin="10px",h.display="inline",h.width="7em",c.appendChild(p),c.appendChild(d),e.addEvent(r.body,"keydown",f),o.style.top="50%",o.style.left="50%",o.style.display="block",u.isIE_5or6&&(o.style.position="absolute",o.style.top=r.documentElement.scrollTop+200+"px",o.style.left="50%"),r.body.appendChild(o),o.style.marginTop=-(t.getHeight(o)/2)+"px",o.style.marginLeft=-(t.getWidth(o)/2)+"px"};setTimeout(function(){c();var e=i.length;if(a.selectionStart!==undefined)a.selectionStart=0,a.selectionEnd=e;else if(a.createTextRange){var t=a.createTextRange();t.collapse(!1),t.moveStart("character",-e),t.moveEnd("character",e),t.select()}a.focus()},0)};var y=g.prototype;y.prefixes="(?:\\s{4,}|\\s*>|\\s*-\\s+|\\s*\\d+\\.|=|\\+|-|_|\\*|#|\\s*\\[[^\n]]+\\]:)",y.unwrap=function(e){var t=new i("([^\\n])\\n(?!(\\n|"+this.prefixes+"))","g");e.selection=e.selection.replace(t,"$1 $2")},y.wrap=function(e,t){this.unwrap(e);var n=new i("(.{1,"+t+"})( +|$\\n?)","gm"),r=this;e.selection=e.selection.replace(n,function(e,t){return(new i("^"+r.prefixes,"")).test(e)?e:t+"\n"}),e.selection=e.selection.replace(/\s+$/,"")},y.doBold=function(e,t){return this.doBorI(e,t,2,this.getString("boldexample"))},y.doItalic=function(e,t){return this.doBorI(e,t,1,this.getString("italicexample"))},y.doBorI=function(e,t,n,r){e.trimWhitespace(),e.selection=e.selection.replace(/\n{2,}/g,"\n");var s=/(\**$)/.exec(e.before)[0],o=/(^\**)/.exec(e.after)[0],u=Math.min(s.length,o.length);if(u>=n&&(u!=2||n!=1))e.before=e.before.replace(i("[*]{"+n+"}$",""),""),e.after=e.after.replace(i("^[*]{"+n+"}",""),"");else if(!e.selection&&o){e.after=e.after.replace(/^([*_]*)/,""),e.before=e.before.replace(/(\s?)$/,"");var a=i.$1;e.before=e.before+o+a}else{!e.selection&&!o&&(e.selection=r);var f=n<=1?"*":"**";e.before=e.before+f,e.after=f+e.after}return},y.stripLinkDefs=function(e,t){return e=e.replace(/^[ ]{0,3}\[(\d+)\]:[ \t]*\n?[ \t]*(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|$)/gm,function(e,n,r,i,s){return t[n]=e.replace(/\s*$/,""),i?(t[n]=e.replace(/["(](.+?)[")]$/,""),i+s):""}),e},y.addLinkDef=function(e,t){var n=0,r={};e.before=this.stripLinkDefs(e.before,r),e.selection=this.stripLinkDefs(e.selection,r),e.after=this.stripLinkDefs(e.after,r);var i="",s=/(\[)((?:\[[^\]]*\]|[^\[\]])*)(\][ ]?(?:\n[ ]*)?\[)(\d+)(\])/g,o=function(e){n++,e=e.replace(/^[ ]{0,3}\[(\d+)\]:/," ["+n+"]:"),i+="\n"+e},u=function(e,t,i,a,f,l){return i=i.replace(s,u),r[f]?(o(r[f]),t+i+a+n+l):e};e.before=e.before.replace(s,u),t?o(t):e.selection=e.selection.replace(s,u);var a=n;return e.after=e.after.replace(s,u),e.after&&(e.after=e.after.replace(/\n*$/,"")),e.after||(e.selection=e.selection.replace(/\n*$/,"")),e.after+="\n\n"+i,a},y.doLinkOrImage=function(e,t,r){e.trimWhitespace(),e.findTags(/\s*!?\[/,/\][ ]?(?:\n[ ]*)?(\[.*?\])?/);var i;if(!(e.endTag.length>1&&e.startTag.length>0)){e.selection=e.startTag+e.selection+e.endTag,e.startTag=e.endTag="";if(/\n\n/.test(e.selection)){this.addLinkDef(e,null);return}var s=this,o=function(n){i.parentNode.removeChild(i);if(n!==null){e.selection=(" "+e.selection).replace(/([^\\](?:\\\\)*)(?=[[\]])/g,"$1\\").substr(1);var o=" [999]: "+b(n),u=s.addLinkDef(e,o);e.startTag=r?"![":"[",e.endTag="]["+u+"]",e.selection||(r?e.selection=s.getString("imagedescription"):e.selection=s.getString("linkdescription"))}t()};return i=n.createBackground(),r?this.hooks.insertImageDialog(o)||n.prompt(this.getString("imagedialog"),f,o):this.hooks.insertLinkDialog(o)||n.prompt(this.getString("linkdialog"),l,o),!0}e.startTag=e.startTag.replace(/!?\[/,""),e.endTag="",this.addLinkDef(e,null)},y.doAutoindent=function(e,t){var n=this,r=!1;e.before=e.before.replace(/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]*\n$/,"\n\n"),e.before=e.before.replace(/(\n|^)[ ]{0,3}>[ \t]*\n$/,"\n\n"),e.before=e.before.replace(/(\n|^)[ \t]+\n$/,"\n\n"),!e.selection&&!/^[ \t]*(?:\n|$)/.test(e.after)&&(e.after=e.after.replace(/^[^\n]*/,function(t){return e.selection=t,""}),r=!0),/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]+.*\n$/.test(e.before)&&n.doList&&n.doList(e),/(\n|^)[ ]{0,3}>[ \t]+.*\n$/.test(e.before)&&n.doBlockquote&&n.doBlockquote(e),/(\n|^)(\t|[ ]{4,}).*\n$/.test(e.before)&&n.doCode&&n.doCode(e),r&&(e.after=e.selection+e.after,e.selection="")},y.doBlockquote=function(e,t){e.selection=e.selection.replace(/^(\n*)([^\r]+?)(\n*)$/,function(t,n,r,i){return e.before+=n,e.after=i+e.after,r}),e.before=e.before.replace(/(>[ \t]*)$/,function(t,n){return e.selection=n+e.selection,""}),e.selection=e.selection.replace(/^(\s|>)+$/,""),e.selection=e.selection||this.getString("quoteexample");var n="",r="",i;if(e.before){var s=e.before.replace(/\n$/,"").split("\n"),u=!1;for(var a=0;a0,/^>/.test(i)?(f=!0,!u&&i.length>1&&(u=!0)):/^[ \t]*$/.test(i)?f=!0:f=u,f?n+=i+"\n":(r+=n+i,n="\n")}/(^|\n)>/.test(n)||(r+=n,n="")}e.startTag=n,e.before=r,e.after&&(e.after=e.after.replace(/^\n?/,"\n")),e.after=e.after.replace(/^(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*)/,function(t){return e.endTag=t,""});var l=function(t){var n=t?"> ":"";e.startTag&&(e.startTag=e.startTag.replace(/\n((>|\s)*)\n$/,function(e,t){return"\n"+t.replace(/^[ ]{0,3}>?[ \t]*$/gm,n)+"\n"})),e.endTag&&(e.endTag=e.endTag.replace(/^\n((>|\s)*)\n/,function(e,t){return"\n"+t.replace(/^[ ]{0,3}>?[ \t]*$/gm,n)+"\n"}))};/^(?![ ]{0,3}>)/m.test(e.selection)?(this.wrap(e,o.lineLength-2),e.selection=e.selection.replace(/^/gm,"> "),l(!0),e.skipLines()):(e.selection=e.selection.replace(/^[ ]{0,3}> ?/gm,""),this.unwrap(e),l(!1),!/^(\n|^)[ ]{0,3}>/.test(e.selection)&&e.startTag&&(e.startTag=e.startTag.replace(/\n{0,2}$/,"\n\n")),!/(\n|^)[ ]{0,3}>.*$/.test(e.selection)&&e.endTag&&(e.endTag=e.endTag.replace(/^\n{0,2}/,"\n\n"))),e.selection=this.hooks.postBlockquoteCreation(e.selection),/\n/.test(e.selection)||(e.selection=e.selection.replace(/^(> *)/,function(t,n){return e.startTag+=n,""}))},y.doCode=function(e,t){var n=/\S[ ]*$/.test(e.before),r=/^[ ]*\S/.test(e.after);if(!r&&!n||/\n/.test(e.selection)){e.before=e.before.replace(/[ ]{4}$/,function(t){return e.selection=t+e.selection,""});var i=1,s=1;/(\n|^)(\t|[ ]{4,}).*\n$/.test(e.before)&&(i=0),/^\n(\t|[ ]{4,})/.test(e.after)&&(s=0),e.skipLines(i,s),e.selection?/^[ ]{0,3}\S/m.test(e.selection)?/\n/.test(e.selection)?e.selection=e.selection.replace(/^/gm," "):e.before+=" ":e.selection=e.selection.replace(/^(?:[ ]{4}|[ ]{0,3}\t)/gm,""):(e.startTag=" ",e.selection=this.getString("codeexample"))}else e.trimWhitespace(),e.findTags(/`/,/`/),!e.startTag&&!e.endTag?(e.startTag=e.endTag="`",e.selection||(e.selection=this.getString("codeexample"))):e.endTag&&!e.startTag?(e.before+=e.endTag,e.endTag=""):e.startTag=e.endTag=""},y.doList=function(e,t,n){var r=/(\n|^)(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*$/,s=/^\n*(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*/,u="-",a=1,f=function(){var e;return n?(e=" "+a+". ",a++):e=" "+u+" ",e},l=function(e){return n===undefined&&(n=/^\s*\d/.test(e)),e=e.replace(/^[ ]{0,3}([*+-]|\d+[.])\s/gm,function(e){return f()}),e};e.findTags(/(\n|^)*[ ]{0,3}([*+-]|\d+[.])\s+/,null),e.before&&!/\n$/.test(e.before)&&!/^\n/.test(e.startTag)&&(e.before+=e.startTag,e.startTag="");if(e.startTag){var c=/\d+[.]/.test(e.startTag);e.startTag="",e.selection=e.selection.replace(/\n[ ]{4}/g,"\n"),this.unwrap(e),e.skipLines(),c&&(e.after=e.after.replace(s,l));if(n==c)return}var h=1;e.before=e.before.replace(r,function(e){return/^\s*([*+-])/.test(e)&&(u=i.$1),h=/[^\n]\n\n[^\n]/.test(e)?1:0,l(e)}),e.selection||(e.selection=this.getString("litem"));var p=f(),d=1;e.after=e.after.replace(s,function(e){return d=/[^\n]\n\n[^\n]/.test(e)?1:0,l(e)}),e.trimWhitespace(!0),e.skipLines(h,d,!0),e.startTag=p;var v=p.replace(/./g," ");this.wrap(e,o.lineLength-v.length),e.selection=e.selection.replace(/\n/g,"\n"+v)},y.doHeading=function(e,t){e.selection=e.selection.replace(/\s+/g," "),e.selection=e.selection.replace(/(^\s+|\s+$)/g,"");if(!e.selection){e.startTag="## ",e.selection=this.getString("headingexample"),e.endTag=" ##";return}var n=0;e.findTags(/#+[ ]*/,/[ ]*#+/),/#+/.test(e.startTag)&&(n=i.lastMatch.length),e.startTag=e.endTag="",e.findTags(null,/\s?(-+|=+)/),/=+/.test(e.endTag)&&(n=1),/-+/.test(e.endTag)&&(n=2),e.startTag=e.endTag="",e.skipLines(1,1);var r=n==0?2:n-1;if(r>0){var s=r>=2?"-":"=",u=e.selection.length;u>o.lineLength&&(u=o.lineLength),e.endTag="\n";while(u--)e.endTag+=s}},y.doHorizontalRule=function(e,t){e.startTag="----------\n",e.selection="",e.skipLines(2,1,!0)}}(),define("Markdown.Editor",function(){});var GOOGLE_SCOPES=["https://www.googleapis.com/auth/drive.install","https://www.googleapis.com/auth/drive","https://www.googleapis.com/auth/blogger"],GOOGLE_DRIVE_APP_ID="241271498917",DROPBOX_APP_KEY="lq6mwopab8wskas",DROPBOX_APP_SECRET="851fgnucpezy84t",DEFAULT_FILE_TITLE="Title",GDRIVE_DEFAULT_FILE_TITLE="New Markdown document",CHECK_ONLINE_PERIOD=6e4,AJAX_TIMEOUT=1e4,ASYNC_TASK_DEFAULT_TIMEOUT=3e4,AUTH_POPUP_TIMEOUT=9e4,SYNC_PERIOD=18e4,USER_IDLE_THRESHOLD=3e5,SYNC_PROVIDER_GDRIVE="sync.gdrive.",SYNC_PROVIDER_DROPBOX="sync.dropbox.",PROVIDER_TYPE_PUBLISH_FLAG=1,PROVIDER_GITHUB="github",PROVIDER_BLOGGER="blogger",delayedFunction=undefined,BASE_URL="http://localhost/",GOOGLE_KEY="AIzaSyAeCU8CGcSkn0z9js6iocHuPBX4f_mMWkw",GOOGLE_CLIENT_ID="241271498917-lev37kef013q85avc91am1gccg5g8lrb.apps.googleusercontent.com",GITHUB_CLIENT_ID="e47fef6055344579799d",GATEKEEPER_URL="http://stackedit-gatekeeper-localhost.herokuapp.com/";location.hostname.indexOf("benweet.github.io")===0&&(BASE_URL="http://benweet.github.io/stackedit/",GOOGLE_KEY="AIzaSyB1Bc1wI_YUWkkOR-5Gri5BFuypgZl0Sxc",GOOGLE_CLIENT_ID="241271498917-jpto9lls9fqnem1e4h6ppds9uob8rpvu.apps.googleusercontent.com",GITHUB_CLIENT_ID="fa0d09514da8377ee32e",GATEKEEPER_URL="http://stackedit-gatekeeper.herokuapp.com/"),define("config",function(){}),define("core",["jquery","file-manager","google-helper","dropbox-helper","github-helper","synchronizer","publisher","async-runner","bootstrap","jgrowl","layout","Markdown.Editor","config","underscore"],function(e,t,n,r,i,s,o,u){function l(){a.currentTime=(new Date).getTime()}function v(){c=!0,h=!0,d=a.currentTime}function m(){return h===!0&&a.currentTime-d>USER_IDLE_THRESHOLD&&(h=!1),h&&p}function y(e,t){e.stop(!0,!0).addClass("error").delay(400).switchClass("error"),t!==undefined&&t.stopPropagation()}function E(){a.isOffline===!0&&navigator.onLine===!0&&b+CHECK_ONLINE_PERIODr?(y(e,t),undefined):i)},a.resetModalInputs=function(){e(".modal input[type=text]:not([disabled])").val("")},a.showWorkingIndicator=function(t){t===!1?(e(".working-indicator").addClass("hide"),e("body").removeClass("working")):(e(".working-indicator").removeClass("hide"),e("body").addClass("working"))},a.showMessage=function(t,n,r){r=r||{},n=n||"icon-info-sign",e.jGrowl(" "+_.escape(t),r)},a.showError=function(e){a.showMessage(e,"icon-warning-sign")},a.isOffline=!1;var b=a.currentTime,w=[];a.setOffline=function(){b=a.currentTime;if(a.isOffline===!1){a.isOffline=!0,a.showMessage("You are offline.","icon-exclamation-sign msg-offline",{sticky:!0,close:function(){a.showMessage("You are back online!","icon-signal")}});for(var e=0;e\n","\n","\n","<%= documentTitle %>\n","\n","<%= documentHTML %>\n",""].join("")},a.loadSettings=function(){localStorage.settings&&e.extend(a.settings,JSON.parse(localStorage.settings)),e("input:radio[name=radio-layout-orientation][value="+a.settings.layoutOrientation+"]").prop("checked",!0),e("#input-settings-editor-font-size").val(a.settings.editorFontSize),e("#input-settings-publish-commit-msg").val(a.settings.commitMsg),e("#textarea-settings-publish-template").val(a.settings.template)},a.saveSettings=function(t){var n={};n.layoutOrientation=e("input:radio[name=radio-layout-orientation]:checked").prop("value"),n.editorFontSize=a.getInputIntValue(e("#input-settings-editor-font-size"),t,1,99),n.commitMsg=a.getInputValue(e("#input-settings-publish-commit-msg"),t),n.template=a.getInputValue(e("#textarea-settings-publish-template"),t),t.isPropagationStopped()||(a.settings=n,localStorage.settings=JSON.stringify(n))},a.createLayout=function(){var t=undefined,n={closable:!0,resizable:!1,slidable:!1,livePaneResizing:!0,enableCursorHotkey:!1,spacing_open:15,spacing_closed:15,togglerLength_open:90,togglerLength_closed:90,stateManagement__enabled:!1};a.settings.layoutOrientation=="horizontal"?(e(".ui-layout-south").remove(),e(".ui-layout-east").addClass("well").prop("id","wmd-preview"),t=e("body").layout(e.extend(n,{east__resizable:!0,east__size:.5,east__minSize:200}))):a.settings.layoutOrientation=="vertical"&&(e(".ui-layout-east").remove(),e(".ui-layout-south").addClass("well").prop("id","wmd-preview"),t=e("body").layout(e.extend(n,{south__resizable:!0,south__size:.5,south__minSize:200}))),e(".ui-layout-toggler-north").addClass("btn").append(e("").addClass("caret")),e(".ui-layout-toggler-south").addClass("btn").append(e("").addClass("caret")),e(".ui-layout-toggler-east").addClass("btn").append(e("").addClass("caret")),e("#navbar").click(function(){t.allowOverflow("north")})};var S=undefined;a.createEditor=function(t){e("#wmd-button-bar").empty();var n=Markdown.getSanitizingConverter(),r=!0;n.hooks.chain("preConversion",function(e){return r||t(),e});var i=new Markdown.Editor(n);i.hooks.set("insertLinkDialog",function(t){return S=t,a.resetModalInputs(),e("#modal-insert-link").modal(),!0}),i.hooks.set("insertImageDialog",function(t){return S=t,a.resetModalInputs(),e("#modal-insert-image").modal(),!0}),i.run(),r=!1,e(".wmd-button-row").addClass("btn-group").find("li:not(.wmd-spacer)").addClass("btn").css("left",0).find("span").hide(),e("#wmd-bold-button").append(e("").addClass("icon-bold")),e("#wmd-italic-button").append(e("").addClass("icon-italic")),e("#wmd-link-button").append(e("").addClass("icon-globe")),e("#wmd-quote-button").append(e("").addClass("icon-indent-left")),e("#wmd-code-button").append(e("").addClass("icon-code")),e("#wmd-image-button").append(e("").addClass("icon-picture")),e("#wmd-olist-button").append(e("").addClass("icon-numbered-list")),e("#wmd-ulist-button").append(e("").addClass("icon-list")),e("#wmd-heading-button").append(e("").addClass("icon-text-height")),e("#wmd-hr-button").append(e("").addClass("icon-hr")),e("#wmd-undo-button").append(e("").addClass("icon-undo")),e("#wmd-redo-button").append(e("").addClass("icon-share-alt"))},a.encodeBase64=function(e){if(e.length===0)return"";var t=[],n=0,r,i;e=encodeURI(e),r=e.length;while(n>18)),f.push(o.charAt(a>>12&63)),f.push(o.charAt(a>>6&63)),f.push(o.charAt(a&63));switch(t.length-l){case 1:a=t[u]<<16,f.push(o.charAt(a>>18)+o.charAt(a>>12&63)+s+s);break;case 2:a=t[u]<<16|t[u+1]<<8,f.push(o.charAt(a>>18)+o.charAt(a>>12&63)+o.charAt(a>>6&63)+s)}return f.join("")};var x=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];return a.crc32=function(e){var t=0,n=-1;for(var r=0;r>>8^x[t];return n^=-1,n<0&&(n=4294967295+n+1),n.toString(16)},a.randomString=function(){return _.random(4294967296).toString(36)},a.popupWindow=function(e,t,n,r){var i=screen.width/2-n/2,s=screen.height/2-r/2;return window.open(e,t,"toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width="+n+", height="+r+", top="+s+", left="+i)},a.init=function(){T(),N(),e.jGrowl.defaults.life=5e3,e.jGrowl.defaults.closer=!1,e.jGrowl.defaults.closeTemplate="",e.jGrowl.defaults.position="bottom-right",e(window).on("offline",a.setOffline),e(window).on("online",a.setOnline),navigator.onLine===!1&&a.setOffline(),e(document).mousemove(v).keypress(v),e(".dropdown-submenu > a").click(function(e){e.stopPropagation()}),e(".action-insert-link").click(function(t){var n=a.getInputValue(e("#input-insert-link"),t);n!==undefined&&S(n)}),e(".action-insert-image").click(function(t){var n=a.getInputValue(e("#input-insert-image"),t);n!==undefined&&S(n)}),e(".action-close-insert-link").click(function(e){S(null)}),e("#menu-bar, .ui-layout-center, .ui-layout-east, .ui-layout-south").removeClass("hide"),a.loadSettings(),a.createLayout(),e("#wmd-input").css({"font-size":a.settings.editorFontSize+"px","line-height":Math.round(a.settings.editorFontSize*(20/14))+"px"}),e(".action-load-settings").click(function(){a.loadSettings()}),e(".action-apply-settings").click(function(e){a.saveSettings(e),e.isPropagationStopped()||window.location.reload()}),e(".action-reset-input").click(function(){a.resetModalInputs()}),u.init(a),n.init(a,t),r.init(a,t),i.init(a,t),s.init(a,t),o.init(a,t),w.push(s.updateSyncButton),w.push(o.updatePublishButton),t.init(a),f=window.setInterval(function(){l(),a.checkWindowUnique();if(m()===!1)return;s.sync(),u.runTask(),E()},1e3)},a}),requirejs.config({waitSeconds:0,shim:{"jquery-ui":["jquery"],bootstrap:["jquery"],jgrowl:["jquery"],layout:["jquery-ui"],"Markdown.Sanitizer":["Markdown.Converter"],"Markdown.Editor":["Markdown.Sanitizer"]}}),require(["jquery","core"],function(e,t){e(function(){if(window.applicationCache&&window.applicationCache.status===window.applicationCache.UPDATEREADY){window.applicationCache.swapCache(),window.location.reload();return}t.init()})}),define("main",function(){});
\ No newline at end of file
diff --git a/js/publisher.js b/js/publisher.js
index 83338c2e..96dd66fd 100644
--- a/js/publisher.js
+++ b/js/publisher.js
@@ -41,28 +41,34 @@ define(["jquery", "github-provider", "underscore"], function($) {
};
// Apply template to the current document
- publisher.applyTemplate = function() {
+ publisher.applyTemplate = function(publishAttributes) {
var fileIndex = fileManager.getCurrentFileIndex();
- return _.template(core.settings.template, {
- documentTitle: localStorage[fileIndex + ".title"],
- documentMarkdown: $("#wmd-input").val(),
- documentHTML: $("#wmd-preview").html()
- });
+ try {
+ return _.template(core.settings.template, {
+ documentTitle: localStorage[fileIndex + ".title"],
+ documentMarkdown: $("#wmd-input").val(),
+ documentHTML: $("#wmd-preview").html(),
+ publishAttributes: publishAttributes
+ });
+ } catch(e) {
+ core.showError(e);
+ throw e;
+ }
};
// Used to get content to publish
- function getPublishContent(publishObject) {
- if(publishObject.format === undefined) {
- publishObject.format = $("input:radio[name=radio-publish-format]:checked").prop("value");
+ function getPublishContent(publishAttributes) {
+ if(publishAttributes.format === undefined) {
+ publishAttributes.format = $("input:radio[name=radio-publish-format]:checked").prop("value");
}
- if(publishObject.format == "markdown") {
+ if(publishAttributes.format == "markdown") {
return $("#wmd-input").val();
}
- else if(publishObject.format == "html") {
+ else if(publishAttributes.format == "html") {
return $("#wmd-preview").html();
}
else {
- return publisher.applyTemplate();
+ return publisher.applyTemplate(publishAttributes);
}
}
@@ -79,12 +85,12 @@ define(["jquery", "github-provider", "underscore"], function($) {
// Dequeue a synchronized location
var publishIndex = publishIndexList.pop();
- var publishObject = JSON.parse(localStorage[publishIndex]);
- var content = getPublishContent(publishObject);
+ var publishAttributes = JSON.parse(localStorage[publishIndex]);
+ var content = getPublishContent(publishAttributes);
// Call the provider
- var provider = providerMap[publishObject.provider];
- provider.publish(publishObject, publishTitle, content, function(error) {
+ var provider = providerMap[publishAttributes.provider];
+ provider.publish(publishAttributes, publishTitle, content, function(error) {
publishLocation(callback, errorFlag);
});
}
@@ -105,30 +111,30 @@ define(["jquery", "github-provider", "underscore"], function($) {
publishRunning = false;
publisher.updatePublishButton();
if(errorFlag === undefined) {
- core.showMessage('"' + title + '" successfully published.');
+ core.showMessage('"' + publishTitle + '" successfully published.');
}
});
};
- // Generate a publishIndex associated to a fileIndex and store a publishObject
- function createPublishIndex(fileIndex, publishObject) {
+ // Generate a publishIndex associated to a fileIndex and store publishAttributes
+ function createPublishIndex(fileIndex, publishAttributes) {
var publishIndex = undefined;
do {
publishIndex = "publish." + core.randomString();
} while(_.has(localStorage, publishIndex));
- localStorage[publishIndex] = JSON.stringify(publishObject);
+ localStorage[publishIndex] = JSON.stringify(publishAttributes);
localStorage[fileIndex + ".publish"] += publishIndex + ";";
}
// Add a new publish location to a local document
- publisher.newLocation = function(publishObject) {
+ publisher.newLocation = function(publishAttributes) {
var fileIndex = fileManager.getCurrentFileIndex();
var title = localStorage[fileIndex + ".title"];
- var content = getPublishContent(publishObject);
- var provider = providerMap[publishObject.provider];
- provider.publish(publishObject, title, content, function(error) {
+ var content = getPublishContent(publishAttributes);
+ var provider = providerMap[publishAttributes.provider];
+ provider.publish(publishAttributes, title, content, function(error) {
if(error === undefined) {
- createPublishIndex(fileIndex, publishObject);
+ createPublishIndex(fileIndex, publishAttributes);
publisher.notifyPublish();
core.showMessage('"' + title
+ '" will now be published on GitHub.');
@@ -155,10 +161,10 @@ define(["jquery", "github-provider", "underscore"], function($) {
}
_.each(publishIndexList, function(publishIndex) {
var serializedObject = localStorage[publishIndex];
- var publishObject = JSON.parse(serializedObject);
- var publishDesc = JSON.stringify(_.omit(publishObject, 'provider')).replace(/{|}|"/g, "");
+ var publishAttributes = JSON.parse(serializedObject);
+ var publishDesc = JSON.stringify(_.omit(publishAttributes, 'provider')).replace(/{|}|"/g, "");
lineElement = $(_.template(lineTemplate, {
- provider: providerMap[publishObject.provider],
+ provider: providerMap[publishAttributes.provider],
publishDesc: publishDesc
}));
lineElement.append($(removeButtonTemplate).click(function() {
@@ -184,9 +190,30 @@ define(["jquery", "github-provider", "underscore"], function($) {
});
$(".tooltip-template").tooltip({
- title: ['Variables:\n',
- 'documentTitle: the document title'
- ].join("")
+ html: true,
+ container: '#modal-settings',
+ placement: 'right',
+ trigger: 'manual',
+ title: ['Available variables:
',
+ '- documentTitle: document title
',
+ '- documentMarkdown: document in Markdown format
',
+ '- documentHTML: document in HTML format
',
+ '- publishAttributes: attributes of the publish location (undefined when using "Save")
',
+ 'Examples:
',
+ _.escape('<%= documentTitle %>'),
+ '
',
+ _.escape('<%- documentHTML %>
'),
+ '
',
+ _.escape('<% if(publishAttributes.provider == "github") print(documentMarkdown); %>'),
+ '
More info',
+ ].join("")
+ }).click(function(e) {
+ $(this).tooltip('show');
+ e.stopPropagation();
+ });
+
+ $(document).click(function(e) {
+ $(".tooltip-template").tooltip('hide');
});
};
diff --git a/test.html b/test.html
deleted file mode 100644
index 9a03cd20..00000000
--- a/test.html
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-README.md
-
-StackEdit
-
-StackEdit is a free, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.
-
-StackEdit can:
-
-
-- Manage multiple Markdown documents locally
-- Export your documents in Markdown or HTML format
-- Synchronize your Markdown documents in the Cloud
-- Edit existing Markdown documents from Google Drive and Dropbox
-- Publish your document on GitHub in one click
-
-
-Features:
-
-
-- Real-time HTML preview
-- WYSIWYG control buttons
-- Configurable layout
-- Offline editing
-- Online synchronization using Google Drive and Dropbox
-- Publish on GitHub
-
-
-
- NOTE: This page has been written with StackEdit.
-
StackEdit
-=========
-
-StackEdit is a free, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.
-
-### StackEdit can:
-
- - Manage multiple Markdown documents locally
- - Export your documents in Markdown or HTML format
- - Synchronize your Markdown documents in the Cloud
- - Edit existing Markdown documents from Google Drive and Dropbox
- - Publish your document on GitHub in one click
-
-### Features:
-
- - Real-time HTML preview
- - WYSIWYG control buttons
- - Configurable layout
- - Offline editing
- - Online synchronization using Google Drive and Dropbox
- - Publish on GitHub
-
-> **NOTE:** This page has been written with [StackEdit][1].
-
- [1]: http://benweet.github.io/stackedit/ "StackEdit"
-
\ No newline at end of file