text: /**
  * @file smartymixed.js
  * @brief Smarty Mixed Codemirror mode (Smarty + Mixed HTML)
  * @author Ruslan Osmanov <rrosmanov at gmail dot com>
  * @version 3.0
  * @date 05.07.2013
  */CodeMirror.defineMode("smartymixed",function(e){var t,n,r,i,s=CodeMirror.getMode(e,"htmlmixed"),o=CodeMirror.getMode(e,"smarty"),t={rightDelimiter:"}",leftDelimiter:"{"};return e.hasOwnProperty("leftDelimiter")&&(t.leftDelimiter=e.leftDelimiter),e.hasOwnProperty("rightDelimiter")&&(t.rightDelimiter=e.rightDelimiter),n={smartyComment:new RegExp("^"+t.leftDelimiter+"\\*"),literalOpen:new RegExp(t.leftDelimiter+"literal"+t.rightDelimiter),literalClose:new RegExp(t.leftDelimiter+"/literal"+t.rightDelimiter),hasLeftDelimeter:new RegExp(".*"+t.leftDelimiter),htmlHasLeftDelimeter:new RegExp("[^<>]*"+t.leftDelimiter)},r={chain:function(e,t,n){return t.tokenize=n,n(e,t)},cleanChain:function(e,t,n){return t.tokenize=null,t.localState=null,t.localMode=null,typeof n=="string"?n?n:null:n(e,t)},maybeBackup:function(e,t,n){var r=e.current(),i=r.search(t),s;if(i>-1)e.backUp(r.length-i);else if(s=r.match(/<\/?$/))e.backUp(r.length),e.match(t,!1)||e.match(r[0]);return n}},i={html:function(e,u){return!u.inLiteral&&e.match(n.htmlHasLeftDelimeter,!1)&&u.htmlMixedState.htmlState.tagName===null?(u.tokenize=i.smarty,u.localMode=o,u.localState=o.startState(s.indent(u.htmlMixedState,"")),r.maybeBackup(e,t.leftDelimiter,o.token(e,u.localState))):!u.inLiteral&&e.match(t.leftDelimiter,!1)?(u.tokenize=i.smarty,u.localMode=o,u.localState=o.startState(s.indent(u.htmlMixedState,"")),r.maybeBackup(e,t.leftDelimiter,o.token(e,u.localState))):s.token(e,u.htmlMixedState)},smarty:function(e,u){if(e.match(t.leftDelimiter,!1)){if(e.match(n.smartyComment,!1))return r.chain(e,u,i.inBlock("comment","*"+t.rightDelimiter))}else if(e.match(t.rightDelimiter,!1))return e.eat(t.rightDelimiter),u.tokenize=i.html,u.localMode=s,u.localState=u.htmlMixedState,"tag";return r.maybeBackup(e,t.rightDelimiter,o.token(e,u.localState))},inBlock:function(e,t){return function(n,i){while(!n.eol()){if(n.match(t)){r.cleanChain(n,i,"");break}n.next()}return e}}},{startState:function(){var e=s.startState();return{token:i.html,localMode:null,localState:null,htmlMixedState:e,tokenize:null,inLiteral:!1}},copyState:function(e){var t=null,n=e.tokenize||e.token;return e.localState&&(t=CodeMirror.copyState(n!=i.html?o:s,e.localState)),{token:e.token,tokenize:e.tokenize,localMode:e.localMode,localState:t,htmlMixedState:CodeMirror.copyState(s,e.htmlMixedState),inLiteral:e.inLiteral}},token:function(e,r){if(e.match(t.leftDelimiter,!1)){if(!r.inLiteral&&e.match(n.literalOpen,!0))return r.inLiteral=!0,"keyword";if(r.inLiteral&&e.match(n.literalClose,!0))return r.inLiteral=!1,"keyword"}r.inLiteral&&r.localState!=r.htmlMixedState&&(r.tokenize=i.html,r.localMode=s,r.localState=r.htmlMixedState);var o=(r.tokenize||r.token)(e,r);return o},indent:function(e,t){return e.localMode==o||e.inLiteral&&!e.localMode||n.hasLeftDelimeter.test(t)?CodeMirror.Pass:s.indent(e.htmlMixedState,t)},innerMode:function(e){return{state:e.localState||e.htmlMixedState,mode:e.localMode||s}}}},"htmlmixed"),CodeMirror.defineMIME("text/x-smarty","smartymixed");