f20080305d
Определение специфических рекомендаций (матрица профилей §8):
1. Ж/д слой (закрыт мёртвый railway ×2.5 у РАС):
- /api/v1/water/{case_id} отдаёт railway=rail как LineString
(без service/industrial/military веток), кэш общий v2;
- railway_warning «перекрыть/проверить немедленно» по профилям;
- SearchMap: Polyline слой ж/д (тёмно-красный), счётчики 💧/🚂.
2. cant_swim → профиль не_умеет_плавать (water ×3.0, без изменения
радиуса, critical_warning «обследовать водоёмы НЕМЕДЛЕННО»):
- раньше чекбокс влиял только на текст, в скоринге был пробел;
- derive в analyze._derive_profiles — работает и для closed_cases.
3. unmodeled_profiles: ДЦП/слабое зрение/слух — честная пометка
«вне поведенческой модели» с пояснением (vector_tasks B12:
профили без аналога не выдавать за учтённые); блок на фронте
в карточке здоровья.
Площадь воды: сферический эксцесс, проверен на квадрате 53° (744017 м²
vs 743272 точного). Тесты: 202 passed (новый test_cant_swim_profile).
103 lines
2.7 KiB
Python
103 lines
2.7 KiB
Python
"""
|
|
pygments.lexers.jsx
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
Lexers for JSX (React) and TSX (TypeScript flavor).
|
|
|
|
:copyright: Copyright 2006-present by the Pygments team, see AUTHORS.
|
|
:license: BSD, see LICENSE for details.
|
|
"""
|
|
|
|
import re
|
|
|
|
from pygments.lexer import bygroups, default, include, inherit
|
|
from pygments.lexers.javascript import JavascriptLexer, TypeScriptLexer
|
|
from pygments.token import Name, Operator, Punctuation, String, Text, \
|
|
Whitespace
|
|
|
|
__all__ = ['JsxLexer', 'TsxLexer']
|
|
|
|
_JSX_RULES = {
|
|
"jsx": [
|
|
(r"</?>", Punctuation), # JSXFragment <>|</>
|
|
(r"(<)(\w+)(\.?)", bygroups(Punctuation, Name.Tag, Punctuation), "tag"),
|
|
(
|
|
r"(</)(\w+)(>)",
|
|
bygroups(Punctuation, Name.Tag, Punctuation),
|
|
),
|
|
(
|
|
r"(</)(\w+)",
|
|
bygroups(Punctuation, Name.Tag),
|
|
"fragment",
|
|
), # Same for React.Context
|
|
],
|
|
"tag": [
|
|
(r"\s+", Whitespace),
|
|
(r"([\w-]+)(\s*)(=)(\s*)", bygroups(Name.Attribute, Whitespace, Operator, Whitespace), "attr"),
|
|
(r"[{}]+", Punctuation),
|
|
(r"[\w\.]+", Name.Attribute),
|
|
(r"(/?)(\s*)(>)", bygroups(Punctuation, Text, Punctuation), "#pop"),
|
|
],
|
|
"fragment": [
|
|
(r"(.)(\w+)", bygroups(Punctuation, Name.Attribute)),
|
|
(r"(>)", bygroups(Punctuation), "#pop"),
|
|
],
|
|
"attr": [
|
|
(r"\{", Punctuation, "expression"),
|
|
(r'".*?"', String, "#pop"),
|
|
(r"'.*?'", String, "#pop"),
|
|
default("#pop"),
|
|
],
|
|
"expression": [
|
|
(r"\{", Punctuation, "#push"),
|
|
(r"\}", Punctuation, "#pop"),
|
|
include("root"),
|
|
],
|
|
}
|
|
|
|
|
|
class JsxLexer(JavascriptLexer):
|
|
"""For JavaScript Syntax Extension (JSX).
|
|
"""
|
|
|
|
name = "JSX"
|
|
aliases = ["jsx", "react"]
|
|
filenames = ["*.jsx", "*.react"]
|
|
mimetypes = ["text/jsx", "text/typescript-jsx"]
|
|
url = "https://facebook.github.io/jsx/"
|
|
version_added = '2.17'
|
|
|
|
flags = re.MULTILINE | re.DOTALL
|
|
|
|
# Use same tokens as `JavascriptLexer`, but with tags and attributes support
|
|
tokens = {
|
|
"root": [
|
|
include("jsx"),
|
|
inherit,
|
|
(r"'", Text),
|
|
],
|
|
**_JSX_RULES}
|
|
|
|
|
|
class TsxLexer(TypeScriptLexer):
|
|
"""For TypeScript with embedded JSX
|
|
"""
|
|
|
|
name = "TSX"
|
|
aliases = ["tsx"]
|
|
filenames = ["*.tsx"]
|
|
mimetypes = ["text/typescript-tsx"]
|
|
url = "https://www.typescriptlang.org/docs/handbook/jsx.html"
|
|
version_added = '2.19'
|
|
|
|
flags = re.MULTILINE | re.DOTALL
|
|
|
|
# Use same tokens as `TypescriptLexer`, but with tags and attributes support
|
|
tokens = {
|
|
"root": [
|
|
include("jsx"),
|
|
inherit,
|
|
(r"'", Text),
|
|
],
|
|
**_JSX_RULES}
|