!function(t){"use strict";var e=function(e,n){this.$ns="bootstrap-markdown",this.$element=t(e),this.$editable={el:null,type:null,attrKeys:[],attrValues:[],content:null},this.$options=t.extend(!0,{},t.fn.markdown.defaults,n),this.$oldContent=null,this.$isPreview=!1,this.$editor=null,this.$textarea=null,this.$handler=[],this.$callback=[],this.$nextTab=[],this.showEditor()};e.prototype={constructor:e,__alterButtons:function(e,n){var r=this.$handler,i="all"==e,a=this;t.each(r,function(t,r){var s=!0;s=i?!1:r.indexOf(e)<0,0==s&&n(a.$editor.find('button[data-handler="'+r+'"]'))})},__buildButtons:function(e,n){var r,i=this.$ns,a=this.$handler,s=this.$callback;for(r=0;r",{"class":"btn-group"});for(c=0;c '+g+""),a.push(p),s.push(f.callback)}n.append(u)}}return n},__setListener:function(){var e="undefined"!=typeof this.$textarea.attr("rows"),n=this.$textarea.val().split("\n").length>5?this.$textarea.val().split("\n").length:"5",r=e?this.$textarea.attr("rows"):n;this.$textarea.attr("rows",r),this.$textarea.css("resize","none"),this.$textarea.on("focus",t.proxy(this.focus,this)).on("keypress",t.proxy(this.keypress,this)).on("keyup",t.proxy(this.keyup,this)),this.eventSupported("keydown")&&this.$textarea.on("keydown",t.proxy(this.keydown,this)),this.$textarea.data("markdown",this)},__handle:function(e){var n=t(e.currentTarget),r=this.$handler,i=this.$callback,a=n.attr("data-handler"),s=r.indexOf(a),l=i[s];t(e.currentTarget).focus(),l(this),a.indexOf("cmdSave")<0&&this.$textarea.focus(),e.preventDefault()},showEditor:function(){var e,n=this,r=this.$ns,i=this.$element,a=(i.css("height"),i.css("width"),this.$editable),s=this.$handler,l=this.$callback,o=this.$options,c=t("",{"class":"md-editor tile",click:function(){n.focus()}});if(null==this.$editor){var h=t("",{"class":"md-header tile-title"});if(o.buttons.length>0&&(h=this.__buildButtons(o.buttons,h)),o.additionalButtons.length>0&&(h=this.__buildButtons(o.additionalButtons,h)),c.append(h),i.is("textarea"))i.before(c),e=i,e.addClass("md-input"),c.append(e);else{var u="function"==typeof toMarkdown?toMarkdown(i.html()):i.html(),f=t.trim(u);e=t("",{"class":"md-input",val:f}),c.append(e),a.el=i,a.type=i.prop("tagName").toLowerCase(),a.content=i.html(),t(i[0].attributes).each(function(){a.attrKeys.push(this.nodeName),a.attrValues.push(this.nodeValue)}),i.replaceWith(c)}if(o.savable){var d=t("",{"class":"md-footer"}),p="cmdSave";s.push(p),l.push(o.onSave),d.append(''),c.append(d)}t.each(["height","width"],function(t,e){"inherit"!=o[e]&&(jQuery.isNumeric(o[e])?c.css(e,o[e]+"px"):c.addClass(o[e]))}),this.$editor=c,this.$textarea=e,this.$editable=a,this.$oldContent=this.getContent(),this.__setListener(),this.$editor.attr("id",(new Date).getTime()),this.$editor.on("click",'[data-provider="bootstrap-markdown"]',t.proxy(this.__handle,this))}else this.$editor.show();return o.autofocus&&(this.$textarea.focus(),this.$editor.addClass("active")),o.onShow(this),this},showPreview:function(){var e,n=this.$options,r=n.onPreview(this),i=this.$textarea,a=i.next(),s=t("",{"class":"md-preview","data-provider":"markdown-preview"});return this.$isPreview=!0,this.disableButtons("all").enableButtons("cmdPreview"),e="string"==typeof r?r:"object"==typeof markdown?markdown.toHTML(i.val()):i.val(),s.html(e),a&&"md-footer"==a.attr("class")?s.insertBefore(a):i.parent().append(s),i.hide(),s.data("markdown",this),this},hidePreview:function(){this.$isPreview=!1;var t=this.$editor.find('div[data-provider="markdown-preview"]');return t.remove(),this.enableButtons("all"),this.$textarea.show(),this.__setListener(),this},isDirty:function(){return this.$oldContent!=this.getContent()},getContent:function(){return this.$textarea.val()},setContent:function(t){return this.$textarea.val(t),this},findSelection:function(t){var e,n=this.getContent();if(e=n.indexOf(t),e>=0&&t.length>0){var r,i=this.getSelection();return this.setSelection(e,e+t.length),r=this.getSelection(),this.setSelection(i.start,i.end),r}return null},getSelection:function(){var t=this.$textarea[0];return("selectionStart"in t&&function(){var e=t.selectionEnd-t.selectionStart;return{start:t.selectionStart,end:t.selectionEnd,length:e,text:t.value.substr(t.selectionStart,e)}}||function(){return null})()},setSelection:function(t,e){var n=this.$textarea[0];return("selectionStart"in n&&function(){n.selectionStart=t,n.selectionEnd=e}||function(){return null})()},replaceSelection:function(t){var e=this.$textarea[0];return("selectionStart"in e&&function(){return e.value=e.value.substr(0,e.selectionStart)+t+e.value.substr(e.selectionEnd,e.value.length),e.selectionStart=e.value.length,this}||function(){return e.value+=t,jQuery(e)})()},getNextTab:function(){if(0==this.$nextTab.length)return null;var t,e=this.$nextTab.shift();return"function"==typeof e?t=e():"object"==typeof e&&e.length>0&&(t=e),t},setNextTab:function(t,e){if("string"==typeof t){var n=this;this.$nextTab.push(function(){return n.findSelection(t)})}else if("numeric"==typeof t&&"numeric"==typeof e){var r=this.getSelection();this.setSelection(t,e),this.$nextTab.push(this.getSelection()),this.setSelection(r.start,r.end)}},enableButtons:function(t){var e=function(t){t.removeAttr("disabled")};return this.__alterButtons(t,e),this},disableButtons:function(t){var e=function(t){t.attr("disabled","disabled")};return this.__alterButtons(t,e),this},eventSupported:function(t){var e=t in this.$element;return e||(this.$element.setAttribute(t,"return;"),e="function"==typeof this.$element[t]),e},keydown:function(e){this.suppressKeyPressRepeat=~t.inArray(e.keyCode,[40,38,9,13,27]),this.keyup(e)},keypress:function(t){this.suppressKeyPressRepeat||this.keyup(t)},keyup:function(t){var e=!1;switch(t.keyCode){case 40:case 38:case 16:case 17:case 18:break;case 9:var n;if(n=this.getNextTab(),null!=n){var r=this;setTimeout(function(){r.setSelection(n.start,n.end)},500),e=!0}else{var i=this.getSelection();i.start==i.end&&i.end==this.getContent().length?e=!1:(this.setSelection(this.getContent().length,this.getContent().length),e=!0)}break;case 13:case 27:e=!1;break;default:e=!1}e&&(t.stopPropagation(),t.preventDefault())},focus:function(){var e=this.$options,n=(e.hideable,this.$editor);return n.addClass("active"),t(document).find(".md-editor").each(function(){if(t(this).attr("id")!=n.attr("id")){var e;e=t(this).find("textarea").data("markdown"),null==e&&(e=t(this).find('div[data-provider="markdown-preview"]').data("markdown")),e&&e.blur()}}),e.onFocus(this),this},blur:function(){var e=this.$options,n=e.hideable,r=this.$editor,i=this.$editable;if(r.hasClass("active")||0==this.$element.parent().length){if(r.removeClass("active"),n)if(null!=i.el){var a=t("<"+i.type+"/>"),s=this.getContent(),l="object"==typeof markdown?markdown.toHTML(s):s;t(i.attrKeys).each(function(t){a.attr(i.attrKeys[t],i.attrValues[t])}),a.html(l),r.replaceWith(a)}else r.hide();e.onBlur(this)}return this}};var n=t.fn.markdown;t.fn.markdown=function(n){return this.each(function(){var r=t(this),i=r.data("markdown"),a="object"==typeof n&&n;i||r.data("markdown",i=new e(this,a))})},t.fn.markdown.defaults={autofocus:!1,hideable:!1,savable:!1,width:"inherit",height:"inherit",buttons:[[{name:"groupFont",data:[{name:"cmdBold",title:"Bold",icon:"editor-bold",callback:function(t){var e,n,r=t.getSelection(),i=t.getContent();e=0==r.length?"strong text":r.text,"**"==i.substr(r.start-2,2)&&"**"==i.substr(r.end,2)?(t.setSelection(r.start-2,r.end+2),t.replaceSelection(e),n=r.start-2):(t.replaceSelection("**"+e+"**"),n=r.start+2),t.setSelection(n,n+e.length)}},{name:"cmdItalic",title:"Italic",icon:"editor-italic",callback:function(t){var e,n,r=t.getSelection(),i=t.getContent();e=0==r.length?"emphasized text":r.text,"*"==i.substr(r.start-1,1)&&"*"==i.substr(r.end,1)?(t.setSelection(r.start-1,r.end+1),t.replaceSelection(e),n=r.start-1):(t.replaceSelection("*"+e+"*"),n=r.start+1),t.setSelection(n,n+e.length)}},{name:"cmdHeading",title:"Heading",icon:"editor-heading",callback:function(t){var e,n,r,i,a=t.getSelection(),s=t.getContent();e=0==a.length?"heading text":a.text+"\n",r=4,"### "==s.substr(a.start-r,r)||(r=3,"###"==s.substr(a.start-r,r))?(t.setSelection(a.start-r,a.end),t.replaceSelection(e),n=a.start-r):a.start>0&&(i=s.substr(a.start-1,1),!!i&&"\n"!=i)?(t.replaceSelection("\n\n### "+e),n=a.start+6):(t.replaceSelection("### "+e),n=a.start+4),t.setSelection(n,n+e.length)}}]},{name:"groupLink",data:[{name:"cmdUrl",title:"URL/Link",icon:"editor-link",callback:function(t){{var e,n,r,i=t.getSelection();t.getContent()}e=0==i.length?"enter link description here":i.text,r=prompt("Insert Hyperlink","http://"),null!=r&&""!=r&&"http://"!=r&&(t.replaceSelection("["+e+"]("+r+")"),n=i.start+1,t.setSelection(n,n+e.length))}},{name:"cmdImage",title:"Image",icon:"editor-picture",callback:function(t){{var e,n,r,i=t.getSelection();t.getContent()}e=0==i.length?"enter image description here":i.text,r=prompt("Insert Image Hyperlink","http://"),null!=r&&(t.replaceSelection("'),n=i.start+2,t.setNextTab("enter image title here"),t.setSelection(n,n+e.length))}}]},{name:"groupMisc",data:[{name:"cmdList",title:"List",icon:"editor-unlist",callback:function(e){{var n,r,i=e.getSelection();e.getContent()}if(0==i.length)n="list text here",e.replaceSelection("- "+n),r=i.start+2;else if(i.text.indexOf("\n")<0)n=i.text,e.replaceSelection("- "+n),r=i.start+2;else{var a=[];a=i.text.split("\n"),n=a[0],t.each(a,function(t,e){a[t]="- "+e}),e.replaceSelection("\n\n"+a.join("\n")),r=i.start+4}e.setSelection(r,r+n.length)}}]},{name:"groupUtil",data:[{name:"cmdPreview",toggle:!0,title:"Preview",btnText:"Preview",btnClass:"btn btn-primary btn-sm",icon:"",callback:function(t){var e=t.$isPreview;0==e?t.showPreview():t.hidePreview()}}]}]],additionalButtons:[],onShow:function(){},onPreview:function(){},onSave:function(){},onBlur:function(){},onFocus:function(){}},t.fn.markdown.Constructor=e,t.fn.markdown.noConflict=function(){return t.fn.markdown=n,this};var r=function(t){var e=t;return e.data("markdown")?void e.data("markdown").showEditor():void e.markdown(e.data())},i=function(e){var n,r=!1,i=t(e.currentTarget);"focusin"!=e.type&&"click"!=e.type||1!=i.length||"object"!=typeof i[0]||(n=i[0].activeElement,t(n).data("markdown")||("undefined"==typeof t(n).parent().parent().parent().attr("class")||t(n).parent().parent().parent().attr("class").indexOf("md-editor")<0?("undefined"==typeof t(n).parent().parent().attr("class")||t(n).parent().parent().attr("class").indexOf("md-editor")<0)&&(r=!0):r=!1),r&&t(document).find(".md-editor").each(function(){var e=t(n).parent();if(t(this).attr("id")!=e.attr("id")){var r;r=t(this).find("textarea").data("markdown"),null==r&&(r=t(this).find('div[data-provider="markdown-preview"]').data("markdown")),r&&r.blur()}}),e.stopPropagation())};t(document).on("click.markdown.data-api",'[data-provide="markdown-editable"]',function(e){r(t(this)),e.preventDefault()}).on("click",function(t){i(t)}).on("focusin",function(t){i(t)}).ready(function(){t('textarea[data-provide="markdown"]').each(function(){r(t(this))})})}(window.jQuery),function(t){function e(){return"Markdown.mk_block( "+uneval(this.toString())+", "+uneval(this.trailing)+", "+uneval(this.lineNumber)+" )"}function n(){var t=require("util");return"Markdown.mk_block( "+t.inspect(this.toString())+", "+t.inspect(this.trailing)+", "+t.inspect(this.lineNumber)+" )"}function r(t){for(var e=0,n=-1;-1!==(n=t.indexOf("\n",n+1));)e++;return e}function i(t,e){function n(t){this.len_after=t,this.name="close_"+e}var r=t+"_state",i="strong"==t?"em_state":"strong_state";return function(a){if(this[r][0]==e)return this[r].shift(),[a.length,new n(a.length-e.length)];var s=this[i].slice(),l=this[r].slice();this[r].unshift(e);{var o=this.processInline(a.substr(e.length)),c=o[o.length-1];this[r].shift()}if(c instanceof n){o.pop();var h=a.length-c.len_after;return[h,[t].concat(o)]}return this[i]=s,this[r]=l,[e.length,e]}}function s(t){for(var e=t.split(""),n=[""],r=!1;e.length;){var i=e.shift();switch(i){case" ":r?n[n.length-1]+=i:n.push("");break;case"'":case'"':r=!r;break;case"\\":i=e.shift();default:n[n.length-1]+=i}}return n}function l(t){return v(t)&&t.length>1&&"object"==typeof t[1]&&!v(t[1])?t[1]:void 0}function o(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function c(t){if("string"==typeof t)return o(t);var e=t.shift(),n={},r=[];for(!t.length||"object"!=typeof t[0]||t[0]instanceof Array||(n=t.shift());t.length;)r.push(arguments.callee(t.shift()));var i="";for(var a in n)i+=" "+a+'="'+o(n[a])+'"';return"img"==e||"br"==e||"hr"==e?"<"+e+i+"/>":"<"+e+i+">"+r.join("")+""+e+">"}function h(t,e,n){var r;n=n||{};var i=t.slice(0);"function"==typeof n.preprocessTreeNode&&(i=n.preprocessTreeNode(i,e));var a=l(i);if(a){i[1]={};for(r in a)i[1][r]=a[r];a=i[1]}if("string"==typeof i)return i;switch(i[0]){case"header":i[0]="h"+i[1].level,delete i[1].level;break;case"bulletlist":i[0]="ul";break;case"numberlist":i[0]="ol";break;case"listitem":i[0]="li";break;case"para":i[0]="p";break;case"markdown":i[0]="html",a&&delete a.references;break;case"code_block":i[0]="pre",r=a?2:1;var s=["code"];s.push.apply(s,i.splice(r)),i[r]=s;break;case"inlinecode":i[0]="code";break;case"img":i[1].src=i[1].href,delete i[1].href;break;case"linebreak":i[0]="br";break;case"link":i[0]="a";break;case"link_ref":i[0]="a";var o=e[a.ref];if(!o)return a.original;delete a.ref,a.href=o.href,o.title&&(a.title=o.title),delete a.original;break;case"img_ref":i[0]="img";var o=e[a.ref];if(!o)return a.original;delete a.ref,a.src=o.href,o.title&&(a.title=o.title),delete a.original}if(r=1,a){for(var c in i[1])r=2;1===r&&i.splice(r,1)}for(;r0&&!v(a[0]))&&this.debug(r[i],"didn't return a proper array"),a}return[]},f.prototype.processInline=function(t){return this.dialect.inline.__call__.call(this,String(t))},f.prototype.toTree=function(t,e){var n=t instanceof Array?t:this.split_blocks(t),r=this.tree;try{for(this.tree=e||this.tree||["markdown"];n.length;){var i=this.processBlock(n.shift(),n);i.length&&this.tree.push.apply(this.tree,i)}return this.tree}finally{e&&(this.tree=r)}},f.prototype.debug=function(){var t=Array.prototype.slice.call(arguments);t.unshift(this.debug_indent),"undefined"!=typeof print&&print.apply(print,t),"undefined"!=typeof console&&"undefined"!=typeof console.log&&console.log.apply(null,t)},f.prototype.loop_re_over_block=function(t,e,n){for(var r,i=e.valueOf();i.length&&null!=(r=t.exec(i));)i=i.substr(r[0].length),n.call(this,r);return i},f.dialects={},f.dialects.Gruber={block:{atxHeader:function(t,e){var n=t.match(/^(#{1,6})\s*(.*?)\s*#*\s*(?:\n|$)/);if(!n)return void 0;var r=["header",{level:n[1].length}];return Array.prototype.push.apply(r,this.processInline(n[2])),n[0].length1&&n.unshift(r);for(var a=0;a1&&"string"==typeof i[i.length-1]?i[i.length-1]+=s:i.push(s)}}function r(t,e){for(var n=new RegExp("^("+o+"{"+t+"}.*?\\n?)*$"),r=new RegExp("^"+o+"{"+t+"}","gm"),i=[];e.length>0;){if(n.exec(e[0])){var a=e.shift(),s=a.replace(r,"");i.push(d(s,a.trailing,a.lineNumber))}break}return i}function i(t,e,n){var r=t.list,i=r[r.length-1];if(!(i[1]instanceof Array&&"para"==i[1][0]))if(e+1==n.length)i.push(["para"].concat(i.splice(1)));else{var a=i.pop();i.push(["para"].concat(i.splice(1)),a)}}var a="[*+-]|\\d+\\.",s=/[*+-]/,l=new RegExp("^( {0,3})("+a+")[ ]+"),o="(?: {0,3}\\t| {4})";return function(a,o){function c(t){var e=s.exec(t[2])?["bulletlist"]:["numberlist"];return d.push({list:e,indent:t[1]}),e}var h=a.match(l);if(!h)return void 0;for(var u,f,d=[],p=c(h),v=!1,b=[d[0].list];;){for(var m=a.split(/(?=\n)/),k="",_=0;_d.length)p=c(h),u.push(p),u=p[1]=["listitem"];else{var S=!1;for(f=0;fh[0].length&&(k+=w+y.substr(h[0].length))}k.length&&(n(u,v,this.processInline(k),w),v=!1,k="");var C=r(d.length,o);C.length>0&&(g(d,i,this),u.push.apply(u,this.toTree(C,[])));var T=o[0]&&o[0].valueOf()||"";if(!T.match(l)&&!T.match(/^ /))break;a=o.shift();var B=this.dialect.block.horizRule(a,o);if(B){b.push.apply(b,B);break}g(d,i,this),v=!0}return b}}(),blockquote:function(t,e){if(!t.match(/^>/m))return void 0;var n=[];if(">"!=t[0]){for(var r=t.split(/\n/),i=[];r.length&&">"!=r[0][0];)i.push(r.shift());t=r.join("\n"),n.push.apply(n,this.processBlock(i.join("\n"),[]))}for(;e.length&&">"==e[0][0];){var a=e.shift();t=new String(t+t.trailing+a),t.trailing=a.trailing}{var s=t.replace(/^> ?/gm,"");this.tree}return n.push(this.toTree(s,["blockquote"])),n},referenceDefn:function(t,e){var n=/^\s*\[(.*?)\]:\s*(\S+)(?:\s+(?:(['"])(.*?)\3|\((.*?)\)))?\n?/;if(!t.match(n))return void 0;l(this.tree)||this.tree.splice(1,0,{});var r=l(this.tree);void 0===r.references&&(r.references={});var i=this.loop_re_over_block(n,t,function(t){t[2]&&"<"==t[2][0]&&">"==t[2][t[2].length-1]&&(t[2]=t[2].substring(1,t[2].length-1));var e=r.references[t[1].toLowerCase()]={href:t[2]};void 0!==t[4]?e.title=t[4]:void 0!==t[5]&&(e.title=t[5])});return i.length&&e.unshift(d(i,t.trailing)),[]},para:function(t){return[["para"].concat(this.processInline(t))]}}},f.dialects.Gruber.inline={__oneElement__:function(t,e,n){var r,i;e=e||this.dialect.inline.__patterns__;var a=new RegExp("([\\s\\S]*?)("+(e.source||e)+")");if(r=a.exec(t),!r)return[t.length,t];if(r[1])return[r[1].length,r[1]];var i;return r[2]in this.dialect.inline&&(i=this.dialect.inline[r[2]].call(this,t.substr(r.index),r,n||[])),i=i||[r[2].length,r[2]]},__call__:function(t,e){function n(t){"string"==typeof t&&"string"==typeof i[i.length-1]?i[i.length-1]+=t:i.push(t)}for(var r,i=[];t.length>0;)r=this.dialect.inline.__oneElement__.call(this,t,e,i),t=t.substr(r.shift()),g(r,n);return i},"]":function(){},"}":function(){},"\\":function(t){return t.match(/^\\[\\`\*_{}\[\]()#\+.!\-]/)?[2,t[1]]:[1,"\\"]},"![":function(t){var e=t.match(/^!\[(.*?)\][ \t]*\([ \t]*(\S*)(?:[ \t]+(["'])(.*?)\3)?[ \t]*\)/);if(e){e[2]&&"<"==e[2][0]&&">"==e[2][e[2].length-1]&&(e[2]=e[2].substring(1,e[2].length-1)),e[2]=this.dialect.inline.__call__.call(this,e[2],/\\/)[0];var n={alt:e[1],href:e[2]||""};return void 0!==e[4]&&(n.title=e[4]),[e[0].length,["img",n]]}return e=t.match(/^!\[(.*?)\][ \t]*\[(.*?)\]/),e?[e[0].length,["img_ref",{alt:e[1],ref:e[2].toLowerCase(),original:e[0]}]]:[2,"!["]},"[":function m(t){var e=String(t),n=f.DialectHelpers.inline_until_char.call(this,t.substr(1),"]");if(!n)return[1,"["];var m,r,i=1+n[0],a=n[1];t=t.substr(i);var s=t.match(/^\s*\([ \t]*(\S+)(?:[ \t]+(["'])(.*?)\2)?[ \t]*\)/);if(s){var l=s[1];if(i+=s[0].length,l&&"<"==l[0]&&">"==l[l.length-1]&&(l=l.substring(1,l.length-1)),!s[3])for(var o=1,c=0;c]+)|(.*?@.*?\.[a-zA-Z]+))>/))?e[3]?[e[0].length,["link",{href:"mailto:"+e[3]},e[3]]]:"mailto"==e[2]?[e[0].length,["link",{href:e[1]},e[1].substr("mailto:".length)]]:[e[0].length,["link",{href:e[1]},e[1]]]:[1,"<"]},"`":function(t){var e=t.match(/(`+)(([\s\S]*?)\1)/);return e&&e[2]?[e[1].length+e[2].length,["inlinecode",e[3]]]:[1,"`"]}," \n":function(){return[3,["linebreak"]]}},f.dialects.Gruber.inline["**"]=i("strong","**"),f.dialects.Gruber.inline.__=i("strong","__"),f.dialects.Gruber.inline["*"]=i("em","*"),f.dialects.Gruber.inline._=i("em","_"),f.buildBlockOrder=function(t){var e=[];for(var n in t)"__order__"!=n&&"__call__"!=n&&e.push(n);t.__order__=e},f.buildInlinePatterns=function(t){var e=[];for(var n in t)if(!n.match(/^__.*__$/)){var r=n.replace(/([\\.*+?|()\[\]{}])/g,"\\$1").replace(/\n/,"\\n");e.push(1==n.length?r:"(?:"+r+")")}e=e.join("|"),t.__patterns__=e;var i=t.__call__;t.__call__=function(t,n){return void 0!=n?i.call(this,t,n):i.call(this,t,e)}},f.DialectHelpers={},f.DialectHelpers.inline_until_char=function(t,e){for(var n=0,r=[];;){if(t[n]==e)return n++,[n,r];if(n>=t.length)return null;var i=this.dialect.inline.__oneElement__.call(this,t.substr(n));n+=i[0],r.push.apply(r,i.slice(1))}},f.subclassDialect=function(t){function e(){}function n(){}return e.prototype=t.block,n.prototype=t.inline,{block:new e,inline:new n}},f.buildBlockOrder(f.dialects.Gruber.block),f.buildInlinePatterns(f.dialects.Gruber.inline),f.dialects.Maruku=f.subclassDialect(f.dialects.Gruber),f.dialects.Maruku.processMetaHash=function(t){for(var e=s(t),n={},r=0;r1)return void 0;if(!t.match(/^(?:\w+:.*\n)*\w+:.*$/))return void 0;l(this.tree)||this.tree.splice(1,0,{});var e=t.split(/\n/);for(p in e){var n=e[p].match(/(\w+):\s*(.*)$/),r=n[1].toLowerCase(),i=n[2];this.tree[1][r]=i}return[]},f.dialects.Maruku.block.block_meta=function(t){var e=t.match(/(^|\n) {0,3}\{:\s*((?:\\\}|[^\}])*)\s*\}$/);if(!e)return void 0;var n,r=this.dialect.processMetaHash(e[2]);if(""===e[1]){var i=this.tree[this.tree.length-1];if(n=l(i),"string"==typeof i)return void 0;n||(n={},i.splice(1,0,n));for(a in r)n[a]=r[a];return[]}var s=t.replace(/\n.*$/,""),o=this.processBlock(s,[]);n=l(o[0]),n||(n={},o[0].splice(1,0,n));for(a in r)n[a]=r[a];return o},f.dialects.Maruku.block.definition_list=function(t,e){var n,r=/^((?:[^\s:].*\n)+):\s+([\s\S]+)$/,i=["dl"];if(!(l=t.match(r)))return void 0;for(var a=[t];e.length&&r.exec(e[0]);)a.push(e.shift());for(var s=0;s