sterzycom/assets/js/components/prism-smarty.min.js
2019-01-25 13:45:36 +01:00

1 line
No EOL
1.7 KiB
JavaScript
Executable file

!function(e){var t=/\{\*[\s\S]+?\*\}|\{[\s\S]+?\}/g,a="{literal}",n="{/literal}",o=!1;e.languages.smarty=e.languages.extend("markup",{smarty:{pattern:t,inside:{delimiter:{pattern:/^\{|\}$/i,alias:"punctuation"},string:/(["'])(?:\\?.)*?\1/,number:/\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee][-+]?\d+)?)\b/,variable:[/\$(?!\d)\w+/,/#(?!\d)\w+#/,{pattern:/(\.|->)(?!\d)\w+/,lookbehind:!0},{pattern:/(\[)(?!\d)\w+(?=\])/,lookbehind:!0}],"function":[{pattern:/(\|\s*)@?(?!\d)\w+/,lookbehind:!0},/^\/?(?!\d)\w+/,/(?!\d)\w+(?=\()/],"attr-name":{pattern:/\w+\s*=\s*(?:(?!\d)\w+)?/,inside:{variable:{pattern:/(=\s*)(?!\d)\w+/,lookbehind:!0},operator:/=/}},punctuation:[/[\[\]().,:`]|\->/],operator:[/[+\-*\/%]|==?=?|[!<>]=?|&&|\|\|?/,/\bis\s+(?:not\s+)?(?:div|even|odd)(?:\s+by)?\b/,/\b(?:eq|neq?|gt|lt|gt?e|lt?e|not|mod|or|and)\b/],keyword:/\b(?:false|off|on|no|true|yes)\b/}}}),e.languages.insertBefore("smarty","tag",{"smarty-comment":{pattern:/\{\*[\s\S]*?\*\}/,alias:["smarty","comment"]}}),e.hooks.add("before-highlight",function(e){"smarty"===e.language&&(e.tokenStack=[],e.backupCode=e.code,e.code=e.code.replace(t,function(t){if(t===n&&(o=!1),!o){t===a&&(o=!0);for(var r=e.tokenStack.length;-1!==e.backupCode.indexOf("___SMARTY"+r+"___");)++r;return e.tokenStack[r]=t,"___SMARTY"+r+"___"}return t}))}),e.hooks.add("before-insert",function(e){"smarty"===e.language&&(e.code=e.backupCode,delete e.backupCode)}),e.hooks.add("after-highlight",function(t){if("smarty"===t.language){for(var a=0,n=Object.keys(t.tokenStack);a<n.length;++a){var o=n[a],r=t.tokenStack[o];t.highlightedCode=t.highlightedCode.replace("___SMARTY"+o+"___",e.highlight(r,t.grammar,"smarty").replace(/\$/g,"$$$$"))}t.element.innerHTML=t.highlightedCode}})}(Prism);