You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.1 KiB
JavaScript

Prism.languages.twig = {
'comment': /\{#[\s\S]*?#\}/g,
'tag': {
pattern: /(\{\{[\s\S]*?\}\}|\{%[\s\S]*?%\})/g,
inside: {
'ld': {
pattern: /^(\{\{\-?|\{%\-?\s*\w+)/,
inside: {
'punctuation': /^(\{\{|\{%)\-?/,
'keyword': /\w+/
}
},
'rd': {
pattern: /\-?(%\}|\}\})$/,
inside: {
'punctuation': /.*/
}
},
'string': {
pattern: /("|')(\\?.)*?\1/g,
inside: {
'punctuation': /^('|")|('|")$/g
}
},
'keyword': /\b(if)\b/g,
'boolean': /\b(true|false|null)\b/g,
'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,
'operator': /==|=|!=|<|>|>=|<=|\+|\-|~|\*|\/|\/\/|%|\*\*|\|/g,
'space-operator': {
pattern: /(\s)(\b(not|b\-and|b\-xor|b\-or|and|or|in|matches|starts with|ends with|is)\b|\?|:|\?:)(?=\s)/g,
lookbehind: true,
inside: {
'operator': /.*/
}
},
'property': /\b[a-zA-Z_][a-zA-Z0-9_]*\b/g,
'punctuation': /\(|\)|\[\]|\[|\]|\{|\}|:|\.|,/g
}
},
// The rest can be parsed as HTML
'other': {
pattern: /[\s\S]*/,
inside: Prism.languages.markup
}
};