var t={addition:"inserted",attributes:"propertyName",bold:"strong",cite:"keyword",code:"monospace",definitionList:"list",deletion:"deleted",div:"punctuation",em:"emphasis",footnote:"variable",footCite:"qualifier",header:"heading",html:"comment",image:"atom",italic:"emphasis",link:"link",linkDefinition:"link",list1:"list",list2:"list.special",list3:"list",notextile:"string.special",pre:"operator",p:"content",quote:"bracket",span:"quote",specialChar:"character",strong:"strong",sub:"content.special",sup:"content.special",table:"variableName.special",tableHeading:"operator"};function e(e,a,r){if("_"===r)return e.eat("_")?n(e,a,"italic",/__/,2):n(e,a,"em",/_/,1);if("*"===r)return e.eat("*")?n(e,a,"bold",/\*\*/,2):n(e,a,"strong",/\*/,1);if("["===r)return e.match(/\d+\]/)&&(a.footCite=!0),i(a);if("("===r&&e.match(/^(r|tm|c)\)/))return t.specialChar;if("<"===r&&e.match(/(\w+)[^>]+>[^<]+<\/\1>/))return t.html;if("?"===r&&e.eat("?"))return n(e,a,"cite",/\?\?/,2);if("="===r&&e.eat("="))return n(e,a,"notextile",/==/,2);if("-"===r&&!e.eat("-"))return n(e,a,"deletion",/-/,1);if("+"===r)return n(e,a,"addition",/\+/,1);if("~"===r)return n(e,a,"sub",/~/,1);if("^"===r)return n(e,a,"sup",/\^/,1);if("%"===r)return n(e,a,"span",/%/,1);if("@"===r)return n(e,a,"code",/@/,1);if("!"===r){var l=n(e,a,"image",/(?:\([^\)]+\))?!/,1);return e.match(/^:\S+/),l}return i(a)}function n(t,e,n,a,r){var l=t.pos>r?t.string.charAt(t.pos-r-1):null,u=t.peek();if(e[n]){if((!u||/\W/.test(u))&&l&&/\S/.test(l)){var s=i(e);return e[n]=!1,s}}else(!l||/\W/.test(l))&&u&&/\S/.test(u)&&t.match(new RegExp("^.*\\S"+a.source+"(?:\\W|$)"),!1)&&(e[n]=!0,e.mode=o.attributes);return i(e)}function i(e){var n=a(e);if(n)return n;var i=[];return e.layoutType&&i.push(t[e.layoutType]),i=i.concat(function(e){for(var n=[],i=1;i]+)?>(?:[^<]+<\/\1>)?/,link:/[^"]+":\S/,linkDefinition:/\[[^\s\]]+\]\S+/,list:/(?:#+|\*+)/,notextile:"notextile",para:"p",pre:"pre",table:"table",tableCellAttributes:/[\/\\]\d+/,tableHeading:/\|_\./,tableText:/[^"_\*\[\(\?\+~\^%@|-]+/,text:/[^!"_=\*\[\(<\?\+~\^%@-]+/},attributes:{align:/(?:<>|<|>|=)/,selector:/\([^\(][^\)]+\)/,lang:/\[[^\[\]]+\]/,pad:/(?:\(+|\)+){1,2}/,css:/\{[^\}]+\}/},createRe:function(t){switch(t){case"drawTable":return r.makeRe("^",r.single.drawTable,"$");case"html":return r.makeRe("^",r.single.html,"(?:",r.single.html,")*","$");case"linkDefinition":return r.makeRe("^",r.single.linkDefinition,"$");case"listLayout":return r.makeRe("^",r.single.list,l("allAttributes"),"*\\s+");case"tableCellAttributes":return r.makeRe("^",r.choiceRe(r.single.tableCellAttributes,l("allAttributes")),"+\\.");case"type":return r.makeRe("^",l("allTypes"));case"typeLayout":return r.makeRe("^",l("allTypes"),l("allAttributes"),"*\\.\\.?","(\\s+|$)");case"attributes":return r.makeRe("^",l("allAttributes"),"+");case"allTypes":return r.choiceRe(r.single.div,r.single.foot,r.single.header,r.single.bc,r.single.bq,r.single.notextile,r.single.pre,r.single.table,r.single.para);case"allAttributes":return r.choiceRe(r.attributes.selector,r.attributes.css,r.attributes.lang,r.attributes.align,r.attributes.pad);default:return r.makeRe("^",r.single[t])}},makeRe:function(){for(var t="",e=0;e