Files
context-continuity/venv.old-py38/lib/python3.9/site-packages/pygments/lexers/json5.py
T
Master 943acbc573 feat: referentiel projets dynamique + validation nommage by design
Durcit la convention de nommage des projets (dérive constatée : 'Sliding
Automation', 'code_versioning'... au lieu des formes canoniques).

- trilium_api.py : projets_canoniques() lit le référentiel = valeurs du label
  projet sur les notes de type=projet (source unique, pas de constante en dur).
  Note-projet CodeVersioning créée (manquait).
- mcp_server.py : _valider_projet() branché dans les 6 tools de création
  (add_decision/history/backlog, new_conversation, create_entite, add_skill).
  Refuse un projet non canonique (suggestion si faute) ou inconnu (renvoi au
  processus de création de projet). Ne verrouille pas si référentiel illisible.
- lint_audit.py : VAL-nommage aligné sur le référentiel (attrape casse, espace
  ET snake_case ; l'ancien 'contient un espace' ratait code_versioning).
- Données : 79 notes ré-étiquetées vers les 3 formes canoniques.

Quality by design : l'erreur de nommage devient impossible à l'écriture, le
Lint n'est plus que le filet de sécurité.
2026-07-17 14:59:33 +02:00

84 lines
2.4 KiB
Python

"""
pygments.lexers.json5
~~~~~~~~~~~~~~~~~~~~~
Lexer for Json5 file format.
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from pygments.lexer import include, RegexLexer, words
from pygments.token import Comment, Keyword, Name, Number, Punctuation, \
String, Whitespace
__all__ = ['Json5Lexer']
def string_rules(quote_mark):
return [
(rf"[^{quote_mark}\\]+", String),
(r"\\.", String.Escape),
(r"\\", Punctuation),
(quote_mark, String, '#pop'),
]
def quoted_field_name(quote_mark):
return [
(rf'([^{quote_mark}\\]|\\.)*{quote_mark}',
Name.Variable, ('#pop', 'object_value'))
]
class Json5Lexer(RegexLexer):
"""Lexer for JSON5 data structures."""
name = 'JSON5'
aliases = ['json5']
filenames = ['*.json5']
url = "https://json5.org"
version_added = '2.19'
tokens = {
'_comments': [
(r'(//|#).*\n', Comment.Single),
(r'/\*\*([^/]|/(?!\*))*\*/', String.Doc),
(r'/\*([^/]|/(?!\*))*\*/', Comment),
],
'root': [
include('_comments'),
(r"'", String, 'singlestring'),
(r'"', String, 'doublestring'),
(r'[+-]?0[xX][0-9a-fA-F]+', Number.Hex),
(r'[+-.]?[0-9]+[.]?[0-9]?([eE][-]?[0-9]+)?', Number.Float),
(r'\{', Punctuation, 'object'),
(r'\[', Punctuation, 'array'),
(words(['false', 'Infinity', '+Infinity', '-Infinity', 'NaN',
'null', 'true',], suffix=r'\b'), Keyword),
(r'\s+', Whitespace),
(r':', Punctuation),
],
'singlestring': string_rules("'"),
'doublestring': string_rules('"'),
'array': [
(r',', Punctuation),
(r'\]', Punctuation, '#pop'),
include('root'),
],
'object': [
(r'\s+', Whitespace),
(r'\}', Punctuation, '#pop'),
(r'\b([^:]+)', Name.Variable, 'object_value'),
(r'"', Name.Variable, 'double_field_name'),
(r"'", Name.Variable, 'single_field_name'),
include('_comments'),
],
'double_field_name': quoted_field_name('"'),
'single_field_name': quoted_field_name("'"),
'object_value': [
(r',', Punctuation, '#pop'),
(r'\}', Punctuation, '#pop:2'),
include('root'),
],
}