5e8020aa38
Editor previews (colour swatches, arrows, embeds), the 18 obsidian-basics tasks (find and replace with regex, back/forward, auto-pair, footnotes, folding, search operators, split view, PDF/audio/ video embeds, spelling, drag and drop, pinned tabs, settings) and round 2: ```query blocks, stacked tabs, pop-out windows, tasks ticked inside embeds, text around an embed, embeds that follow edits, block menu shortcut. New crates: notescraft-regex (linear-time engine) and notescraft-syntax. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
239 lines
7.8 KiB
YAML
239 lines
7.8 KiB
YAML
%YAML 1.2
|
|
---
|
|
# NotesCraft's own TOML grammar. Original work written for this project; not copied
|
|
# from any other grammar. Scope names follow what notescraft-syntax maps to kinds.
|
|
# Regexes stay linear: no nested quantifiers, so nothing can backtrack far.
|
|
name: TOML
|
|
file_extensions: [toml]
|
|
scope: source.toml
|
|
|
|
contexts:
|
|
main:
|
|
- match: '#.*'
|
|
scope: comment.line.number-sign.toml
|
|
- match: '\[\['
|
|
scope: punctuation.definition.table.toml
|
|
push: table-array-header
|
|
- match: '\['
|
|
scope: punctuation.definition.table.toml
|
|
push: table-header
|
|
- include: key-parts
|
|
|
|
# Bare and quoted keys, dotted separators and the '=' that starts a value.
|
|
# Shared by the top level and inline tables.
|
|
key-parts:
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin.toml
|
|
push: quoted-key-double
|
|
- match: "'"
|
|
scope: punctuation.definition.string.begin.toml
|
|
push: quoted-key-single
|
|
- match: '[A-Za-z0-9_-]+'
|
|
scope: meta.mapping.key.toml
|
|
- match: '\.'
|
|
scope: punctuation.separator.key.toml
|
|
- match: '='
|
|
scope: keyword.operator.assignment.toml
|
|
push: value
|
|
- match: '#.*'
|
|
scope: comment.line.number-sign.toml
|
|
|
|
quoted-key-double:
|
|
- meta_scope: meta.mapping.key.toml
|
|
- match: '\\.'
|
|
scope: constant.character.escape.toml
|
|
- match: '"'
|
|
scope: punctuation.definition.string.end.toml
|
|
pop: true
|
|
|
|
quoted-key-single:
|
|
- meta_scope: meta.mapping.key.toml
|
|
- match: "'"
|
|
scope: punctuation.definition.string.end.toml
|
|
pop: true
|
|
|
|
# [table] headers: each key part is a tag.
|
|
table-header:
|
|
- match: '\]'
|
|
scope: punctuation.definition.table.toml
|
|
pop: true
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin.toml
|
|
push: quoted-key-double
|
|
- match: "'"
|
|
scope: punctuation.definition.string.begin.toml
|
|
push: quoted-key-single
|
|
- match: '[A-Za-z0-9_-]+'
|
|
scope: entity.name.tag.toml
|
|
- match: '\.'
|
|
scope: punctuation.separator.key.toml
|
|
|
|
# [[array-of-tables]] headers, same as above but closed by ']]'.
|
|
table-array-header:
|
|
- match: '\]\]'
|
|
scope: punctuation.definition.table.toml
|
|
pop: true
|
|
- match: '\]'
|
|
scope: punctuation.definition.table.toml
|
|
pop: true
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin.toml
|
|
push: quoted-key-double
|
|
- match: "'"
|
|
scope: punctuation.definition.string.begin.toml
|
|
push: quoted-key-single
|
|
- match: '[A-Za-z0-9_-]+'
|
|
scope: entity.name.tag.toml
|
|
- match: '\.'
|
|
scope: punctuation.separator.key.toml
|
|
|
|
# What follows '='. Composite values replace this context (set) so a completed
|
|
# composite ends back at the caller; a scalar scopes itself and pops, and the
|
|
# end of the line pops anything left (empty or invalid values).
|
|
value:
|
|
- match: '#.*'
|
|
scope: comment.line.number-sign.toml
|
|
- match: '"""'
|
|
scope: punctuation.definition.string.begin.toml
|
|
set: multiline-basic
|
|
- match: "'''"
|
|
scope: punctuation.definition.string.begin.toml
|
|
set: multiline-literal
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin.toml
|
|
set: basic
|
|
- match: "'"
|
|
scope: punctuation.definition.string.begin.toml
|
|
set: literal
|
|
- match: '\['
|
|
scope: punctuation.definition.array.begin.toml
|
|
set: array
|
|
- match: '\{'
|
|
scope: punctuation.definition.inline-table.begin.toml
|
|
set: inline-table
|
|
- match: '\b(?:true|false)\b'
|
|
scope: constant.language.toml
|
|
pop: true
|
|
- match: '\b(?:\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)?|\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)'
|
|
scope: constant.numeric.date.toml
|
|
pop: true
|
|
- match: '[+-]?\b0[xX][0-9a-fA-F](?:_?[0-9a-fA-F])*'
|
|
scope: constant.numeric.integer.hex.toml
|
|
pop: true
|
|
- match: '[+-]?\b0[oO][0-7](?:_?[0-7])*'
|
|
scope: constant.numeric.integer.octal.toml
|
|
pop: true
|
|
- match: '[+-]?\b0[bB][01](?:_?[01])*'
|
|
scope: constant.numeric.integer.binary.toml
|
|
pop: true
|
|
- match: '[+-]?\b(?:inf|nan)\b'
|
|
scope: constant.numeric.float.toml
|
|
pop: true
|
|
- match: '[+-]?\b(?:\d(?:_?\d)*\.\d(?:_?\d)*(?:[eE][+-]?\d(?:_?\d)*)?|\d(?:_?\d)*[eE][+-]?\d(?:_?\d)*)'
|
|
scope: constant.numeric.float.toml
|
|
pop: true
|
|
- match: '[+-]?\b\d(?:_?\d)*'
|
|
scope: constant.numeric.integer.toml
|
|
pop: true
|
|
- match: '\n'
|
|
pop: true
|
|
|
|
# Atomic values, scope only; shared by arrays and inline tables.
|
|
scalars:
|
|
- match: '\b(?:true|false)\b'
|
|
scope: constant.language.toml
|
|
- match: '\b(?:\d{4}-\d{2}-\d{2}(?:[Tt ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)?|\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})?)'
|
|
scope: constant.numeric.date.toml
|
|
- match: '[+-]?\b0[xX][0-9a-fA-F](?:_?[0-9a-fA-F])*'
|
|
scope: constant.numeric.integer.hex.toml
|
|
- match: '[+-]?\b0[oO][0-7](?:_?[0-7])*'
|
|
scope: constant.numeric.integer.octal.toml
|
|
- match: '[+-]?\b0[bB][01](?:_?[01])*'
|
|
scope: constant.numeric.integer.binary.toml
|
|
- match: '[+-]?\b(?:inf|nan)\b'
|
|
scope: constant.numeric.float.toml
|
|
- match: '[+-]?\b(?:\d(?:_?\d)*\.\d(?:_?\d)*(?:[eE][+-]?\d(?:_?\d)*)?|\d(?:_?\d)*[eE][+-]?\d(?:_?\d)*)'
|
|
scope: constant.numeric.float.toml
|
|
- match: '[+-]?\b\d(?:_?\d)*'
|
|
scope: constant.numeric.integer.toml
|
|
|
|
# Basic (double-quoted) string; escapes are recognised, the quote closes.
|
|
basic:
|
|
- meta_scope: string.quoted.double.toml
|
|
- match: '\\.'
|
|
scope: constant.character.escape.toml
|
|
- match: '"'
|
|
scope: punctuation.definition.string.end.toml
|
|
pop: true
|
|
|
|
# Literal (single-quoted) string; no escapes.
|
|
literal:
|
|
- meta_scope: string.quoted.single.toml
|
|
- match: "'"
|
|
scope: punctuation.definition.string.end.toml
|
|
pop: true
|
|
|
|
# Multi-line basic string; a line-ending backslash joins lines, and a terminator
|
|
# never eats a content quote (""" only when not followed by another ").
|
|
multiline-basic:
|
|
- meta_scope: string.quoted.double.toml
|
|
- match: '\\\n'
|
|
scope: constant.character.escape.toml
|
|
- match: '\\.'
|
|
scope: constant.character.escape.toml
|
|
- match: '"""(?!")'
|
|
scope: punctuation.definition.string.end.toml
|
|
pop: true
|
|
|
|
# Multi-line literal string.
|
|
multiline-literal:
|
|
- meta_scope: string.quoted.single.toml
|
|
- match: "'''(?!')"
|
|
scope: punctuation.definition.string.end.toml
|
|
pop: true
|
|
|
|
# Arrays span lines; elements are values, comma-separated.
|
|
array:
|
|
- match: '\]'
|
|
scope: punctuation.definition.array.end.toml
|
|
pop: true
|
|
- match: ','
|
|
scope: punctuation.separator.array.toml
|
|
- match: '#.*'
|
|
scope: comment.line.number-sign.toml
|
|
- include: nested-values
|
|
|
|
# Inline tables: keys and values, comma-separated.
|
|
inline-table:
|
|
- match: '\}'
|
|
scope: punctuation.definition.inline-table.end.toml
|
|
pop: true
|
|
- match: ','
|
|
scope: punctuation.separator.inline-table.toml
|
|
- match: '#.*'
|
|
scope: comment.line.number-sign.toml
|
|
- include: nested-values
|
|
- include: key-parts
|
|
|
|
# Composite values inside arrays and inline tables push (not set), so the
|
|
# container stays on the stack and a finished composite returns to it.
|
|
nested-values:
|
|
- match: '"""'
|
|
scope: punctuation.definition.string.begin.toml
|
|
push: multiline-basic
|
|
- match: "'''"
|
|
scope: punctuation.definition.string.begin.toml
|
|
push: multiline-literal
|
|
- match: '"'
|
|
scope: punctuation.definition.string.begin.toml
|
|
push: basic
|
|
- match: "'"
|
|
scope: punctuation.definition.string.begin.toml
|
|
push: literal
|
|
- match: '\['
|
|
scope: punctuation.definition.array.begin.toml
|
|
push: array
|
|
- match: '\{'
|
|
scope: punctuation.definition.inline-table.begin.toml
|
|
push: inline-table
|
|
- include: scalars |