@driftsys/markspec 0.10.3 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/esm/ast/normalize.d.ts +4 -5
- package/esm/ast/normalize.d.ts.map +1 -1
- package/esm/ast/normalize.js +6 -37
- package/esm/collect/mod.d.ts +29 -9
- package/esm/collect/mod.d.ts.map +1 -1
- package/esm/collect/mod.js +36 -10
- package/esm/compiler/deserialize.d.ts +49 -0
- package/esm/compiler/deserialize.d.ts.map +1 -0
- package/esm/compiler/deserialize.js +139 -0
- package/esm/compiler/manifest.d.ts +3 -0
- package/esm/compiler/manifest.d.ts.map +1 -1
- package/esm/compiler/manifest.js +9 -3
- package/esm/compiler/mod.d.ts.map +1 -1
- package/esm/compiler/mod.js +18 -13
- package/esm/config/markspec.d.ts +40 -1
- package/esm/config/markspec.d.ts.map +1 -1
- package/esm/config/markspec.js +127 -2
- package/esm/config/mod.d.ts.map +1 -1
- package/esm/config/mod.js +143 -147
- package/esm/decl/duplicates.d.ts +29 -0
- package/esm/decl/duplicates.d.ts.map +1 -0
- package/esm/decl/duplicates.js +28 -0
- package/esm/decl/mod.d.ts +4 -2
- package/esm/decl/mod.d.ts.map +1 -1
- package/esm/decl/mod.js +2 -1
- package/esm/decl/surfaces.d.ts +29 -7
- package/esm/decl/surfaces.d.ts.map +1 -1
- package/esm/decl/surfaces.js +31 -18
- package/esm/discovery/mod.d.ts +24 -8
- package/esm/discovery/mod.d.ts.map +1 -1
- package/esm/discovery/mod.js +57 -21
- package/esm/discovery/projects.d.ts +109 -0
- package/esm/discovery/projects.d.ts.map +1 -0
- package/esm/discovery/projects.js +232 -0
- package/esm/formatter/entry_body.d.ts +86 -0
- package/esm/formatter/entry_body.d.ts.map +1 -0
- package/esm/formatter/entry_body.js +287 -0
- package/esm/formatter/mod.d.ts +13 -9
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +126 -50
- package/esm/gates/mod.d.ts +13 -2
- package/esm/gates/mod.d.ts.map +1 -1
- package/esm/gates/mod.js +41 -13
- package/esm/lint/runner.d.ts.map +1 -1
- package/esm/lint/runner.js +7 -5
- package/esm/lock/acquire_compile.d.ts +31 -0
- package/esm/lock/acquire_compile.d.ts.map +1 -0
- package/esm/lock/acquire_compile.js +83 -0
- package/esm/lock/cache_check.d.ts +28 -0
- package/esm/lock/cache_check.d.ts.map +1 -0
- package/esm/lock/cache_check.js +51 -0
- package/esm/lock/check.d.ts +14 -3
- package/esm/lock/check.d.ts.map +1 -1
- package/esm/lock/check.js +43 -4
- package/esm/lock/edge_drift.d.ts +2 -0
- package/esm/lock/edge_drift.d.ts.map +1 -1
- package/esm/lock/edge_drift.js +4 -0
- package/esm/lock/git_intent.d.ts +46 -0
- package/esm/lock/git_intent.d.ts.map +1 -0
- package/esm/lock/git_intent.js +111 -0
- package/esm/lock/mod.d.ts +11 -4
- package/esm/lock/mod.d.ts.map +1 -1
- package/esm/lock/mod.js +8 -2
- package/esm/lock/model.d.ts +24 -1
- package/esm/lock/model.d.ts.map +1 -1
- package/esm/lock/parser.d.ts.map +1 -1
- package/esm/lock/parser.js +32 -0
- package/esm/lock/pin_assurance.d.ts +20 -0
- package/esm/lock/pin_assurance.d.ts.map +1 -0
- package/esm/lock/pin_assurance.js +34 -0
- package/esm/lock/resolve.d.ts +8 -17
- package/esm/lock/resolve.d.ts.map +1 -1
- package/esm/lock/resolve.js +7 -67
- package/esm/lock/serializer.d.ts.map +1 -1
- package/esm/lock/serializer.js +23 -0
- package/esm/lock/upstream_common.d.ts +29 -0
- package/esm/lock/upstream_common.d.ts.map +1 -0
- package/esm/lock/upstream_common.js +38 -0
- package/esm/lock/upstream_deps.d.ts +63 -0
- package/esm/lock/upstream_deps.d.ts.map +1 -0
- package/esm/lock/upstream_deps.js +172 -0
- package/esm/lock/upstream_refs.d.ts +69 -0
- package/esm/lock/upstream_refs.d.ts.map +1 -0
- package/esm/lock/upstream_refs.js +238 -0
- package/esm/mod.d.ts +23 -11
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +20 -8
- package/esm/model/mod.d.ts +114 -28
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +76 -13
- package/esm/model/profile.d.ts +13 -0
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/parser/code_regions.d.ts +29 -0
- package/esm/parser/code_regions.d.ts.map +1 -0
- package/esm/parser/code_regions.js +38 -0
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +110 -91
- package/esm/parser/mod.d.ts.map +1 -1
- package/esm/parser/mod.js +7 -1
- package/esm/parser/translate.d.ts.map +1 -1
- package/esm/parser/translate.js +5 -0
- package/esm/profile/manifest.d.ts.map +1 -1
- package/esm/profile/manifest.js +20 -3
- package/esm/profile/merge.js +7 -0
- package/esm/refs/mod.d.ts.map +1 -1
- package/esm/refs/mod.js +8 -19
- package/esm/reporter/mod.d.ts +11 -0
- package/esm/reporter/mod.d.ts.map +1 -1
- package/esm/reporter/mod.js +20 -9
- package/esm/typl/assemble.d.ts +53 -0
- package/esm/typl/assemble.d.ts.map +1 -0
- package/esm/typl/assemble.js +238 -0
- package/esm/typl/ast.d.ts +7 -1
- package/esm/typl/ast.d.ts.map +1 -1
- package/esm/typl/ast.js +3 -0
- package/esm/typl/bullet.d.ts +9 -7
- package/esm/typl/bullet.d.ts.map +1 -1
- package/esm/typl/bullet.js +6 -4
- package/esm/typl/citations.d.ts +27 -0
- package/esm/typl/citations.d.ts.map +1 -0
- package/esm/typl/citations.js +16 -0
- package/esm/typl/diagnostics.d.ts +2 -2
- package/esm/typl/diagnostics.d.ts.map +1 -1
- package/esm/typl/diagnostics.js +18 -0
- package/esm/typl/grammar.d.ts.map +1 -1
- package/esm/typl/grammar.js +6 -0
- package/esm/typl/lexer.d.ts.map +1 -1
- package/esm/typl/lexer.js +25 -4
- package/esm/typl/mod.d.ts +8 -2
- package/esm/typl/mod.d.ts.map +1 -1
- package/esm/typl/mod.js +5 -1
- package/esm/typl/recognize.js +2 -2
- package/esm/typl/registry.d.ts +1 -1
- package/esm/typl/resolve.d.ts +31 -0
- package/esm/typl/resolve.d.ts.map +1 -0
- package/esm/typl/resolve.js +27 -0
- package/esm/typl/table.d.ts +52 -0
- package/esm/typl/table.d.ts.map +1 -0
- package/esm/typl/table.js +69 -0
- package/esm/typl/validator.d.ts +24 -5
- package/esm/typl/validator.d.ts.map +1 -1
- package/esm/typl/validator.js +55 -75
- package/esm/upstream/mod.d.ts +45 -0
- package/esm/upstream/mod.d.ts.map +1 -0
- package/esm/upstream/mod.js +98 -0
- package/esm/upstream/project.d.ts +33 -0
- package/esm/upstream/project.d.ts.map +1 -0
- package/esm/upstream/project.js +38 -0
- package/esm/upstream/refs.d.ts +23 -0
- package/esm/upstream/refs.d.ts.map +1 -0
- package/esm/upstream/refs.js +71 -0
- package/esm/util/fence.d.ts +20 -29
- package/esm/util/fence.d.ts.map +1 -1
- package/esm/util/fence.js +42 -50
- package/esm/util/modals.d.ts +6 -0
- package/esm/util/modals.d.ts.map +1 -1
- package/esm/util/modals.js +37 -0
- package/esm/util/paths.d.ts +14 -0
- package/esm/util/paths.d.ts.map +1 -0
- package/esm/util/paths.js +22 -0
- package/esm/uxil/assemble.d.ts +38 -0
- package/esm/uxil/assemble.d.ts.map +1 -0
- package/esm/uxil/assemble.js +268 -0
- package/esm/uxil/ast.d.ts +63 -0
- package/esm/uxil/ast.d.ts.map +1 -0
- package/esm/uxil/ast.js +9 -0
- package/esm/uxil/citations.d.ts +27 -0
- package/esm/uxil/citations.d.ts.map +1 -0
- package/esm/uxil/citations.js +25 -0
- package/esm/uxil/diagnostics.d.ts +39 -0
- package/esm/uxil/diagnostics.d.ts.map +1 -0
- package/esm/uxil/diagnostics.js +135 -0
- package/esm/uxil/grammar.d.ts +72 -0
- package/esm/uxil/grammar.d.ts.map +1 -0
- package/esm/uxil/grammar.js +505 -0
- package/esm/uxil/lexer.d.ts +23 -0
- package/esm/uxil/lexer.d.ts.map +1 -0
- package/esm/uxil/lexer.js +58 -0
- package/esm/uxil/mod.d.ts +32 -0
- package/esm/uxil/mod.d.ts.map +1 -0
- package/esm/uxil/mod.js +11 -0
- package/esm/uxil/projection.d.ts +40 -0
- package/esm/uxil/projection.d.ts.map +1 -0
- package/esm/uxil/projection.js +41 -0
- package/esm/uxil/recognize.d.ts +16 -0
- package/esm/uxil/recognize.d.ts.map +1 -0
- package/esm/uxil/recognize.js +28 -0
- package/esm/uxil/registry.d.ts +37 -0
- package/esm/uxil/registry.d.ts.map +1 -0
- package/esm/uxil/registry.js +29 -0
- package/esm/uxil/surfaces.d.ts +36 -0
- package/esm/uxil/surfaces.d.ts.map +1 -0
- package/esm/uxil/surfaces.js +34 -0
- package/esm/uxil/validator.d.ts +36 -0
- package/esm/uxil/validator.d.ts.map +1 -0
- package/esm/uxil/validator.js +139 -0
- package/esm/uxil/vocab.d.ts +33 -0
- package/esm/uxil/vocab.d.ts.map +1 -0
- package/esm/uxil/vocab.js +36 -0
- package/esm/validator/body_blocks.d.ts +2 -1
- package/esm/validator/body_blocks.d.ts.map +1 -1
- package/esm/validator/body_blocks.js +80 -2
- package/esm/validator/caption_convention.d.ts +2 -1
- package/esm/validator/caption_convention.d.ts.map +1 -1
- package/esm/validator/caption_convention.js +2 -1
- package/esm/validator/corpus.d.ts +6 -0
- package/esm/validator/corpus.d.ts.map +1 -1
- package/esm/validator/corpus.js +55 -20
- package/esm/validator/discipline.d.ts +6 -4
- package/esm/validator/discipline.d.ts.map +1 -1
- package/esm/validator/discipline.js +6 -4
- package/esm/validator/mod.d.ts +1 -1
- package/esm/validator/mod.d.ts.map +1 -1
- package/esm/validator/mod.js +29 -16
- package/esm/validator/pipeline.d.ts +11 -1
- package/esm/validator/pipeline.d.ts.map +1 -1
- package/esm/validator/pipeline.js +76 -23
- package/esm/validator/trace_types.d.ts +9 -2
- package/esm/validator/trace_types.d.ts.map +1 -1
- package/esm/validator/trace_types.js +21 -5
- package/esm/validator/traceability.d.ts +15 -3
- package/esm/validator/traceability.d.ts.map +1 -1
- package/esm/validator/traceability.js +39 -4
- package/esm/validator/types.d.ts.map +1 -1
- package/esm/validator/types.js +11 -1
- package/esm/validator/uxil_family.d.ts +43 -0
- package/esm/validator/uxil_family.d.ts.map +1 -0
- package/esm/validator/uxil_family.js +52 -0
- package/package.json +1 -1
- package/script/ast/normalize.d.ts +4 -5
- package/script/ast/normalize.d.ts.map +1 -1
- package/script/ast/normalize.js +5 -36
- package/script/collect/mod.d.ts +29 -9
- package/script/collect/mod.d.ts.map +1 -1
- package/script/collect/mod.js +38 -10
- package/script/compiler/deserialize.d.ts +49 -0
- package/script/compiler/deserialize.d.ts.map +1 -0
- package/script/compiler/deserialize.js +144 -0
- package/script/compiler/manifest.d.ts +3 -0
- package/script/compiler/manifest.d.ts.map +1 -1
- package/script/compiler/manifest.js +10 -3
- package/script/compiler/mod.d.ts.map +1 -1
- package/script/compiler/mod.js +16 -11
- package/script/config/markspec.d.ts +40 -1
- package/script/config/markspec.d.ts.map +1 -1
- package/script/config/markspec.js +129 -3
- package/script/config/mod.d.ts.map +1 -1
- package/script/config/mod.js +143 -147
- package/script/decl/duplicates.d.ts +29 -0
- package/script/decl/duplicates.d.ts.map +1 -0
- package/script/decl/duplicates.js +31 -0
- package/script/decl/mod.d.ts +4 -2
- package/script/decl/mod.d.ts.map +1 -1
- package/script/decl/mod.js +4 -2
- package/script/decl/surfaces.d.ts +29 -7
- package/script/decl/surfaces.d.ts.map +1 -1
- package/script/decl/surfaces.js +32 -19
- package/script/discovery/mod.d.ts +24 -8
- package/script/discovery/mod.d.ts.map +1 -1
- package/script/discovery/mod.js +56 -20
- package/script/discovery/projects.d.ts +109 -0
- package/script/discovery/projects.d.ts.map +1 -0
- package/script/discovery/projects.js +240 -0
- package/script/formatter/entry_body.d.ts +86 -0
- package/script/formatter/entry_body.d.ts.map +1 -0
- package/script/formatter/entry_body.js +292 -0
- package/script/formatter/mod.d.ts +13 -9
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +124 -48
- package/script/gates/mod.d.ts +13 -2
- package/script/gates/mod.d.ts.map +1 -1
- package/script/gates/mod.js +50 -22
- package/script/lint/runner.d.ts.map +1 -1
- package/script/lint/runner.js +6 -4
- package/script/lock/acquire_compile.d.ts +31 -0
- package/script/lock/acquire_compile.d.ts.map +1 -0
- package/script/lock/acquire_compile.js +86 -0
- package/script/lock/cache_check.d.ts +28 -0
- package/script/lock/cache_check.d.ts.map +1 -0
- package/script/lock/cache_check.js +54 -0
- package/script/lock/check.d.ts +14 -3
- package/script/lock/check.d.ts.map +1 -1
- package/script/lock/check.js +43 -4
- package/script/lock/edge_drift.d.ts +2 -0
- package/script/lock/edge_drift.d.ts.map +1 -1
- package/script/lock/edge_drift.js +5 -0
- package/script/lock/git_intent.d.ts +46 -0
- package/script/lock/git_intent.d.ts.map +1 -0
- package/script/lock/git_intent.js +115 -0
- package/script/lock/mod.d.ts +11 -4
- package/script/lock/mod.d.ts.map +1 -1
- package/script/lock/mod.js +17 -2
- package/script/lock/model.d.ts +24 -1
- package/script/lock/model.d.ts.map +1 -1
- package/script/lock/parser.d.ts.map +1 -1
- package/script/lock/parser.js +32 -0
- package/script/lock/pin_assurance.d.ts +20 -0
- package/script/lock/pin_assurance.d.ts.map +1 -0
- package/script/lock/pin_assurance.js +37 -0
- package/script/lock/resolve.d.ts +8 -17
- package/script/lock/resolve.d.ts.map +1 -1
- package/script/lock/resolve.js +7 -68
- package/script/lock/serializer.d.ts.map +1 -1
- package/script/lock/serializer.js +23 -0
- package/script/lock/upstream_common.d.ts +29 -0
- package/script/lock/upstream_common.d.ts.map +1 -0
- package/script/lock/upstream_common.js +42 -0
- package/script/lock/upstream_deps.d.ts +63 -0
- package/script/lock/upstream_deps.d.ts.map +1 -0
- package/script/lock/upstream_deps.js +175 -0
- package/script/lock/upstream_refs.d.ts +69 -0
- package/script/lock/upstream_refs.d.ts.map +1 -0
- package/script/lock/upstream_refs.js +244 -0
- package/script/mod.d.ts +23 -11
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +55 -7
- package/script/model/mod.d.ts +114 -28
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +81 -14
- package/script/model/profile.d.ts +13 -0
- package/script/model/profile.d.ts.map +1 -1
- package/script/parser/code_regions.d.ts +29 -0
- package/script/parser/code_regions.d.ts.map +1 -0
- package/script/parser/code_regions.js +41 -0
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +108 -89
- package/script/parser/mod.d.ts.map +1 -1
- package/script/parser/mod.js +7 -1
- package/script/parser/translate.d.ts.map +1 -1
- package/script/parser/translate.js +5 -0
- package/script/profile/manifest.d.ts.map +1 -1
- package/script/profile/manifest.js +20 -3
- package/script/profile/merge.js +7 -0
- package/script/refs/mod.d.ts.map +1 -1
- package/script/refs/mod.js +7 -18
- package/script/reporter/mod.d.ts +11 -0
- package/script/reporter/mod.d.ts.map +1 -1
- package/script/reporter/mod.js +19 -8
- package/script/typl/assemble.d.ts +53 -0
- package/script/typl/assemble.d.ts.map +1 -0
- package/script/typl/assemble.js +241 -0
- package/script/typl/ast.d.ts +7 -1
- package/script/typl/ast.d.ts.map +1 -1
- package/script/typl/ast.js +3 -0
- package/script/typl/bullet.d.ts +9 -7
- package/script/typl/bullet.d.ts.map +1 -1
- package/script/typl/bullet.js +6 -4
- package/script/typl/citations.d.ts +27 -0
- package/script/typl/citations.d.ts.map +1 -0
- package/script/typl/citations.js +20 -0
- package/script/typl/diagnostics.d.ts +2 -2
- package/script/typl/diagnostics.d.ts.map +1 -1
- package/script/typl/diagnostics.js +18 -0
- package/script/typl/grammar.d.ts.map +1 -1
- package/script/typl/grammar.js +6 -0
- package/script/typl/lexer.d.ts.map +1 -1
- package/script/typl/lexer.js +25 -4
- package/script/typl/mod.d.ts +8 -2
- package/script/typl/mod.d.ts.map +1 -1
- package/script/typl/mod.js +14 -2
- package/script/typl/recognize.js +2 -2
- package/script/typl/registry.d.ts +1 -1
- package/script/typl/resolve.d.ts +31 -0
- package/script/typl/resolve.d.ts.map +1 -0
- package/script/typl/resolve.js +33 -0
- package/script/typl/table.d.ts +52 -0
- package/script/typl/table.d.ts.map +1 -0
- package/script/typl/table.js +75 -0
- package/script/typl/validator.d.ts +24 -5
- package/script/typl/validator.d.ts.map +1 -1
- package/script/typl/validator.js +55 -75
- package/script/upstream/mod.d.ts +45 -0
- package/script/upstream/mod.d.ts.map +1 -0
- package/script/upstream/mod.js +101 -0
- package/script/upstream/project.d.ts +33 -0
- package/script/upstream/project.d.ts.map +1 -0
- package/script/upstream/project.js +41 -0
- package/script/upstream/refs.d.ts +23 -0
- package/script/upstream/refs.d.ts.map +1 -0
- package/script/upstream/refs.js +74 -0
- package/script/util/fence.d.ts +20 -29
- package/script/util/fence.d.ts.map +1 -1
- package/script/util/fence.js +47 -54
- package/script/util/modals.d.ts +6 -0
- package/script/util/modals.d.ts.map +1 -1
- package/script/util/modals.js +38 -0
- package/script/util/paths.d.ts +14 -0
- package/script/util/paths.d.ts.map +1 -0
- package/script/util/paths.js +25 -0
- package/script/uxil/assemble.d.ts +38 -0
- package/script/uxil/assemble.d.ts.map +1 -0
- package/script/uxil/assemble.js +272 -0
- package/script/uxil/ast.d.ts +63 -0
- package/script/uxil/ast.d.ts.map +1 -0
- package/script/uxil/ast.js +10 -0
- package/script/uxil/citations.d.ts +27 -0
- package/script/uxil/citations.d.ts.map +1 -0
- package/script/uxil/citations.js +29 -0
- package/script/uxil/diagnostics.d.ts +39 -0
- package/script/uxil/diagnostics.d.ts.map +1 -0
- package/script/uxil/diagnostics.js +140 -0
- package/script/uxil/grammar.d.ts +72 -0
- package/script/uxil/grammar.d.ts.map +1 -0
- package/script/uxil/grammar.js +511 -0
- package/script/uxil/lexer.d.ts +23 -0
- package/script/uxil/lexer.d.ts.map +1 -0
- package/script/uxil/lexer.js +61 -0
- package/script/uxil/mod.d.ts +32 -0
- package/script/uxil/mod.d.ts.map +1 -0
- package/script/uxil/mod.js +37 -0
- package/script/uxil/projection.d.ts +40 -0
- package/script/uxil/projection.d.ts.map +1 -0
- package/script/uxil/projection.js +44 -0
- package/script/uxil/recognize.d.ts +16 -0
- package/script/uxil/recognize.d.ts.map +1 -0
- package/script/uxil/recognize.js +31 -0
- package/script/uxil/registry.d.ts +37 -0
- package/script/uxil/registry.d.ts.map +1 -0
- package/script/uxil/registry.js +32 -0
- package/script/uxil/surfaces.d.ts +36 -0
- package/script/uxil/surfaces.d.ts.map +1 -0
- package/script/uxil/surfaces.js +39 -0
- package/script/uxil/validator.d.ts +36 -0
- package/script/uxil/validator.d.ts.map +1 -0
- package/script/uxil/validator.js +142 -0
- package/script/uxil/vocab.d.ts +33 -0
- package/script/uxil/vocab.d.ts.map +1 -0
- package/script/uxil/vocab.js +41 -0
- package/script/validator/body_blocks.d.ts +2 -1
- package/script/validator/body_blocks.d.ts.map +1 -1
- package/script/validator/body_blocks.js +80 -2
- package/script/validator/caption_convention.d.ts +2 -1
- package/script/validator/caption_convention.d.ts.map +1 -1
- package/script/validator/caption_convention.js +2 -1
- package/script/validator/corpus.d.ts +6 -0
- package/script/validator/corpus.d.ts.map +1 -1
- package/script/validator/corpus.js +55 -19
- package/script/validator/discipline.d.ts +6 -4
- package/script/validator/discipline.d.ts.map +1 -1
- package/script/validator/discipline.js +6 -4
- package/script/validator/mod.d.ts +1 -1
- package/script/validator/mod.d.ts.map +1 -1
- package/script/validator/mod.js +29 -15
- package/script/validator/pipeline.d.ts +11 -1
- package/script/validator/pipeline.d.ts.map +1 -1
- package/script/validator/pipeline.js +75 -22
- package/script/validator/trace_types.d.ts +9 -2
- package/script/validator/trace_types.d.ts.map +1 -1
- package/script/validator/trace_types.js +20 -4
- package/script/validator/traceability.d.ts +15 -3
- package/script/validator/traceability.d.ts.map +1 -1
- package/script/validator/traceability.js +38 -3
- package/script/validator/types.d.ts.map +1 -1
- package/script/validator/types.js +10 -0
- package/script/validator/uxil_family.d.ts +43 -0
- package/script/validator/uxil_family.d.ts.map +1 -0
- package/script/validator/uxil_family.js +56 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module core/discovery/projects
|
|
3
|
+
*
|
|
4
|
+
* Project-root discovery shared by the CLI, the LSP and the MCP server.
|
|
5
|
+
*
|
|
6
|
+
* A "project root" is a directory that holds a `project.yaml` or a
|
|
7
|
+
* `.markspec.yaml`. {@linkcode discoverProjectRoots} finds the primary
|
|
8
|
+
* root by walking up from a start folder, then every nested root below
|
|
9
|
+
* it with the gitignore-aware file walk.
|
|
10
|
+
*/
|
|
11
|
+
import { basename, dirname, isAbsolute, relative, SEPARATOR } from "@std/path";
|
|
12
|
+
import { discoverProjectRoot } from "../config/mod.js";
|
|
13
|
+
import { discoverMarkspecRoot, loadToolConfig } from "../config/markspec.js";
|
|
14
|
+
import { discoverFiles } from "./mod.js";
|
|
15
|
+
import { isIgnored, parseGitignore } from "./gitignore.js";
|
|
16
|
+
/** The file names whose directory can be a project root. */
|
|
17
|
+
const CONFIG_BASENAMES = new Set([
|
|
18
|
+
"project.yaml",
|
|
19
|
+
".markspec.yaml",
|
|
20
|
+
]);
|
|
21
|
+
/** `true` when `path` is `root` itself or lies below it. */
|
|
22
|
+
export function isWithin(root, path) {
|
|
23
|
+
const rel = relative(root, path);
|
|
24
|
+
// A child directory may itself start with `..` (e.g. `..cache`), so
|
|
25
|
+
// compare whole path segments, not a string prefix.
|
|
26
|
+
return rel === "" ||
|
|
27
|
+
(rel !== ".." && !rel.startsWith(`..${SEPARATOR}`) && !isAbsolute(rel));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Return the deepest root in `roots` that is `dir` itself or an ancestor
|
|
31
|
+
* of `dir`, or `undefined` when none is.
|
|
32
|
+
*/
|
|
33
|
+
export function nearestRoot(dir, roots) {
|
|
34
|
+
let best;
|
|
35
|
+
for (const root of roots) {
|
|
36
|
+
if (!isWithin(root, dir))
|
|
37
|
+
continue;
|
|
38
|
+
if (best === undefined || root.length > best.length)
|
|
39
|
+
best = root;
|
|
40
|
+
}
|
|
41
|
+
return best;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Walk up from `startDir` to the nearest `project.yaml`, else the nearest
|
|
45
|
+
* `.markspec.yaml`. Returns `undefined` when neither exists.
|
|
46
|
+
*
|
|
47
|
+
* The LSP server and the MCP server use this order to find the root
|
|
48
|
+
* above their workspace. The CLI (`check`, `fmt`, `lint`) uses
|
|
49
|
+
* {@linkcode createProjectRootResolver}, which starts from this nearest
|
|
50
|
+
* config root but skips a config that an enclosing project hides (#845).
|
|
51
|
+
*/
|
|
52
|
+
export async function resolveConfigRoot(startDir, readFile) {
|
|
53
|
+
return await discoverProjectRoot(startDir, readFile) ??
|
|
54
|
+
await discoverMarkspecRoot(startDir, readFile);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Directories strictly below `root` that a document walk-up would
|
|
58
|
+
* resolve to, found with the gitignore-aware project walk (honouring
|
|
59
|
+
* `exclude`). Each discovered `project.yaml` or `.markspec.yaml` is
|
|
60
|
+
* resolved with {@linkcode resolveConfigRoot} from its own directory, so a
|
|
61
|
+
* `.markspec.yaml` below a `project.yaml` is not a root of its own — the
|
|
62
|
+
* same answer the CLI gives for a file there. A found root is dropped when
|
|
63
|
+
* the `.markspec.yaml` `exclude:` list of another found root above it
|
|
64
|
+
* covers it: each project's exclude list applies to its own subtree, with
|
|
65
|
+
* patterns relative to that project. The result is sorted.
|
|
66
|
+
*/
|
|
67
|
+
export async function findNestedProjectRoots(root, io, exclude) {
|
|
68
|
+
const out = new Set();
|
|
69
|
+
for await (const path of discoverFiles(root, io, {
|
|
70
|
+
extensions: new Set([".yaml"]),
|
|
71
|
+
exclude,
|
|
72
|
+
})) {
|
|
73
|
+
if (!CONFIG_BASENAMES.has(basename(path)))
|
|
74
|
+
continue;
|
|
75
|
+
const dir = dirname(path);
|
|
76
|
+
if (dir === root)
|
|
77
|
+
continue;
|
|
78
|
+
const found = await resolveConfigRoot(dir, io.readFile);
|
|
79
|
+
if (found !== undefined && found !== root && isWithin(root, found)) {
|
|
80
|
+
out.add(found);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const nested = [...out];
|
|
84
|
+
const excludeRules = new Map();
|
|
85
|
+
const kept = [];
|
|
86
|
+
for (const candidate of nested) {
|
|
87
|
+
let covered = false;
|
|
88
|
+
for (const ancestor of nested) {
|
|
89
|
+
if (ancestor === candidate || !isWithin(ancestor, candidate))
|
|
90
|
+
continue;
|
|
91
|
+
let rules = excludeRules.get(ancestor);
|
|
92
|
+
if (rules === undefined) {
|
|
93
|
+
const { config } = await loadToolConfig(ancestor, io.readFile);
|
|
94
|
+
rules = parseGitignore(config.exclude.join("\n"), "");
|
|
95
|
+
excludeRules.set(ancestor, rules);
|
|
96
|
+
}
|
|
97
|
+
if (isExcludedDir(relative(ancestor, candidate), rules)) {
|
|
98
|
+
covered = true;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (!covered)
|
|
103
|
+
kept.push(candidate);
|
|
104
|
+
}
|
|
105
|
+
return kept.sort();
|
|
106
|
+
}
|
|
107
|
+
/** `true` when the directory at `rel` (relative, host separators), or any
|
|
108
|
+
* directory above it, matches `rules` — the same pruning the walk does. */
|
|
109
|
+
function isExcludedDir(rel, rules) {
|
|
110
|
+
if (rules.length === 0)
|
|
111
|
+
return false;
|
|
112
|
+
const segments = rel.split(SEPARATOR);
|
|
113
|
+
for (let i = 1; i <= segments.length; i++) {
|
|
114
|
+
if (isIgnored(segments.slice(0, i).join("/"), true, rules))
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Find every MarkSpec project reachable from `startDir`.
|
|
121
|
+
*
|
|
122
|
+
* `primaryRoot` is the nearest config root found by walking up from
|
|
123
|
+
* `startDir` (see {@linkcode resolveConfigRoot}), or `startDir` itself
|
|
124
|
+
* when there is none. `roots` holds the primary root (only when it has a
|
|
125
|
+
* config) plus every nested root below it, sorted. The nested scan honours
|
|
126
|
+
* the primary project's `.markspec.yaml` `exclude:` list, and each nested
|
|
127
|
+
* project's own list for the folders below it.
|
|
128
|
+
*
|
|
129
|
+
* When the primary root is a filesystem root or `options.homeDir`, no
|
|
130
|
+
* downward scan runs, even when that folder holds a config: `roots` then
|
|
131
|
+
* holds only the primary root when it has a config, and is empty
|
|
132
|
+
* otherwise.
|
|
133
|
+
*/
|
|
134
|
+
export async function discoverProjectRoots(startDir, io, options = {}) {
|
|
135
|
+
const configRoot = await resolveConfigRoot(startDir, io.readFile);
|
|
136
|
+
const primaryRoot = configRoot ?? startDir;
|
|
137
|
+
const isFilesystemRoot = dirname(primaryRoot) === primaryRoot;
|
|
138
|
+
if (isFilesystemRoot || primaryRoot === options.homeDir) {
|
|
139
|
+
return {
|
|
140
|
+
primaryRoot,
|
|
141
|
+
roots: configRoot !== undefined ? [primaryRoot] : [],
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const { config } = configRoot !== undefined
|
|
145
|
+
? await loadToolConfig(primaryRoot, io.readFile)
|
|
146
|
+
: { config: undefined };
|
|
147
|
+
const nested = await findNestedProjectRoots(primaryRoot, io, config?.exclude);
|
|
148
|
+
const roots = configRoot !== undefined ? [primaryRoot, ...nested] : nested;
|
|
149
|
+
return { primaryRoot, roots: roots.sort() };
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Create a resolver that gives, for any folder, the project root the LSP
|
|
153
|
+
* would give a document in that folder when the editor workspace is the
|
|
154
|
+
* outermost project root above it (#845).
|
|
155
|
+
*
|
|
156
|
+
* The nearest config root {@linkcode resolveConfigRoot} finds is not
|
|
157
|
+
* always the owner: when an enclosing project hides that config (an
|
|
158
|
+
* `exclude:` entry, a `.gitignore` entry, a hidden folder), the LSP and
|
|
159
|
+
* the MCP server never treat it as a root, and its files belong to the
|
|
160
|
+
* enclosing project. So the resolver walks up from the nearest config
|
|
161
|
+
* root to the outermost enclosing one, finds the nested roots below that
|
|
162
|
+
* outermost root the way the LSP does, and returns the deepest of them
|
|
163
|
+
* that contains `dir`.
|
|
164
|
+
*
|
|
165
|
+
* The walk up stops before a filesystem root and before
|
|
166
|
+
* `options.homeDir`: {@linkcode discoverProjectRoots} never scans down
|
|
167
|
+
* from those folders, so a stray config there must not claim every
|
|
168
|
+
* project below it. Results are cached per folder.
|
|
169
|
+
*/
|
|
170
|
+
export function createProjectRootResolver(io, options = {}) {
|
|
171
|
+
const owners = new Map();
|
|
172
|
+
const outermosts = new Map();
|
|
173
|
+
const nested = new Map();
|
|
174
|
+
function nestedRoots(root) {
|
|
175
|
+
let found = nested.get(root);
|
|
176
|
+
if (found === undefined) {
|
|
177
|
+
found = loadToolConfig(root, io.readFile).then(({ config }) => findNestedProjectRoots(root, io, config.exclude));
|
|
178
|
+
nested.set(root, found);
|
|
179
|
+
}
|
|
180
|
+
return found;
|
|
181
|
+
}
|
|
182
|
+
function outermostOf(dir) {
|
|
183
|
+
let found = outermosts.get(dir);
|
|
184
|
+
if (found === undefined) {
|
|
185
|
+
found = resolveOutermost(dir);
|
|
186
|
+
outermosts.set(dir, found);
|
|
187
|
+
}
|
|
188
|
+
return found;
|
|
189
|
+
}
|
|
190
|
+
async function resolveOutermost(dir) {
|
|
191
|
+
const nearest = await resolveConfigRoot(dir, io.readFile);
|
|
192
|
+
return nearest === undefined ? undefined : await outermostFrom(nearest);
|
|
193
|
+
}
|
|
194
|
+
/** Walk up from the config root `nearest` to the outermost one. */
|
|
195
|
+
async function outermostFrom(nearest) {
|
|
196
|
+
let outermost = nearest;
|
|
197
|
+
while (true) {
|
|
198
|
+
const parent = dirname(outermost);
|
|
199
|
+
if (parent === outermost)
|
|
200
|
+
break;
|
|
201
|
+
const above = await resolveConfigRoot(parent, io.readFile);
|
|
202
|
+
if (above === undefined || dirname(above) === above ||
|
|
203
|
+
above === options.homeDir) {
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
outermost = above;
|
|
207
|
+
}
|
|
208
|
+
return outermost;
|
|
209
|
+
}
|
|
210
|
+
async function resolveOwner(dir) {
|
|
211
|
+
const nearest = await resolveConfigRoot(dir, io.readFile);
|
|
212
|
+
if (nearest === undefined)
|
|
213
|
+
return undefined;
|
|
214
|
+
const outermost = await outermostFrom(nearest);
|
|
215
|
+
if (outermost === nearest)
|
|
216
|
+
return nearest;
|
|
217
|
+
const roots = [outermost, ...await nestedRoots(outermost)];
|
|
218
|
+
return nearestRoot(dir, roots) ?? outermost;
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
ownerOf(dir) {
|
|
222
|
+
let owner = owners.get(dir);
|
|
223
|
+
if (owner === undefined) {
|
|
224
|
+
owner = resolveOwner(dir);
|
|
225
|
+
owners.set(dir, owner);
|
|
226
|
+
}
|
|
227
|
+
return owner;
|
|
228
|
+
},
|
|
229
|
+
nestedRoots,
|
|
230
|
+
outermostOf,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formatter/entry_body
|
|
3
|
+
*
|
|
4
|
+
* Read and replace the body of one entry in a Markdown file text.
|
|
5
|
+
*
|
|
6
|
+
* Splice-only contract: {@linkcode replaceEntryBody} changes only the
|
|
7
|
+
* lines of the target entry's body. Every other line of the file (other
|
|
8
|
+
* entries, prose, front matter, the title, the trailer block, and each
|
|
9
|
+
* line's own line ending) stays byte-for-byte unchanged. After the splice
|
|
10
|
+
* the text is parsed again; when the set of entries differs (a new entry,
|
|
11
|
+
* a lost entry, a changed title or trailer) or the target's body is not
|
|
12
|
+
* the proposal, the edit is refused.
|
|
13
|
+
*
|
|
14
|
+
* The body range starts after the title paragraph (up to the first blank
|
|
15
|
+
* line after the title line, so a soft-wrapped title is skipped) and the
|
|
16
|
+
* blank lines after it. It has as many lines as the parser's
|
|
17
|
+
* `entry.body`, so lazy continuation lines are included, and it must
|
|
18
|
+
* match that body line for line. The body indent is the content column of
|
|
19
|
+
* the list item: the marker column, plus the marker width, plus the spaces
|
|
20
|
+
* after the marker. Lines are split on `\r\n`, a
|
|
21
|
+
* lone `\r`, or `\n`, as in the parser.
|
|
22
|
+
*
|
|
23
|
+
* Pure: no I/O, Node-compatible.
|
|
24
|
+
*/
|
|
25
|
+
/** Why {@linkcode replaceEntryBody} refused an edit. */
|
|
26
|
+
export type EntryBodyRefusal = "entry-not-found" | "body-empty" | "proposal-empty" | "trailer-invalid" | "entries-changed";
|
|
27
|
+
/** Result of {@linkcode replaceEntryBody}. */
|
|
28
|
+
export type EntryBodyEdit = {
|
|
29
|
+
readonly ok: true;
|
|
30
|
+
readonly text: string;
|
|
31
|
+
} | {
|
|
32
|
+
readonly ok: false;
|
|
33
|
+
readonly refusal: EntryBodyRefusal;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* 0-based content column of the list item whose marker starts at `marker`
|
|
37
|
+
* on `line`: the marker column, plus 1 for the bullet, plus the spaces
|
|
38
|
+
* after it. So `- [ID]` gives the marker column plus 2 and `- [ID]` gives
|
|
39
|
+
* the marker column plus 4. Only a bullet followed by one to four spaces
|
|
40
|
+
* can start an entry: ordered lists never hold entries, and five or more
|
|
41
|
+
* spaces make the title an indented code block. When the line does not
|
|
42
|
+
* start with a bullet and a space at `marker`, the marker column plus 2 is
|
|
43
|
+
* used as a fallback.
|
|
44
|
+
*/
|
|
45
|
+
export declare function contentColumn(line: string, marker: number): number;
|
|
46
|
+
/**
|
|
47
|
+
* Body of the entry `displayId` as written in `text`: dedented, LF line
|
|
48
|
+
* endings, no surrounding blank lines. Returns `""` when the entry has no
|
|
49
|
+
* body and `undefined` when no entry has `displayId`. `file` names a
|
|
50
|
+
* `.md` file. When the body lines cannot be located exactly in `text`,
|
|
51
|
+
* the parser's body is returned (and {@linkcode replaceEntryBody}
|
|
52
|
+
* refuses to edit that entry).
|
|
53
|
+
*/
|
|
54
|
+
export declare function readEntryBody(text: string, file: string, displayId: string): Promise<string | undefined>;
|
|
55
|
+
/**
|
|
56
|
+
* Return `text` with the body of entry `displayId` replaced by `body`,
|
|
57
|
+
* re-indented to the body indent. Every other line stays byte-for-byte
|
|
58
|
+
* unchanged. Inserted lines take the line ending of the title line. In
|
|
59
|
+
* `body`, `\r\n` and a lone `\r` count as line breaks.
|
|
60
|
+
*
|
|
61
|
+
* Refusals: `entry-not-found` (no such entry), `trailer-invalid` (the
|
|
62
|
+
* entry's trailer block did not parse, see below), `body-empty` (the entry
|
|
63
|
+
* has no body), `proposal-empty` (`body` is blank), `entries-changed`
|
|
64
|
+
* (two entries in `text` have `displayId`; or the body lines cannot be
|
|
65
|
+
* located exactly in `text`; or the edited
|
|
66
|
+
* text no longer parses to the same entries, with the same title and
|
|
67
|
+
* trailer for the target, and with the proposal as the target's body;
|
|
68
|
+
* or the parse raises more structural diagnostics of some code, such as
|
|
69
|
+
* MSL-P020, than the original text).
|
|
70
|
+
*
|
|
71
|
+
* `trailer-invalid`: when a trailer line is malformed (for example an
|
|
72
|
+
* empty `Labels:`, a key without a colon, or a lowercase key), the parser
|
|
73
|
+
* reads the whole trailer block, the `Id:` line included, as body. A
|
|
74
|
+
* splice would then delete the `Id:` and trailer lines, and the identity
|
|
75
|
+
* check cannot see it, because the entry has no `id` and no attributes
|
|
76
|
+
* before or after the edit. So the edit is refused when an `MSL-P020`,
|
|
77
|
+
* `MSL-P021` or `MSL-P022` names the entry (the message starts with
|
|
78
|
+
* `<displayId>:`). This is broader than that case: `MSL-P020` also fires
|
|
79
|
+
* when a body paragraph starts with a recognized trailer key, so such an
|
|
80
|
+
* entry is refused too. The file already fails `markspec check` there.
|
|
81
|
+
* An entry whose trailer-looking lines use only unrecognized keys, and
|
|
82
|
+
* that the parser reads as body without a diagnostic, is edited as the
|
|
83
|
+
* parser sees it: those lines are body.
|
|
84
|
+
*/
|
|
85
|
+
export declare function replaceEntryBody(text: string, file: string, displayId: string, body: string): Promise<EntryBodyEdit>;
|
|
86
|
+
//# sourceMappingURL=entry_body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry_body.d.ts","sourceRoot":"","sources":["../../src/formatter/entry_body.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAKH,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,YAAY,GACZ,gBAAgB,GAChB,iBAAiB,GACjB,iBAAiB,CAAC;AAEtB,8CAA8C;AAC9C,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,CAAC;AA8E/D;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGlE;AAyCD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAS7B;AASD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,aAAa,CAAC,CAoDxB"}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module formatter/entry_body
|
|
3
|
+
*
|
|
4
|
+
* Read and replace the body of one entry in a Markdown file text.
|
|
5
|
+
*
|
|
6
|
+
* Splice-only contract: {@linkcode replaceEntryBody} changes only the
|
|
7
|
+
* lines of the target entry's body. Every other line of the file (other
|
|
8
|
+
* entries, prose, front matter, the title, the trailer block, and each
|
|
9
|
+
* line's own line ending) stays byte-for-byte unchanged. After the splice
|
|
10
|
+
* the text is parsed again; when the set of entries differs (a new entry,
|
|
11
|
+
* a lost entry, a changed title or trailer) or the target's body is not
|
|
12
|
+
* the proposal, the edit is refused.
|
|
13
|
+
*
|
|
14
|
+
* The body range starts after the title paragraph (up to the first blank
|
|
15
|
+
* line after the title line, so a soft-wrapped title is skipped) and the
|
|
16
|
+
* blank lines after it. It has as many lines as the parser's
|
|
17
|
+
* `entry.body`, so lazy continuation lines are included, and it must
|
|
18
|
+
* match that body line for line. The body indent is the content column of
|
|
19
|
+
* the list item: the marker column, plus the marker width, plus the spaces
|
|
20
|
+
* after the marker. Lines are split on `\r\n`, a
|
|
21
|
+
* lone `\r`, or `\n`, as in the parser.
|
|
22
|
+
*
|
|
23
|
+
* Pure: no I/O, Node-compatible.
|
|
24
|
+
*/
|
|
25
|
+
import { parseFile } from "../parser/mod.js";
|
|
26
|
+
/**
|
|
27
|
+
* Split `text` into lines on `\r\n`, a lone `\r`, or `\n`, the same rule
|
|
28
|
+
* the parser uses to normalize line endings, so line indexes agree with
|
|
29
|
+
* parser line numbers. Each line keeps its own ending.
|
|
30
|
+
*/
|
|
31
|
+
function splitText(text) {
|
|
32
|
+
const lines = [];
|
|
33
|
+
const endings = [];
|
|
34
|
+
const re = /\r\n|\r|\n/g;
|
|
35
|
+
let from = 0;
|
|
36
|
+
for (let m = re.exec(text); m !== null; m = re.exec(text)) {
|
|
37
|
+
lines.push(text.slice(from, m.index));
|
|
38
|
+
endings.push(m[0]);
|
|
39
|
+
from = m.index + m[0].length;
|
|
40
|
+
}
|
|
41
|
+
lines.push(text.slice(from));
|
|
42
|
+
endings.push("");
|
|
43
|
+
return { lines, endings };
|
|
44
|
+
}
|
|
45
|
+
/** Lines of `text` with trailing whitespace removed, for comparisons. */
|
|
46
|
+
function trimmedLines(text) {
|
|
47
|
+
return text.split("\n").map((l) => l.trimEnd());
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Locate the body of `entry` in `lines`. `start === end` when the entry
|
|
51
|
+
* has no body.
|
|
52
|
+
*
|
|
53
|
+
* The body starts after the title paragraph and the blank lines that
|
|
54
|
+
* follow it. Its length is the line count of the parser's `entry.body`,
|
|
55
|
+
* so a lazy continuation line (a body line indented less than the body
|
|
56
|
+
* indent) is part of the span. `exact` is false when the dedented span,
|
|
57
|
+
* trimmed as a whole like the parser's body, does not match `entry.body`
|
|
58
|
+
* line for line (trailing whitespace ignored); the span is then not
|
|
59
|
+
* reliable and must not be edited.
|
|
60
|
+
*/
|
|
61
|
+
function bodySpan(lines, entry) {
|
|
62
|
+
const titleIdx = entry.location.line - 1;
|
|
63
|
+
const indent = contentColumn(lines[titleIdx] ?? "", entry.location.column - 1);
|
|
64
|
+
const isBlank = (i) => lines[i].trim() === "";
|
|
65
|
+
let start = titleIdx + 1;
|
|
66
|
+
// Skip the rest of the title paragraph (a soft-wrapped title).
|
|
67
|
+
while (start < lines.length && !isBlank(start))
|
|
68
|
+
start++;
|
|
69
|
+
while (start < lines.length && isBlank(start))
|
|
70
|
+
start++;
|
|
71
|
+
if (entry.body === "")
|
|
72
|
+
return { start, end: start, indent, exact: true };
|
|
73
|
+
const expected = trimmedLines(entry.body);
|
|
74
|
+
const end = Math.min(start + expected.length, lines.length);
|
|
75
|
+
const actual = spanText(lines, { start, end, indent, exact: true });
|
|
76
|
+
// The parser trims its body as a whole, which drops the leading
|
|
77
|
+
// whitespace of the first line (an indented code block); trim the span
|
|
78
|
+
// the same way before comparing.
|
|
79
|
+
const exact = actual.join("\n").trim() === expected.join("\n");
|
|
80
|
+
return { start, end, indent, exact };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 0-based content column of the list item whose marker starts at `marker`
|
|
84
|
+
* on `line`: the marker column, plus 1 for the bullet, plus the spaces
|
|
85
|
+
* after it. So `- [ID]` gives the marker column plus 2 and `- [ID]` gives
|
|
86
|
+
* the marker column plus 4. Only a bullet followed by one to four spaces
|
|
87
|
+
* can start an entry: ordered lists never hold entries, and five or more
|
|
88
|
+
* spaces make the title an indented code block. When the line does not
|
|
89
|
+
* start with a bullet and a space at `marker`, the marker column plus 2 is
|
|
90
|
+
* used as a fallback.
|
|
91
|
+
*/
|
|
92
|
+
export function contentColumn(line, marker) {
|
|
93
|
+
const m = /^[-*+]( +)/.exec(line.slice(marker));
|
|
94
|
+
return m ? marker + 1 + m[1].length : marker + 2;
|
|
95
|
+
}
|
|
96
|
+
/** Dedented span lines, trailing whitespace removed. */
|
|
97
|
+
function spanText(lines, span) {
|
|
98
|
+
return lines.slice(span.start, span.end)
|
|
99
|
+
.map((l) => l.trim() === "" ? "" : dedent(l, span.indent).trimEnd());
|
|
100
|
+
}
|
|
101
|
+
/** Parse `text` and find the entry named `displayId`. */
|
|
102
|
+
async function locate(text, file, displayId) {
|
|
103
|
+
const { entries, diagnostics } = await parseFile(text, { file });
|
|
104
|
+
const entry = entries.find((e) => e.displayId === displayId);
|
|
105
|
+
const trailerInvalid = diagnostics.some((d) => TRAILER_PARSE_CODES.has(d.code) && d.message.startsWith(`${displayId}:`));
|
|
106
|
+
return {
|
|
107
|
+
entries,
|
|
108
|
+
entry,
|
|
109
|
+
diagnosticCodes: diagnostics.map((d) => d.code),
|
|
110
|
+
trailerInvalid,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** Parse codes that mean an entry's trailer block did not parse. */
|
|
114
|
+
const TRAILER_PARSE_CODES = new Set([
|
|
115
|
+
"MSL-P020",
|
|
116
|
+
"MSL-P021",
|
|
117
|
+
"MSL-P022",
|
|
118
|
+
]);
|
|
119
|
+
/**
|
|
120
|
+
* Body of the entry `displayId` as written in `text`: dedented, LF line
|
|
121
|
+
* endings, no surrounding blank lines. Returns `""` when the entry has no
|
|
122
|
+
* body and `undefined` when no entry has `displayId`. `file` names a
|
|
123
|
+
* `.md` file. When the body lines cannot be located exactly in `text`,
|
|
124
|
+
* the parser's body is returned (and {@linkcode replaceEntryBody}
|
|
125
|
+
* refuses to edit that entry).
|
|
126
|
+
*/
|
|
127
|
+
export async function readEntryBody(text, file, displayId) {
|
|
128
|
+
const { entry } = await locate(text, file, displayId);
|
|
129
|
+
if (!entry)
|
|
130
|
+
return undefined;
|
|
131
|
+
const { lines } = splitText(text);
|
|
132
|
+
const span = bodySpan(lines, entry);
|
|
133
|
+
if (!span.exact)
|
|
134
|
+
return entry.body;
|
|
135
|
+
return lines.slice(span.start, span.end)
|
|
136
|
+
.map((l) => l.trim() === "" ? "" : dedent(l, span.indent))
|
|
137
|
+
.join("\n");
|
|
138
|
+
}
|
|
139
|
+
/** Remove up to `indent` leading spaces. */
|
|
140
|
+
function dedent(line, indent) {
|
|
141
|
+
let i = 0;
|
|
142
|
+
while (i < indent && line[i] === " ")
|
|
143
|
+
i++;
|
|
144
|
+
return line.slice(i);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Return `text` with the body of entry `displayId` replaced by `body`,
|
|
148
|
+
* re-indented to the body indent. Every other line stays byte-for-byte
|
|
149
|
+
* unchanged. Inserted lines take the line ending of the title line. In
|
|
150
|
+
* `body`, `\r\n` and a lone `\r` count as line breaks.
|
|
151
|
+
*
|
|
152
|
+
* Refusals: `entry-not-found` (no such entry), `trailer-invalid` (the
|
|
153
|
+
* entry's trailer block did not parse, see below), `body-empty` (the entry
|
|
154
|
+
* has no body), `proposal-empty` (`body` is blank), `entries-changed`
|
|
155
|
+
* (two entries in `text` have `displayId`; or the body lines cannot be
|
|
156
|
+
* located exactly in `text`; or the edited
|
|
157
|
+
* text no longer parses to the same entries, with the same title and
|
|
158
|
+
* trailer for the target, and with the proposal as the target's body;
|
|
159
|
+
* or the parse raises more structural diagnostics of some code, such as
|
|
160
|
+
* MSL-P020, than the original text).
|
|
161
|
+
*
|
|
162
|
+
* `trailer-invalid`: when a trailer line is malformed (for example an
|
|
163
|
+
* empty `Labels:`, a key without a colon, or a lowercase key), the parser
|
|
164
|
+
* reads the whole trailer block, the `Id:` line included, as body. A
|
|
165
|
+
* splice would then delete the `Id:` and trailer lines, and the identity
|
|
166
|
+
* check cannot see it, because the entry has no `id` and no attributes
|
|
167
|
+
* before or after the edit. So the edit is refused when an `MSL-P020`,
|
|
168
|
+
* `MSL-P021` or `MSL-P022` names the entry (the message starts with
|
|
169
|
+
* `<displayId>:`). This is broader than that case: `MSL-P020` also fires
|
|
170
|
+
* when a body paragraph starts with a recognized trailer key, so such an
|
|
171
|
+
* entry is refused too. The file already fails `markspec check` there.
|
|
172
|
+
* An entry whose trailer-looking lines use only unrecognized keys, and
|
|
173
|
+
* that the parser reads as body without a diagnostic, is edited as the
|
|
174
|
+
* parser sees it: those lines are body.
|
|
175
|
+
*/
|
|
176
|
+
export async function replaceEntryBody(text, file, displayId, body) {
|
|
177
|
+
const before = await locate(text, file, displayId);
|
|
178
|
+
const entry = before.entry;
|
|
179
|
+
if (!entry)
|
|
180
|
+
return { ok: false, refusal: "entry-not-found" };
|
|
181
|
+
if (before.trailerInvalid)
|
|
182
|
+
return { ok: false, refusal: "trailer-invalid" };
|
|
183
|
+
// Two entries with the same display ID make the target ambiguous (and
|
|
184
|
+
// `markspec check` already rejects the file), so do not edit either.
|
|
185
|
+
if (before.entries.filter((e) => e.displayId === displayId).length > 1) {
|
|
186
|
+
return { ok: false, refusal: "entries-changed" };
|
|
187
|
+
}
|
|
188
|
+
const { lines, endings } = splitText(text);
|
|
189
|
+
const span = bodySpan(lines, entry);
|
|
190
|
+
if (span.start === span.end)
|
|
191
|
+
return { ok: false, refusal: "body-empty" };
|
|
192
|
+
if (!span.exact)
|
|
193
|
+
return { ok: false, refusal: "entries-changed" };
|
|
194
|
+
const proposal = body.replace(/\r\n?/g, "\n").split("\n");
|
|
195
|
+
while (proposal.length > 0 && proposal[0].trim() === "")
|
|
196
|
+
proposal.shift();
|
|
197
|
+
while (proposal.length > 0 && proposal[proposal.length - 1].trim() === "") {
|
|
198
|
+
proposal.pop();
|
|
199
|
+
}
|
|
200
|
+
if (proposal.length === 0)
|
|
201
|
+
return { ok: false, refusal: "proposal-empty" };
|
|
202
|
+
const titleIdx = entry.location.line - 1;
|
|
203
|
+
const eol = endings[titleIdx];
|
|
204
|
+
const indentStr = " ".repeat(span.indent);
|
|
205
|
+
const inserted = proposal.map((l) => (l.trim() === "" ? "" : indentStr + l) + eol);
|
|
206
|
+
// The final line of the file has no ending after it; keep the old
|
|
207
|
+
// ending of the last body line when the body reaches the file end.
|
|
208
|
+
if (span.end === lines.length) {
|
|
209
|
+
const last = inserted.length - 1;
|
|
210
|
+
inserted[last] = indentStr + proposal[last] + endings[span.end - 1];
|
|
211
|
+
}
|
|
212
|
+
const keep = (from, to) => {
|
|
213
|
+
let out = "";
|
|
214
|
+
for (let i = from; i < to; i++)
|
|
215
|
+
out += lines[i] + endings[i];
|
|
216
|
+
return out;
|
|
217
|
+
};
|
|
218
|
+
const edited = keep(0, span.start) + inserted.join("") +
|
|
219
|
+
keep(span.end, lines.length);
|
|
220
|
+
const after = await locate(edited, file, displayId);
|
|
221
|
+
if (!sameEntries(before.entries, after.entries, entry, after.entry) ||
|
|
222
|
+
addsParseDiagnostic(before.diagnosticCodes, after.diagnosticCodes) ||
|
|
223
|
+
trimmedLines(after.entry?.body ?? "").join("\n") !==
|
|
224
|
+
proposal.map((l) => l.trimEnd()).join("\n").trim()) {
|
|
225
|
+
return { ok: false, refusal: "entries-changed" };
|
|
226
|
+
}
|
|
227
|
+
return { ok: true, text: edited };
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Identity check: same entry count; per index, same display ID and Id;
|
|
231
|
+
* for the target, also the same title and the same trailer attributes.
|
|
232
|
+
* An unclosed fence or HTML block in the proposal (for example a final
|
|
233
|
+
* line of three backticks) can swallow the target's trailer without any
|
|
234
|
+
* parse diagnostic; this comparison and the body-equality check in
|
|
235
|
+
* {@linkcode replaceEntryBody} are what refuse such an edit. No input is
|
|
236
|
+
* known that only one of the two refuses: the splice changes only body
|
|
237
|
+
* lines, so another entry, or the target's title or trailer, can change
|
|
238
|
+
* only through a block in the proposal that also changes the target body.
|
|
239
|
+
* (A link reference definition named like a later display ID does not
|
|
240
|
+
* remove that entry: the parser reads definitions only at the top level.)
|
|
241
|
+
* So the tests pin the pair, not either check by itself, and each check is
|
|
242
|
+
* a backstop for the other.
|
|
243
|
+
*/
|
|
244
|
+
function sameEntries(before, after, target, targetAfter) {
|
|
245
|
+
if (before.length !== after.length || !targetAfter)
|
|
246
|
+
return false;
|
|
247
|
+
for (let i = 0; i < before.length; i++) {
|
|
248
|
+
if (before[i].displayId !== after[i].displayId)
|
|
249
|
+
return false;
|
|
250
|
+
if (before[i].id !== after[i].id)
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
if (target.title !== targetAfter.title)
|
|
254
|
+
return false;
|
|
255
|
+
const a = target.rawAttributes;
|
|
256
|
+
const b = targetAfter.rawAttributes;
|
|
257
|
+
if (a.length !== b.length)
|
|
258
|
+
return false;
|
|
259
|
+
return a.every((attr, i) => attr.key === b[i].key && attr.value === b[i].value);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* True when `after` holds more diagnostics of some code than `before`.
|
|
263
|
+
* Counts per code, not messages, so diagnostics whose location moved with
|
|
264
|
+
* the splice do not count as new. This catches a body with a trailer-like
|
|
265
|
+
* line or an entry-shaped list item after a blank line (MSL-P020), which
|
|
266
|
+
* the parser keeps as body text and the entry comparison alone cannot
|
|
267
|
+
* see. An entry-shaped item directly after a paragraph line, with no
|
|
268
|
+
* blank line between them, raises no diagnostic; the parser keeps it as
|
|
269
|
+
* body text and adds no entry, so the edit is accepted.
|
|
270
|
+
*
|
|
271
|
+
* Known limit: the parser raises at most one MSL-P020 per entry, so when
|
|
272
|
+
* the target body already has a trailer-like line, a proposal that adds
|
|
273
|
+
* more such lines raises no new MSL-P020 and is accepted. The lines stay
|
|
274
|
+
* body text; no trailer or entry changes.
|
|
275
|
+
*/
|
|
276
|
+
function addsParseDiagnostic(before, after) {
|
|
277
|
+
const counts = new Map();
|
|
278
|
+
for (const code of before)
|
|
279
|
+
counts.set(code, (counts.get(code) ?? 0) + 1);
|
|
280
|
+
for (const code of after) {
|
|
281
|
+
const left = (counts.get(code) ?? 0) - 1;
|
|
282
|
+
if (left < 0)
|
|
283
|
+
return true;
|
|
284
|
+
counts.set(code, left);
|
|
285
|
+
}
|
|
286
|
+
return false;
|
|
287
|
+
}
|
package/esm/formatter/mod.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare function isSentenceInitial(line: string, offset: number): boolean
|
|
|
24
24
|
*
|
|
25
25
|
* The pass skips:
|
|
26
26
|
*
|
|
27
|
-
* -
|
|
27
|
+
* - CommonMark fenced code blocks and inline-code spans — code is
|
|
28
28
|
* verbatim per round-trip invariants (spec §5.1).
|
|
29
29
|
* - Lines indented by four or more spaces (or a tab) — conservatively
|
|
30
30
|
* captures indented code blocks and attribute trailers, both of which
|
|
@@ -33,8 +33,8 @@ export declare function isSentenceInitial(line: string, offset: number): boolean
|
|
|
33
33
|
* @remarks Not called by `format()` as of SP3 Task 5 — body modal
|
|
34
34
|
* normalization moved to `normalizeBodyAst` in the AST pass (spec-correct
|
|
35
35
|
* verbatim-boundary handling). Retained as an exported symbol because
|
|
36
|
-
* `mod_test.ts` tests it directly
|
|
37
|
-
*
|
|
36
|
+
* `mod_test.ts` tests it directly. Both entry points delegate to the same
|
|
37
|
+
* AST-backed prose normalizer. Do NOT
|
|
38
38
|
* delete — external callers may depend on this export.
|
|
39
39
|
*/
|
|
40
40
|
export declare function normalizeModalKeywords(markdown: string): string;
|
|
@@ -121,17 +121,21 @@ export declare function sortAttributes(attributes: Attribute[]): Attribute[];
|
|
|
121
121
|
* no trailing line-continuation characters.
|
|
122
122
|
*
|
|
123
123
|
* @param attributes - The attributes to render, in canonical order.
|
|
124
|
-
* @param indent -
|
|
125
|
-
*
|
|
124
|
+
* @param indent - The 0-based list item content column, or 0 inside
|
|
125
|
+
* source-file doc comments.
|
|
126
126
|
*/
|
|
127
127
|
export declare function renderAttributeBlock(attributes: Attribute[], indent: number): string;
|
|
128
128
|
/**
|
|
129
129
|
* Find the 0-based line index where a list item's content ends.
|
|
130
130
|
* Exported for the ADR-029 prose pass (entry-extent computation).
|
|
131
|
-
* Scans forward from the
|
|
132
|
-
*
|
|
131
|
+
* Scans forward from the later of the line after the entry start and
|
|
132
|
+
* `itemEndFloor` until a line has less indent than the content column, a
|
|
133
|
+
* conventional sibling marker is found, or EOF. Pass the parser's
|
|
134
|
+
* `Entry.endLine` as `itemEndFloor` so that a lazy continuation line
|
|
135
|
+
* inside the item does not end the scan early; the default `0` keeps
|
|
136
|
+
* the indentation-only scan.
|
|
133
137
|
*/
|
|
134
|
-
export declare function findItemEnd(lines: readonly string[], startIdx: number, indent: number): number;
|
|
138
|
+
export declare function findItemEnd(lines: readonly string[], startIdx: number, indent: number, itemEndFloor?: number): number;
|
|
135
139
|
/**
|
|
136
140
|
* Find the 0-based line range [start, end) of the attribute block
|
|
137
141
|
* for an entry starting at the given line.
|
|
@@ -139,7 +143,7 @@ export declare function findItemEnd(lines: readonly string[], startIdx: number,
|
|
|
139
143
|
* Scans forward from the entry start to find the list item boundary,
|
|
140
144
|
* then walks backwards to find the contiguous trailing attribute block.
|
|
141
145
|
*/
|
|
142
|
-
export declare function findAttributeBlockRange(lines: readonly string[], entryStartLine: number, indent: number): {
|
|
146
|
+
export declare function findAttributeBlockRange(lines: readonly string[], entryStartLine: number, indent: number, itemEndFloor?: number): {
|
|
143
147
|
start: number;
|
|
144
148
|
end: number;
|
|
145
149
|
} | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/formatter/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAGX,MAAM,iBAAiB,CAAC;AA2BzB,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAGrB;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/formatter/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,KAAK,EACV,SAAS,EACT,UAAU,EAGX,MAAM,iBAAiB,CAAC;AA2BzB,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAGrB;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE/D;AA8SD,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;IACrC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;IAC9B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,cAAc,CAAC;CAC/C;AAED,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AA2BD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CAmSd;AAsDD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAmB/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,SAAS,EAAE,GACtB,SAAS,EAAE,CA2Bb;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,SAAS,EAAE,EACvB,MAAM,EAAE,MAAM,GACb,MAAM,CAKR;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,YAAY,SAAI,GACf,MAAM,CAkBR;AAyED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,YAAY,SAAI,GACf;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CA2B5C"}
|