104 lines
3.0 KiB
YAML
104 lines
3.0 KiB
YAML
%YAML 1.2
|
|
---
|
|
# NotesCraft's own Handlebars grammar. Original work written for this project; not copied
|
|
# from any other grammar. Regexes stay linear: no nested quantifiers, so nothing backtracks far.
|
|
# Strings end at their line unless the language allows multi-line ones.
|
|
name: Handlebars
|
|
file_extensions: [hbs, handlebars, mustache, mst]
|
|
scope: text.html.handlebars
|
|
|
|
contexts:
|
|
main:
|
|
- match: '\{\{!--'
|
|
scope: comment.block
|
|
push: hb-comment-long
|
|
- match: '\{\{!'
|
|
scope: comment.block
|
|
push: hb-comment-short
|
|
- match: '\{\{\{'
|
|
scope: keyword.operator.template.begin
|
|
push: triple
|
|
- match: '\{\{~?[#/^>&]?'
|
|
scope: keyword.operator.template.begin
|
|
push: tag
|
|
hb-comment-long:
|
|
- meta_scope: comment.block
|
|
- match: '--\}\}'
|
|
pop: true
|
|
hb-comment-short:
|
|
- meta_scope: comment.block
|
|
- match: '\}\}'
|
|
pop: true
|
|
triple:
|
|
- match: '~?\}\}\}'
|
|
scope: keyword.operator.template.end
|
|
pop: true
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin
|
|
push: triple-dq
|
|
- match: ''''
|
|
scope: punctuation.definition.string.begin
|
|
push: triple-sq
|
|
- match: '\b(?:if|else|unless|each|with|lookup|log|this|partial|block|inverse|yield)\b'
|
|
scope: keyword.control
|
|
- match: '\b(?:true|false|null|undefined)\b'
|
|
scope: constant.language
|
|
- match: '\b(?:0[xX][0-9a-fA-F_]+|0[bB][01_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)\b'
|
|
scope: constant.numeric
|
|
- match: '[-+*/%=<>!&|^~?:.,]+'
|
|
scope: keyword.operator
|
|
triple-dq:
|
|
- meta_scope: string.quoted.double
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: '"'
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|
|
triple-sq:
|
|
- meta_scope: string.quoted.single
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: ''''
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|
|
tag:
|
|
- match: '~?\}\}'
|
|
scope: keyword.operator.template.end
|
|
pop: true
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin
|
|
push: tag-dq
|
|
- match: ''''
|
|
scope: punctuation.definition.string.begin
|
|
push: tag-sq
|
|
- match: '\b(?:if|else|unless|each|with|lookup|log|this|partial|block|inverse|yield)\b'
|
|
scope: keyword.control
|
|
- match: '\b(?:true|false|null|undefined)\b'
|
|
scope: constant.language
|
|
- match: '\b(?:0[xX][0-9a-fA-F_]+|0[bB][01_]+|\d[\d_]*(?:\.\d[\d_]*)?(?:[eE][+-]?\d+)?)\b'
|
|
scope: constant.numeric
|
|
- match: '[-+*/%=<>!&|^~?:.,]+'
|
|
scope: keyword.operator
|
|
tag-dq:
|
|
- meta_scope: string.quoted.double
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: '"'
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|
|
tag-sq:
|
|
- meta_scope: string.quoted.single
|
|
- match: '\\.'
|
|
scope: constant.character.escape
|
|
- match: ''''
|
|
scope: punctuation.definition.string.end
|
|
pop: true
|
|
- match: '(?=\n)'
|
|
pop: true
|