@agentshouse/mdmodel 0.1.0-alpha.9 → 0.1.0-c04c0d681d2d4
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/API.md +368 -0
- package/README.md +36 -194
- package/dist/blocks.d.ts +11 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +69 -0
- package/dist/condition.d.ts +162 -0
- package/dist/condition.d.ts.map +1 -0
- package/dist/condition.js +616 -0
- package/dist/definition.d.ts +70 -27
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +728 -146
- package/dist/divide.d.ts +3 -0
- package/dist/divide.d.ts.map +1 -0
- package/dist/divide.js +320 -0
- package/dist/document.d.ts +12 -2
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +400 -177
- package/dist/fields.d.ts +6 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +10 -0
- package/dist/index.d.ts +16 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/links.d.ts +4 -0
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +633 -225
- package/dist/paths.d.ts +15 -4
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +149 -36
- package/dist/profile.js +1 -3
- package/dist/project.d.ts +20 -1
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +101 -95
- package/dist/references.d.ts +4 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +30 -0
- package/dist/refuse.d.ts.map +1 -1
- package/dist/refuse.js +2 -10
- package/dist/schema.d.ts +7 -5
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +156 -41
- package/dist/sections.d.ts +2 -1
- package/dist/sections.d.ts.map +1 -1
- package/dist/sections.js +44 -66
- package/dist/types.d.ts +95 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -3
- package/dist/validate.d.ts +10 -2
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +283 -159
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -3
- package/dist/yaml.d.ts +9 -3
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +300 -201
- package/fixtures/README.md +91 -56
- package/fixtures/cases/absent-link-dangles/library/item.md +8 -0
- package/fixtures/cases/absent-link-dangles/schema.yaml +6 -0
- package/fixtures/cases/absent-optional-field/context.json +1 -0
- package/fixtures/cases/absent-optional-field/expected.json +1 -0
- package/fixtures/cases/absent-optional-field/library/companies/acme.md +4 -0
- package/fixtures/cases/absent-optional-field/library/deals/lead.md +6 -0
- package/fixtures/cases/absent-optional-field/schema.yaml +56 -0
- package/fixtures/cases/absolute-link/context.json +1 -0
- package/fixtures/cases/absolute-link/expected.json +5 -0
- package/fixtures/cases/absolute-link/library/item.md +8 -0
- package/fixtures/cases/absolute-link/schema.yaml +6 -0
- package/fixtures/cases/attachment-reference-any-file/context.json +1 -0
- package/fixtures/cases/attachment-reference-any-file/expected.json +1 -0
- package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +15 -0
- package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/schema.yaml +32 -0
- package/fixtures/cases/attachment-reference-dangles/context.json +1 -0
- package/fixtures/cases/attachment-reference-dangles/expected.json +1 -0
- package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +15 -0
- package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/schema.yaml +32 -0
- package/fixtures/cases/attachment-reference-outside/context.json +1 -0
- package/fixtures/cases/attachment-reference-outside/expected.json +6 -0
- package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +15 -0
- package/fixtures/cases/attachment-reference-outside/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-outside/schema.yaml +32 -0
- package/fixtures/cases/binary-any-reference/expected.json +1 -2
- package/fixtures/cases/binary-any-reference/schema.yaml +4 -0
- package/fixtures/cases/binary-document-collision/expected.json +1 -2
- package/fixtures/cases/binary-document-collision/schema.yaml +1 -0
- package/fixtures/cases/binary-image-dangles/expected.json +1 -0
- package/fixtures/cases/binary-image-dangles/schema.yaml +1 -0
- package/fixtures/cases/binary-link-dangles/expected.json +1 -0
- package/fixtures/cases/binary-link-dangles/schema.yaml +1 -0
- package/fixtures/cases/binary-link-outside-collection/expected.json +1 -2
- package/fixtures/cases/binary-link-outside-collection/schema.yaml +1 -0
- package/fixtures/cases/binary-prototype-reference/expected.json +1 -2
- package/fixtures/cases/binary-prototype-reference/schema.yaml +4 -0
- package/fixtures/cases/binary-typed-reference/expected.json +1 -2
- package/fixtures/cases/binary-typed-reference/schema.yaml +5 -0
- package/fixtures/cases/boolean-field/context.json +1 -0
- package/fixtures/cases/boolean-field/expected.json +6 -0
- package/fixtures/cases/boolean-field/library/companies/acme.md +4 -0
- package/fixtures/cases/boolean-field/library/deals/renewal.md +31 -0
- package/fixtures/cases/boolean-field/schema.yaml +56 -0
- package/fixtures/cases/bracketed-link-definition/schema.yaml +6 -0
- package/fixtures/cases/closed-nested-object/context.json +1 -0
- package/fixtures/cases/closed-nested-object/expected.json +6 -0
- package/fixtures/cases/closed-nested-object/library/companies/acme.md +4 -0
- package/fixtures/cases/closed-nested-object/library/deals/renewal.md +32 -0
- package/fixtures/cases/closed-nested-object/schema.yaml +56 -0
- package/fixtures/cases/composed-root-reference/context.json +1 -0
- package/fixtures/cases/composed-root-reference/expected.json +6 -0
- package/fixtures/cases/composed-root-reference/library/a.md +5 -0
- package/fixtures/cases/composed-root-reference/schema.yaml +13 -0
- package/fixtures/cases/cross-room-link/context.json +1 -0
- package/fixtures/cases/cross-room-link/expected.json +1 -0
- package/fixtures/cases/cross-room-link/library/clients/acme.md +6 -0
- package/fixtures/cases/cross-room-link/schema.yaml +3 -0
- package/fixtures/cases/cross-room-reference/context.json +1 -0
- package/fixtures/cases/cross-room-reference/expected.json +1 -0
- package/fixtures/cases/cross-room-reference/library/clients/acme.md +9 -0
- package/fixtures/cases/cross-room-reference/schema.yaml +9 -0
- package/fixtures/cases/date-time-format/context.json +1 -0
- package/fixtures/cases/date-time-format/expected.json +6 -0
- package/fixtures/cases/date-time-format/library/companies/acme.md +4 -0
- package/fixtures/cases/date-time-format/library/deals/renewal.md +31 -0
- package/fixtures/cases/date-time-format/schema.yaml +56 -0
- package/fixtures/cases/declared-binary-links/schema.yaml +1 -0
- package/fixtures/cases/default-unfilled/context.json +1 -0
- package/fixtures/cases/default-unfilled/expected.json +6 -0
- package/fixtures/cases/default-unfilled/library/companies/acme.md +4 -0
- package/fixtures/cases/default-unfilled/library/deals/renewal.md +29 -0
- package/fixtures/cases/default-unfilled/schema.yaml +56 -0
- package/fixtures/cases/defs-pattern/context.json +1 -0
- package/fixtures/cases/defs-pattern/expected.json +6 -0
- package/fixtures/cases/defs-pattern/library/companies/acme.md +4 -0
- package/fixtures/cases/defs-pattern/library/deals/renewal.md +31 -0
- package/fixtures/cases/defs-pattern/schema.yaml +56 -0
- package/fixtures/cases/dependent-rule/context.json +1 -0
- package/fixtures/cases/dependent-rule/expected.json +6 -0
- package/fixtures/cases/dependent-rule/library/companies/acme.md +4 -0
- package/fixtures/cases/dependent-rule/library/deals/renewal.md +30 -0
- package/fixtures/cases/dependent-rule/schema.yaml +56 -0
- package/fixtures/cases/duplicate-link-definition/schema.yaml +6 -0
- package/fixtures/cases/email-format/context.json +1 -0
- package/fixtures/cases/email-format/expected.json +6 -0
- package/fixtures/cases/email-format/library/companies/acme.md +4 -0
- package/fixtures/cases/email-format/library/deals/renewal.md +31 -0
- package/fixtures/cases/email-format/schema.yaml +56 -0
- package/fixtures/cases/fenced-link-definition/schema.yaml +6 -0
- package/fixtures/cases/field-enum/expected.json +2 -3
- package/fixtures/cases/field-enum/schema.yaml +7 -0
- package/fixtures/cases/frontmatter-schema/context.json +1 -0
- package/fixtures/cases/frontmatter-schema/expected.json +5 -0
- package/fixtures/cases/frontmatter-schema/schema.yaml +5 -0
- package/fixtures/cases/integer-field/context.json +1 -0
- package/fixtures/cases/integer-field/expected.json +6 -0
- package/fixtures/cases/integer-field/library/companies/acme.md +4 -0
- package/fixtures/cases/integer-field/library/deals/renewal.md +31 -0
- package/fixtures/cases/integer-field/schema.yaml +56 -0
- package/fixtures/cases/interrupted-link-definition/schema.yaml +1 -0
- package/fixtures/cases/json-schema-constructs/context.json +1 -0
- package/fixtures/cases/json-schema-constructs/expected.json +1 -0
- package/fixtures/cases/json-schema-constructs/library/companies/acme.md +4 -0
- package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +31 -0
- package/fixtures/cases/json-schema-constructs/schema.yaml +56 -0
- package/fixtures/cases/list-of-objects-closed/context.json +1 -0
- package/fixtures/cases/list-of-objects-closed/expected.json +6 -0
- package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +32 -0
- package/fixtures/cases/list-of-objects-closed/schema.yaml +56 -0
- package/fixtures/cases/list-of-objects-item/context.json +1 -0
- package/fixtures/cases/list-of-objects-item/expected.json +6 -0
- package/fixtures/cases/list-of-objects-item/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +31 -0
- package/fixtures/cases/list-of-objects-item/schema.yaml +56 -0
- package/fixtures/cases/list-of-objects-reference/context.json +1 -0
- package/fixtures/cases/list-of-objects-reference/expected.json +6 -0
- package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +14 -0
- package/fixtures/cases/list-of-objects-reference/library/places/depot.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/products/seats.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/products/support.md +4 -0
- package/fixtures/cases/list-of-objects-reference/schema.yaml +32 -0
- package/fixtures/cases/list-size/context.json +1 -0
- package/fixtures/cases/list-size/expected.json +6 -0
- package/fixtures/cases/list-size/library/companies/acme.md +4 -0
- package/fixtures/cases/list-size/library/deals/renewal.md +31 -0
- package/fixtures/cases/list-size/schema.yaml +56 -0
- package/fixtures/cases/long-fence-link-definition/schema.yaml +1 -0
- package/fixtures/cases/malformed-definition/expected.json +2 -4
- package/fixtures/cases/malformed-definition/schema.yaml +3 -0
- package/fixtures/cases/member-document/context.json +1 -0
- package/fixtures/cases/member-document/expected.json +1 -0
- package/fixtures/cases/member-document/library/people/ana.md +5 -0
- package/fixtures/cases/member-document/schema.yaml +5 -0
- package/fixtures/cases/missing-required-field/expected.json +2 -3
- package/fixtures/cases/missing-required-field/schema.yaml +7 -0
- package/fixtures/cases/missing-section-item-kind/expected.json +2 -4
- package/fixtures/cases/missing-section-item-kind/schema.yaml +6 -0
- package/fixtures/cases/misspelled-key/context.json +1 -0
- package/fixtures/cases/misspelled-key/expected.json +6 -0
- package/fixtures/cases/misspelled-key/library/companies/acme.md +4 -0
- package/fixtures/cases/misspelled-key/library/deals/renewal.md +32 -0
- package/fixtures/cases/misspelled-key/schema.yaml +56 -0
- package/fixtures/cases/nested-defs/context.json +1 -0
- package/fixtures/cases/nested-defs/expected.json +6 -0
- package/fixtures/cases/nested-defs/library/deal.md +6 -0
- package/fixtures/cases/nested-defs/schema.yaml +11 -0
- package/fixtures/cases/nested-object-reference/context.json +1 -0
- package/fixtures/cases/nested-object-reference/expected.json +6 -0
- package/fixtures/cases/nested-object-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-object-reference/library/deals/renewal.md +14 -0
- package/fixtures/cases/nested-object-reference/library/places/depot.md +4 -0
- package/fixtures/cases/nested-object-reference/library/products/seats.md +4 -0
- package/fixtures/cases/nested-object-reference/library/products/support.md +4 -0
- package/fixtures/cases/nested-object-reference/schema.yaml +32 -0
- package/fixtures/cases/nested-reference/context.json +1 -0
- package/fixtures/cases/nested-reference/expected.json +1 -0
- package/fixtures/cases/nested-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-reference/library/deals/renewal.md +15 -0
- package/fixtures/cases/nested-reference/library/places/depot.md +4 -0
- package/fixtures/cases/nested-reference/library/products/seats.md +4 -0
- package/fixtures/cases/nested-reference/library/products/support.md +4 -0
- package/fixtures/cases/nested-reference/schema.yaml +32 -0
- package/fixtures/cases/nested-required-field/context.json +1 -0
- package/fixtures/cases/nested-required-field/expected.json +6 -0
- package/fixtures/cases/nested-required-field/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-required-field/library/deals/renewal.md +30 -0
- package/fixtures/cases/nested-required-field/schema.yaml +56 -0
- package/fixtures/cases/null-refused/context.json +1 -0
- package/fixtures/cases/null-refused/expected.json +6 -0
- package/fixtures/cases/null-refused/library/companies/acme.md +4 -0
- package/fixtures/cases/null-refused/library/deals/renewal.md +31 -0
- package/fixtures/cases/null-refused/schema.yaml +56 -0
- package/fixtures/cases/numeric-range/context.json +1 -0
- package/fixtures/cases/numeric-range/expected.json +6 -0
- package/fixtures/cases/numeric-range/library/companies/acme.md +4 -0
- package/fixtures/cases/numeric-range/library/deals/renewal.md +31 -0
- package/fixtures/cases/numeric-range/schema.yaml +56 -0
- package/fixtures/cases/one-of-variant/context.json +1 -0
- package/fixtures/cases/one-of-variant/expected.json +6 -0
- package/fixtures/cases/one-of-variant/library/companies/acme.md +4 -0
- package/fixtures/cases/one-of-variant/library/deals/renewal.md +31 -0
- package/fixtures/cases/one-of-variant/schema.yaml +56 -0
- package/fixtures/cases/open-map-value/context.json +1 -0
- package/fixtures/cases/open-map-value/expected.json +6 -0
- package/fixtures/cases/open-map-value/library/companies/acme.md +4 -0
- package/fixtures/cases/open-map-value/library/deals/renewal.md +31 -0
- package/fixtures/cases/open-map-value/schema.yaml +56 -0
- package/fixtures/cases/other-room-reference/context.json +1 -0
- package/fixtures/cases/other-room-reference/expected.json +6 -0
- package/fixtures/cases/other-room-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/other-room-reference/library/deals/renewal.md +14 -0
- package/fixtures/cases/other-room-reference/library/places/depot.md +4 -0
- package/fixtures/cases/other-room-reference/library/products/seats.md +4 -0
- package/fixtures/cases/other-room-reference/library/products/support.md +4 -0
- package/fixtures/cases/other-room-reference/schema.yaml +32 -0
- package/fixtures/cases/paragraph-link-definition/schema.yaml +1 -0
- package/fixtures/cases/prototype-field/expected.json +2 -3
- package/fixtures/cases/prototype-field/schema.yaml +6 -0
- package/fixtures/cases/quoted-link-definition/expected.json +1 -2
- package/fixtures/cases/quoted-link-definition/library/notes/draft.md +1 -1
- package/fixtures/cases/quoted-link-definition/schema.yaml +1 -0
- package/fixtures/cases/referenced-missing-file/expected.json +0 -1
- package/fixtures/cases/referenced-missing-file/schema.yaml +11 -0
- package/fixtures/cases/remote-ref/context.json +1 -0
- package/fixtures/cases/remote-ref/expected.json +5 -0
- package/fixtures/cases/remote-ref/schema.yaml +3 -0
- package/fixtures/cases/second-member-document/context.json +1 -0
- package/fixtures/cases/second-member-document/expected.json +5 -0
- package/fixtures/cases/second-member-document/schema.yaml +4 -0
- package/fixtures/cases/section-item-enum/context.json +1 -0
- package/fixtures/cases/section-item-enum/expected.json +6 -0
- package/fixtures/cases/section-item-enum/library/task.md +8 -0
- package/fixtures/cases/section-item-enum/schema.yaml +3 -0
- package/fixtures/cases/section-item-kind/context.json +1 -0
- package/fixtures/cases/section-item-kind/expected.json +6 -0
- package/fixtures/cases/section-item-kind/library/task.md +8 -0
- package/fixtures/cases/section-item-kind/schema.yaml +3 -0
- package/fixtures/cases/section-items/context.json +1 -0
- package/fixtures/cases/section-items/expected.json +1 -0
- package/fixtures/cases/section-items/library/other.md +3 -0
- package/fixtures/cases/section-items/library/page.md +42 -0
- package/fixtures/cases/section-items/schema.yaml +10 -0
- package/fixtures/cases/section-reference-path/context.json +1 -0
- package/fixtures/cases/section-reference-path/expected.json +6 -0
- package/fixtures/cases/section-reference-path/library/other.md +3 -0
- package/fixtures/cases/section-reference-path/library/page.md +7 -0
- package/fixtures/cases/section-reference-path/schema.yaml +3 -0
- package/fixtures/cases/section-reference-type/context.json +1 -0
- package/fixtures/cases/section-reference-type/expected.json +6 -0
- package/fixtures/cases/section-reference-type/library/note.md +1 -0
- package/fixtures/cases/section-reference-type/library/page.md +7 -0
- package/fixtures/cases/section-reference-type/schema.yaml +3 -0
- package/fixtures/cases/shortcut-reference-link/context.json +1 -0
- package/fixtures/cases/shortcut-reference-link/expected.json +5 -0
- package/fixtures/cases/shortcut-reference-link/library/item.md +10 -0
- package/fixtures/cases/shortcut-reference-link/schema.yaml +6 -0
- package/fixtures/cases/string-length/context.json +1 -0
- package/fixtures/cases/string-length/expected.json +6 -0
- package/fixtures/cases/string-length/library/companies/acme.md +4 -0
- package/fixtures/cases/string-length/library/deals/renewal.md +31 -0
- package/fixtures/cases/string-length/schema.yaml +56 -0
- package/fixtures/cases/structured-section/expected.json +1 -2
- package/fixtures/cases/structured-section/schema.yaml +7 -0
- package/fixtures/cases/submission-keys/context.json +1 -0
- package/fixtures/cases/submission-keys/expected.json +1 -0
- package/fixtures/cases/submission-keys/library/notes/visitor.md +8 -0
- package/fixtures/cases/submission-keys/schema.yaml +4 -0
- package/fixtures/cases/text-field-kind/context.json +1 -0
- package/fixtures/cases/text-field-kind/expected.json +6 -0
- package/fixtures/cases/text-field-kind/library/page.md +4 -0
- package/fixtures/cases/text-field-kind/schema.yaml +4 -0
- package/fixtures/cases/truncated-link-definition/expected.json +1 -2
- package/fixtures/cases/truncated-link-definition/library/notes/draft.md +1 -1
- package/fixtures/cases/truncated-link-definition/schema.yaml +1 -0
- package/fixtures/cases/types-folder-content/context.json +1 -0
- package/fixtures/cases/types-folder-content/expected.json +1 -0
- package/fixtures/cases/types-folder-content/library/types/task.md +4 -0
- package/fixtures/cases/types-folder-content/schema.yaml +4 -0
- package/fixtures/cases/unclosed-frontmatter/expected.json +1 -2
- package/fixtures/cases/undeclared-field/expected.json +2 -3
- package/fixtures/cases/undeclared-field/schema.yaml +6 -0
- package/fixtures/cases/unevaluated-items-closed/context.json +1 -0
- package/fixtures/cases/unevaluated-items-closed/expected.json +6 -0
- package/fixtures/cases/unevaluated-items-closed/library/trip.md +6 -0
- package/fixtures/cases/unevaluated-items-closed/schema.yaml +10 -0
- package/fixtures/cases/unknown-type/context.json +1 -0
- package/fixtures/cases/unknown-type/expected.json +6 -0
- package/fixtures/cases/unknown-type/library/item.md +3 -0
- package/fixtures/cases/unknown-type/schema.yaml +3 -0
- package/fixtures/cases/unlisted-reference-type/context.json +1 -0
- package/fixtures/cases/unlisted-reference-type/expected.json +5 -0
- package/fixtures/cases/unlisted-reference-type/schema.yaml +3 -0
- package/fixtures/cases/unresolved-link/expected.json +1 -2
- package/fixtures/cases/unresolved-link/library/item.md +1 -1
- package/fixtures/cases/unresolved-link/schema.yaml +6 -0
- package/fixtures/cases/valid-typed-document/schema.yaml +16 -0
- package/fixtures/cases/wide-item-fence-link/schema.yaml +1 -0
- package/fixtures/division.json +409 -0
- package/fixtures/projection.json +90 -21
- package/package.json +6 -13
- package/dist/definition.js.map +0 -1
- package/dist/document.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/links.js.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/profile.js.map +0 -1
- package/dist/project.js.map +0 -1
- package/dist/refuse.js.map +0 -1
- package/dist/schema.js.map +0 -1
- package/dist/sections.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/validate.js.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/yaml.js.map +0 -1
- package/fixtures/cases/binary-any-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-document-collision/library/types/note.md +0 -3
- package/fixtures/cases/binary-link-outside-collection/library/types/note.md +0 -3
- package/fixtures/cases/binary-prototype-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-typed-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-typed-reference/library/types/person.md +0 -3
- package/fixtures/cases/bracketed-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/declared-binary-links/library/types/note.md +0 -3
- package/fixtures/cases/duplicate-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/fenced-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/field-enum/library/types/task.md +0 -8
- package/fixtures/cases/interrupted-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/long-fence-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/malformed-definition/library/types/task.md +0 -5
- package/fixtures/cases/missing-binary-image/expected.json +0 -6
- package/fixtures/cases/missing-binary-image/library/types/note.md +0 -3
- package/fixtures/cases/missing-binary-link/expected.json +0 -6
- package/fixtures/cases/missing-binary-link/library/types/note.md +0 -3
- package/fixtures/cases/missing-required-field/library/types/task.md +0 -8
- package/fixtures/cases/missing-section-item-kind/library/types/task.md +0 -7
- package/fixtures/cases/paragraph-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/prd-definition/library/types/task.md +0 -16
- package/fixtures/cases/prototype-field/library/types/task.md +0 -7
- package/fixtures/cases/quoted-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/referenced-missing-file/library/types/person.md +0 -5
- package/fixtures/cases/referenced-missing-file/library/types/task.md +0 -8
- package/fixtures/cases/structured-section/library/types/task.md +0 -8
- package/fixtures/cases/truncated-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/undeclared-field/library/types/task.md +0 -7
- package/fixtures/cases/unresolved-link/library/types/task.md +0 -7
- package/fixtures/cases/valid-typed-document/library/types/person.md +0 -5
- package/fixtures/cases/valid-typed-document/library/types/task.md +0 -13
- package/fixtures/cases/wide-item-fence-link/library/types/note.md +0 -3
- package/markdown-syntax-profile.md +0 -9
- /package/fixtures/cases/{prd-definition → absent-link-dangles}/context.json +0 -0
- /package/fixtures/cases/{prd-definition → absent-link-dangles}/expected.json +0 -0
- /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/context.json +0 -0
- /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/library/notes/draft.md +0 -0
- /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/context.json +0 -0
- /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/library/notes/draft.md +0 -0
package/dist/yaml.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export class YamlError extends Error {
|
|
2
2
|
offset;
|
|
3
|
-
constructor(offset){
|
|
4
|
-
super('yaml')
|
|
3
|
+
constructor(offset) {
|
|
4
|
+
super('yaml');
|
|
5
|
+
this.offset = offset;
|
|
5
6
|
this.name = 'YamlError';
|
|
6
7
|
}
|
|
7
8
|
}
|
|
@@ -9,20 +10,26 @@ function peek(c) {
|
|
|
9
10
|
return c.i < c.end ? c.text[c.i] : '';
|
|
10
11
|
}
|
|
11
12
|
function skipEol(c) {
|
|
12
|
-
if (peek(c) === '\r')
|
|
13
|
-
|
|
13
|
+
if (peek(c) === '\r')
|
|
14
|
+
c.i += 1;
|
|
15
|
+
if (peek(c) === '\n')
|
|
16
|
+
c.i += 1;
|
|
14
17
|
}
|
|
15
18
|
function skipSpaces(c) {
|
|
16
|
-
while(peek(c) === ' ')
|
|
17
|
-
|
|
19
|
+
while (peek(c) === ' ')
|
|
20
|
+
c.i += 1;
|
|
21
|
+
if (peek(c) === '\t')
|
|
22
|
+
throw new YamlError(c.i);
|
|
18
23
|
}
|
|
19
24
|
function skipToEol(c) {
|
|
20
|
-
while(c.i < c.end && peek(c) !== '\n' && peek(c) !== '\r')
|
|
25
|
+
while (c.i < c.end && peek(c) !== '\n' && peek(c) !== '\r')
|
|
26
|
+
c.i += 1;
|
|
21
27
|
}
|
|
22
28
|
function skipBlankAndComments(c) {
|
|
23
|
-
while(c.i < c.end){
|
|
29
|
+
while (c.i < c.end) {
|
|
24
30
|
skipSpaces(c);
|
|
25
|
-
if (peek(c) === '#')
|
|
31
|
+
if (peek(c) === '#')
|
|
32
|
+
skipToEol(c);
|
|
26
33
|
if (peek(c) === '\r' || peek(c) === '\n') {
|
|
27
34
|
skipEol(c);
|
|
28
35
|
continue;
|
|
@@ -31,7 +38,7 @@ function skipBlankAndComments(c) {
|
|
|
31
38
|
}
|
|
32
39
|
}
|
|
33
40
|
function skipFlowSpace(c) {
|
|
34
|
-
while(c.i < c.end){
|
|
41
|
+
while (c.i < c.end) {
|
|
35
42
|
const ch = peek(c);
|
|
36
43
|
if (ch === ' ' || ch === '\n' || ch === '\r') {
|
|
37
44
|
c.i += 1;
|
|
@@ -41,64 +48,86 @@ function skipFlowSpace(c) {
|
|
|
41
48
|
skipToEol(c);
|
|
42
49
|
continue;
|
|
43
50
|
}
|
|
44
|
-
if (ch === '\t')
|
|
51
|
+
if (ch === '\t')
|
|
52
|
+
throw new YamlError(c.i);
|
|
45
53
|
break;
|
|
46
54
|
}
|
|
47
55
|
}
|
|
48
56
|
function indentAt(c) {
|
|
49
57
|
let j = c.i;
|
|
50
|
-
while(j > 0 && c.text[j - 1] !== '\n'
|
|
58
|
+
while (j > 0 && c.text[j - 1] !== '\n' && c.text[j - 1] !== '\r')
|
|
59
|
+
j -= 1;
|
|
51
60
|
let n = 0;
|
|
52
|
-
while(j < c.i){
|
|
61
|
+
while (j < c.i) {
|
|
53
62
|
const ch = c.text[j];
|
|
54
|
-
if (ch === ' ')
|
|
55
|
-
|
|
56
|
-
else
|
|
63
|
+
if (ch === ' ')
|
|
64
|
+
n += 1;
|
|
65
|
+
else if (ch === '\t')
|
|
66
|
+
throw new YamlError(j);
|
|
67
|
+
else
|
|
68
|
+
break;
|
|
57
69
|
j += 1;
|
|
58
70
|
}
|
|
59
71
|
return n;
|
|
60
72
|
}
|
|
61
73
|
function scalar(value, start, end) {
|
|
62
|
-
return {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (text
|
|
72
|
-
|
|
73
|
-
if (/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/.test(text)) return Number(text);
|
|
74
|
+
return { kind: 'scalar', value, start, end };
|
|
75
|
+
}
|
|
76
|
+
export function interpretPlain(text) {
|
|
77
|
+
if (text === 'true')
|
|
78
|
+
return true;
|
|
79
|
+
if (text === 'false')
|
|
80
|
+
return false;
|
|
81
|
+
if (text === 'null' || text === '')
|
|
82
|
+
return null;
|
|
83
|
+
if (/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/.test(text))
|
|
84
|
+
return Number(text);
|
|
74
85
|
return text;
|
|
75
86
|
}
|
|
87
|
+
const ESCAPES = {
|
|
88
|
+
b: '\b',
|
|
89
|
+
f: '\f',
|
|
90
|
+
n: '\n',
|
|
91
|
+
r: '\r',
|
|
92
|
+
t: '\t',
|
|
93
|
+
'"': '"',
|
|
94
|
+
'/': '/',
|
|
95
|
+
'\\': '\\',
|
|
96
|
+
};
|
|
97
|
+
function parseEscape(c) {
|
|
98
|
+
c.i += 1;
|
|
99
|
+
const escaped = peek(c);
|
|
100
|
+
const held = ESCAPES[escaped];
|
|
101
|
+
if (held !== undefined) {
|
|
102
|
+
c.i += 1;
|
|
103
|
+
return held;
|
|
104
|
+
}
|
|
105
|
+
const hex = c.text.slice(c.i + 1, c.i + 5);
|
|
106
|
+
if (escaped !== 'u' || c.i + 5 > c.end || !/^[0-9A-Fa-f]{4}$/.test(hex))
|
|
107
|
+
throw new YamlError(c.i);
|
|
108
|
+
c.i += 5;
|
|
109
|
+
return String.fromCharCode(Number.parseInt(hex, 16));
|
|
110
|
+
}
|
|
76
111
|
function parseQuoted(c) {
|
|
77
112
|
const quote = peek(c);
|
|
78
113
|
const start = c.i;
|
|
79
114
|
c.i += 1;
|
|
80
115
|
let out = '';
|
|
81
|
-
while(c.i < c.end){
|
|
116
|
+
while (c.i < c.end) {
|
|
82
117
|
const ch = peek(c);
|
|
83
|
-
if (ch ===
|
|
84
|
-
c.i += 1;
|
|
85
|
-
return scalar(out, start, c.i);
|
|
86
|
-
}
|
|
87
|
-
if (ch === '\n' || ch === '\r') throw new YamlError(c.i);
|
|
88
|
-
if (quote === "'" && ch === "'" && c.text[c.i + 1] === "'") {
|
|
118
|
+
if (quote === "'" && ch === "'" && c.i + 1 < c.end && c.text[c.i + 1] === "'") {
|
|
89
119
|
out += "'";
|
|
90
120
|
c.i += 2;
|
|
91
121
|
continue;
|
|
92
122
|
}
|
|
93
|
-
if (
|
|
94
|
-
c.i += 1;
|
|
95
|
-
const escaped = peek(c);
|
|
96
|
-
if (escaped === 'n') out += '\n';
|
|
97
|
-
else if (escaped === 't') out += '\t';
|
|
98
|
-
else if (escaped === '"') out += '"';
|
|
99
|
-
else if (escaped === '\\') out += '\\';
|
|
100
|
-
else throw new YamlError(c.i);
|
|
123
|
+
if (ch === quote) {
|
|
101
124
|
c.i += 1;
|
|
125
|
+
return scalar(out, start, c.i);
|
|
126
|
+
}
|
|
127
|
+
if (ch === '\n' || ch === '\r')
|
|
128
|
+
throw new YamlError(c.i);
|
|
129
|
+
if (quote === '"' && ch === '\\') {
|
|
130
|
+
out += parseEscape(c);
|
|
102
131
|
continue;
|
|
103
132
|
}
|
|
104
133
|
out += ch;
|
|
@@ -108,90 +137,95 @@ function parseQuoted(c) {
|
|
|
108
137
|
}
|
|
109
138
|
function parsePlain(c, flow) {
|
|
110
139
|
const start = c.i;
|
|
111
|
-
while(c.i < c.end){
|
|
140
|
+
while (c.i < c.end) {
|
|
112
141
|
const ch = peek(c);
|
|
113
|
-
if (flow && (ch === ',' || ch === ']' || ch === '}'))
|
|
114
|
-
|
|
115
|
-
if (ch === '
|
|
142
|
+
if (flow && (ch === ',' || ch === ']' || ch === '}'))
|
|
143
|
+
break;
|
|
144
|
+
if (ch === '\n' || ch === '\r')
|
|
145
|
+
break;
|
|
146
|
+
if (ch === '#' && (c.i === start || c.text[c.i - 1] === ' ' || c.text[c.i - 1] === '\t'))
|
|
147
|
+
break;
|
|
116
148
|
c.i += 1;
|
|
117
149
|
}
|
|
118
|
-
if (c.i === start)
|
|
150
|
+
if (c.i === start)
|
|
151
|
+
throw new YamlError(c.i);
|
|
119
152
|
const raw = c.text.slice(start, c.i);
|
|
120
153
|
const trimmed = raw.trimEnd();
|
|
121
154
|
return scalar(interpretPlain(trimmed), start, start + trimmed.length);
|
|
122
155
|
}
|
|
123
156
|
function parseScalar(c, flow) {
|
|
124
157
|
const ch = peek(c);
|
|
125
|
-
if (ch === '"' || ch === "'")
|
|
158
|
+
if (ch === '"' || ch === "'")
|
|
159
|
+
return parseQuoted(c);
|
|
126
160
|
return parsePlain(c, flow);
|
|
127
161
|
}
|
|
128
162
|
function parseKey(c) {
|
|
129
163
|
const start = c.i;
|
|
130
164
|
if (peek(c) === '"' || peek(c) === "'") {
|
|
131
165
|
const quoted = parseQuoted(c);
|
|
132
|
-
if (typeof quoted.value !== 'string')
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
start,
|
|
136
|
-
end: c.i
|
|
137
|
-
};
|
|
166
|
+
if (typeof quoted.value !== 'string')
|
|
167
|
+
throw new YamlError(start);
|
|
168
|
+
return { name: quoted.value, start, end: c.i };
|
|
138
169
|
}
|
|
139
170
|
let end = c.i;
|
|
140
|
-
while(c.i < c.end){
|
|
171
|
+
while (c.i < c.end) {
|
|
141
172
|
const ch = peek(c);
|
|
142
|
-
if (ch === ':' ||
|
|
173
|
+
if (ch === ':' ||
|
|
174
|
+
ch === '\n' ||
|
|
175
|
+
ch === '\r' ||
|
|
176
|
+
ch === ',' ||
|
|
177
|
+
ch === '}' ||
|
|
178
|
+
ch === ']' ||
|
|
179
|
+
ch === '#' ||
|
|
180
|
+
ch === '{' ||
|
|
181
|
+
ch === '[') {
|
|
143
182
|
break;
|
|
144
183
|
}
|
|
145
184
|
c.i += 1;
|
|
146
|
-
if (ch !== ' ' && ch !== '\t')
|
|
185
|
+
if (ch !== ' ' && ch !== '\t')
|
|
186
|
+
end = c.i;
|
|
147
187
|
}
|
|
148
|
-
if (end === start)
|
|
188
|
+
if (end === start)
|
|
189
|
+
throw new YamlError(c.i);
|
|
149
190
|
c.i = end;
|
|
150
|
-
return {
|
|
151
|
-
name: c.text.slice(start, end),
|
|
152
|
-
start,
|
|
153
|
-
end
|
|
154
|
-
};
|
|
191
|
+
return { name: c.text.slice(start, end), start, end };
|
|
155
192
|
}
|
|
156
193
|
function parseFlowValue(c) {
|
|
157
194
|
skipFlowSpace(c);
|
|
158
195
|
const ch = peek(c);
|
|
159
|
-
if (ch === '{')
|
|
160
|
-
|
|
161
|
-
if (ch === '
|
|
196
|
+
if (ch === '{')
|
|
197
|
+
return parseFlowMap(c);
|
|
198
|
+
if (ch === '[')
|
|
199
|
+
return parseFlowSeq(c);
|
|
200
|
+
if (ch === '|' || ch === '>')
|
|
201
|
+
throw new YamlError(c.i);
|
|
162
202
|
return parseScalar(c, true);
|
|
163
203
|
}
|
|
164
204
|
function parseFlowMap(c) {
|
|
165
205
|
const start = c.i;
|
|
166
|
-
if (peek(c) !== '{')
|
|
206
|
+
if (peek(c) !== '{')
|
|
207
|
+
throw new YamlError(c.i);
|
|
167
208
|
c.i += 1;
|
|
168
209
|
skipFlowSpace(c);
|
|
169
210
|
const entries = [];
|
|
170
211
|
const seen = new Set();
|
|
171
212
|
if (peek(c) === '}') {
|
|
172
213
|
c.i += 1;
|
|
173
|
-
return {
|
|
174
|
-
kind: 'map',
|
|
175
|
-
entries,
|
|
176
|
-
start,
|
|
177
|
-
end: c.i
|
|
178
|
-
};
|
|
214
|
+
return { kind: 'map', entries, start, end: c.i };
|
|
179
215
|
}
|
|
180
|
-
while(c.i < c.end){
|
|
216
|
+
while (c.i < c.end) {
|
|
181
217
|
skipFlowSpace(c);
|
|
182
218
|
const key = parseKey(c);
|
|
183
219
|
skipFlowSpace(c);
|
|
184
|
-
if (peek(c) !== ':')
|
|
220
|
+
if (peek(c) !== ':')
|
|
221
|
+
throw new YamlError(c.i);
|
|
185
222
|
c.i += 1;
|
|
223
|
+
const after = c.i;
|
|
186
224
|
const value = parseFlowValue(c);
|
|
187
|
-
if (seen.has(key.name))
|
|
225
|
+
if (seen.has(key.name))
|
|
226
|
+
throw new YamlError(key.start);
|
|
188
227
|
seen.add(key.name);
|
|
189
|
-
entries.push({
|
|
190
|
-
key: key.name,
|
|
191
|
-
keyStart: key.start,
|
|
192
|
-
keyEnd: key.end,
|
|
193
|
-
value
|
|
194
|
-
});
|
|
228
|
+
entries.push({ key: key.name, after, value });
|
|
195
229
|
skipFlowSpace(c);
|
|
196
230
|
if (peek(c) === ',') {
|
|
197
231
|
c.i += 1;
|
|
@@ -199,12 +233,7 @@ function parseFlowMap(c) {
|
|
|
199
233
|
}
|
|
200
234
|
if (peek(c) === '}') {
|
|
201
235
|
c.i += 1;
|
|
202
|
-
return {
|
|
203
|
-
kind: 'map',
|
|
204
|
-
entries,
|
|
205
|
-
start,
|
|
206
|
-
end: c.i
|
|
207
|
-
};
|
|
236
|
+
return { kind: 'map', entries, start, end: c.i };
|
|
208
237
|
}
|
|
209
238
|
throw new YamlError(c.i);
|
|
210
239
|
}
|
|
@@ -212,20 +241,16 @@ function parseFlowMap(c) {
|
|
|
212
241
|
}
|
|
213
242
|
function parseFlowSeq(c) {
|
|
214
243
|
const start = c.i;
|
|
215
|
-
if (peek(c) !== '[')
|
|
244
|
+
if (peek(c) !== '[')
|
|
245
|
+
throw new YamlError(c.i);
|
|
216
246
|
c.i += 1;
|
|
217
247
|
skipFlowSpace(c);
|
|
218
248
|
const items = [];
|
|
219
249
|
if (peek(c) === ']') {
|
|
220
250
|
c.i += 1;
|
|
221
|
-
return {
|
|
222
|
-
kind: 'seq',
|
|
223
|
-
items,
|
|
224
|
-
start,
|
|
225
|
-
end: c.i
|
|
226
|
-
};
|
|
251
|
+
return { kind: 'seq', items, start, end: c.i };
|
|
227
252
|
}
|
|
228
|
-
while(c.i < c.end){
|
|
253
|
+
while (c.i < c.end) {
|
|
229
254
|
items.push(parseFlowValue(c));
|
|
230
255
|
skipFlowSpace(c);
|
|
231
256
|
if (peek(c) === ',') {
|
|
@@ -235,138 +260,213 @@ function parseFlowSeq(c) {
|
|
|
235
260
|
}
|
|
236
261
|
if (peek(c) === ']') {
|
|
237
262
|
c.i += 1;
|
|
238
|
-
return {
|
|
239
|
-
kind: 'seq',
|
|
240
|
-
items,
|
|
241
|
-
start,
|
|
242
|
-
end: c.i
|
|
243
|
-
};
|
|
263
|
+
return { kind: 'seq', items, start, end: c.i };
|
|
244
264
|
}
|
|
245
265
|
throw new YamlError(c.i);
|
|
246
266
|
}
|
|
247
267
|
throw new YamlError(c.i);
|
|
248
268
|
}
|
|
249
269
|
function parseValue(c, parentKeyIndent) {
|
|
270
|
+
const at = c.i;
|
|
250
271
|
skipSpaces(c);
|
|
251
|
-
if (peek(c) === '#')
|
|
272
|
+
if (peek(c) === '#')
|
|
273
|
+
skipToEol(c);
|
|
252
274
|
const ch = peek(c);
|
|
253
275
|
if (ch === '' || ch === '\n' || ch === '\r') {
|
|
254
276
|
skipEol(c);
|
|
255
277
|
skipBlankAndComments(c);
|
|
256
|
-
if (c.i >= c.end)
|
|
278
|
+
if (c.i >= c.end)
|
|
279
|
+
return scalar(null, at, at);
|
|
257
280
|
const nextIndent = indentAt(c);
|
|
258
|
-
if (nextIndent
|
|
259
|
-
|
|
260
|
-
if (
|
|
261
|
-
|
|
281
|
+
if (nextIndent === parentKeyIndent && seqAhead(c))
|
|
282
|
+
return parseBlockSeq(c, nextIndent);
|
|
283
|
+
if (nextIndent <= parentKeyIndent)
|
|
284
|
+
return scalar(null, at, at);
|
|
285
|
+
if (peek(c) === '-')
|
|
286
|
+
return parseBlockSeq(c, nextIndent);
|
|
287
|
+
if (peek(c) === '[')
|
|
288
|
+
return parseFlowSeq(c);
|
|
289
|
+
if (peek(c) === '{')
|
|
290
|
+
return parseFlowMap(c);
|
|
262
291
|
return parseBlockMap(c, nextIndent);
|
|
263
292
|
}
|
|
264
|
-
if (ch === '{')
|
|
265
|
-
|
|
266
|
-
if (ch === '
|
|
293
|
+
if (ch === '{')
|
|
294
|
+
return parseFlowMap(c);
|
|
295
|
+
if (ch === '[')
|
|
296
|
+
return parseFlowSeq(c);
|
|
297
|
+
if (ch === '|' || ch === '>')
|
|
298
|
+
throw new YamlError(c.i);
|
|
267
299
|
return parseScalar(c, false);
|
|
268
300
|
}
|
|
301
|
+
function seqAhead(c) {
|
|
302
|
+
const next = c.text[c.i + 1];
|
|
303
|
+
return peek(c) === '-' && (next === ' ' || next === '\n' || next === '\r' || c.i + 1 >= c.end);
|
|
304
|
+
}
|
|
305
|
+
function mappingAhead(c) {
|
|
306
|
+
const start = c.i;
|
|
307
|
+
try {
|
|
308
|
+
if (peek(c) === '{' || peek(c) === '[')
|
|
309
|
+
return false;
|
|
310
|
+
parseKey(c);
|
|
311
|
+
skipSpaces(c);
|
|
312
|
+
if (peek(c) !== ':')
|
|
313
|
+
return false;
|
|
314
|
+
const next = c.text[c.i + 1];
|
|
315
|
+
return next === ' ' || next === '\n' || next === '\r' || c.i + 1 >= c.end;
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
if (error instanceof YamlError)
|
|
319
|
+
return false;
|
|
320
|
+
throw error;
|
|
321
|
+
}
|
|
322
|
+
finally {
|
|
323
|
+
c.i = start;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
function lineStartOf(c) {
|
|
327
|
+
let j = c.i;
|
|
328
|
+
while (j > 0 && c.text[j - 1] !== '\n' && c.text[j - 1] !== '\r')
|
|
329
|
+
j -= 1;
|
|
330
|
+
return j;
|
|
331
|
+
}
|
|
332
|
+
function parseSeqItem(c, indent) {
|
|
333
|
+
skipSpaces(c);
|
|
334
|
+
if (peek(c) !== '#' && peek(c) !== '\n' && peek(c) !== '\r' && c.i < c.end && mappingAhead(c))
|
|
335
|
+
return parseBlockMap(c, c.i - lineStartOf(c), true);
|
|
336
|
+
return parseValue(c, indent);
|
|
337
|
+
}
|
|
269
338
|
function parseBlockSeq(c, indent) {
|
|
270
339
|
const start = c.i;
|
|
271
340
|
const items = [];
|
|
272
341
|
let end = start;
|
|
273
|
-
while(c.i < c.end){
|
|
342
|
+
while (c.i < c.end) {
|
|
274
343
|
skipBlankAndComments(c);
|
|
275
|
-
if (c.i >= c.end)
|
|
276
|
-
|
|
277
|
-
if (
|
|
344
|
+
if (c.i >= c.end)
|
|
345
|
+
break;
|
|
346
|
+
if (indentAt(c) !== indent)
|
|
347
|
+
break;
|
|
348
|
+
if (peek(c) !== '-')
|
|
349
|
+
break;
|
|
278
350
|
c.i += 1;
|
|
279
|
-
|
|
280
|
-
|
|
351
|
+
const item = parseSeqItem(c, indent);
|
|
352
|
+
items.push(item);
|
|
353
|
+
end = item.end;
|
|
281
354
|
}
|
|
282
|
-
return {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
start,
|
|
286
|
-
end
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
function parseBlockMap(c, indent) {
|
|
355
|
+
return { kind: 'seq', items, start, end };
|
|
356
|
+
}
|
|
357
|
+
function parseBlockMap(c, indent, inline = false) {
|
|
290
358
|
const start = c.i;
|
|
291
359
|
const entries = [];
|
|
292
360
|
const seen = new Set();
|
|
293
361
|
let end = start;
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (
|
|
297
|
-
|
|
298
|
-
|
|
362
|
+
let first = inline;
|
|
363
|
+
while (c.i < c.end) {
|
|
364
|
+
if (!first) {
|
|
365
|
+
skipBlankAndComments(c);
|
|
366
|
+
if (c.i >= c.end)
|
|
367
|
+
break;
|
|
368
|
+
if (indentAt(c) < indent)
|
|
369
|
+
break;
|
|
370
|
+
if (indentAt(c) > indent)
|
|
371
|
+
throw new YamlError(c.i);
|
|
372
|
+
}
|
|
373
|
+
first = false;
|
|
299
374
|
const key = parseKey(c);
|
|
300
375
|
skipSpaces(c);
|
|
301
|
-
if (peek(c) !== ':')
|
|
376
|
+
if (peek(c) !== ':')
|
|
377
|
+
throw new YamlError(c.i);
|
|
302
378
|
c.i += 1;
|
|
379
|
+
const after = c.i;
|
|
303
380
|
const value = parseValue(c, indent);
|
|
304
|
-
if (seen.has(key.name))
|
|
381
|
+
if (seen.has(key.name))
|
|
382
|
+
throw new YamlError(key.start);
|
|
305
383
|
seen.add(key.name);
|
|
306
|
-
entries.push({
|
|
307
|
-
|
|
308
|
-
keyStart: key.start,
|
|
309
|
-
keyEnd: key.end,
|
|
310
|
-
value
|
|
311
|
-
});
|
|
312
|
-
end = c.i;
|
|
384
|
+
entries.push({ key: key.name, after, value });
|
|
385
|
+
end = value.end;
|
|
313
386
|
}
|
|
314
|
-
return {
|
|
315
|
-
kind: 'map',
|
|
316
|
-
entries,
|
|
317
|
-
start,
|
|
318
|
-
end
|
|
319
|
-
};
|
|
387
|
+
return { kind: 'map', entries, start, end };
|
|
320
388
|
}
|
|
321
389
|
export function parseYamlMapping(text, start, end) {
|
|
322
|
-
const c = {
|
|
323
|
-
text,
|
|
324
|
-
i: start,
|
|
325
|
-
end
|
|
326
|
-
};
|
|
390
|
+
const c = { text, i: start, end };
|
|
327
391
|
skipBlankAndComments(c);
|
|
328
|
-
if (c.i >= end)
|
|
329
|
-
kind: 'map',
|
|
330
|
-
entries: [],
|
|
331
|
-
start,
|
|
332
|
-
end
|
|
333
|
-
};
|
|
392
|
+
if (c.i >= end)
|
|
393
|
+
return { kind: 'map', entries: [], start, end };
|
|
334
394
|
if (peek(c) === '{') {
|
|
335
395
|
const mapped = parseFlowMap(c);
|
|
336
396
|
skipBlankAndComments(c);
|
|
337
|
-
if (c.i < end)
|
|
397
|
+
if (c.i < end)
|
|
398
|
+
throw new YamlError(c.i);
|
|
338
399
|
return mapped;
|
|
339
400
|
}
|
|
340
401
|
const mapped = parseBlockMap(c, indentAt(c));
|
|
341
402
|
skipBlankAndComments(c);
|
|
342
|
-
if (c.i < end)
|
|
403
|
+
if (c.i < end)
|
|
404
|
+
throw new YamlError(c.i);
|
|
343
405
|
return mapped;
|
|
344
406
|
}
|
|
345
407
|
export function jsValue(node) {
|
|
346
|
-
if (node.kind === 'scalar')
|
|
347
|
-
|
|
408
|
+
if (node.kind === 'scalar')
|
|
409
|
+
return node.value;
|
|
410
|
+
if (node.kind === 'seq')
|
|
411
|
+
return node.items.map(jsValue);
|
|
348
412
|
const record = Object.create(null);
|
|
349
|
-
for (const entry of node.entries)
|
|
413
|
+
for (const entry of node.entries)
|
|
414
|
+
record[entry.key] = jsValue(entry.value);
|
|
350
415
|
return record;
|
|
351
416
|
}
|
|
352
417
|
export function mapEntry(map, key) {
|
|
353
|
-
return map.entries.find((entry)=>entry.key === key);
|
|
418
|
+
return map.entries.find((entry) => entry.key === key);
|
|
354
419
|
}
|
|
355
420
|
export function isPlainSafe(text) {
|
|
356
|
-
if (text === '' || text === 'true' || text === 'false' || text === 'null')
|
|
357
|
-
|
|
358
|
-
if (
|
|
359
|
-
|
|
421
|
+
if (text === '' || text === 'true' || text === 'false' || text === 'null')
|
|
422
|
+
return false;
|
|
423
|
+
if (/[\s#:{}[\],&*!|>'"%@`]/.test(text))
|
|
424
|
+
return false;
|
|
425
|
+
if (text.startsWith('-') || text.startsWith('?') || text.startsWith(':'))
|
|
426
|
+
return false;
|
|
427
|
+
if (/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/.test(text))
|
|
428
|
+
return false;
|
|
360
429
|
return true;
|
|
361
430
|
}
|
|
431
|
+
export function plain(value) {
|
|
432
|
+
if (!isRecord(value))
|
|
433
|
+
return false;
|
|
434
|
+
const prototype = Object.getPrototypeOf(value);
|
|
435
|
+
return prototype === Object.prototype || prototype === null;
|
|
436
|
+
}
|
|
437
|
+
function listed(value) {
|
|
438
|
+
const keys = Object.keys(value);
|
|
439
|
+
return keys.length === value.length && keys.every((key, index) => key === String(index));
|
|
440
|
+
}
|
|
441
|
+
function heldWithin(value, within) {
|
|
442
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
443
|
+
return true;
|
|
444
|
+
if (typeof value === 'number')
|
|
445
|
+
return Number.isFinite(value);
|
|
446
|
+
if (typeof value !== 'object' || within.includes(value))
|
|
447
|
+
return false;
|
|
448
|
+
const path = [...within, value];
|
|
449
|
+
const held = (item) => heldWithin(item, path);
|
|
450
|
+
if (Array.isArray(value))
|
|
451
|
+
return listed(value) && value.every(held);
|
|
452
|
+
return plain(value) && Object.values(value).every(held);
|
|
453
|
+
}
|
|
454
|
+
export function frontmatterValue(value) {
|
|
455
|
+
return heldWithin(value, []);
|
|
456
|
+
}
|
|
362
457
|
export function serializeJs(value) {
|
|
363
|
-
if (value ===
|
|
364
|
-
|
|
365
|
-
if (value ===
|
|
366
|
-
|
|
367
|
-
if (
|
|
368
|
-
|
|
369
|
-
|
|
458
|
+
if (typeof value === 'string')
|
|
459
|
+
return isPlainSafe(value) ? value : JSON.stringify(value);
|
|
460
|
+
if (value === null || typeof value !== 'object')
|
|
461
|
+
return JSON.stringify(value);
|
|
462
|
+
if (Array.isArray(value))
|
|
463
|
+
return `[${value.map(serializeJs).join(', ')}]`;
|
|
464
|
+
return `{${Object.entries(value)
|
|
465
|
+
.map(([key, held]) => `${serializeKey(key)}: ${serializeJs(held)}`)
|
|
466
|
+
.join(', ')}}`;
|
|
467
|
+
}
|
|
468
|
+
export function isRecord(value) {
|
|
469
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
370
470
|
}
|
|
371
471
|
export function serializeKey(name) {
|
|
372
472
|
return isPlainSafe(name) || /^[A-Za-z][A-Za-z0-9_-]*$/.test(name) ? name : JSON.stringify(name);
|
|
@@ -383,47 +483,46 @@ export function bodyAfterFrontmatter(content) {
|
|
|
383
483
|
return content.slice(bodyStartOf(content));
|
|
384
484
|
}
|
|
385
485
|
export function extractFrontmatter(content) {
|
|
386
|
-
if (!content.startsWith('---'))
|
|
387
|
-
kind: 'none'
|
|
388
|
-
};
|
|
486
|
+
if (!content.startsWith('---'))
|
|
487
|
+
return { kind: 'none' };
|
|
389
488
|
const firstNl = content.indexOf('\n');
|
|
390
|
-
const firstLine = firstNl === -1
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
489
|
+
const firstLine = firstNl === -1
|
|
490
|
+
? content
|
|
491
|
+
: content.slice(0, content[firstNl - 1] === '\r' ? firstNl - 1 : firstNl);
|
|
492
|
+
if (!/^---[ \t]*$/.test(firstLine))
|
|
493
|
+
return { kind: 'none' };
|
|
494
|
+
if (firstNl === -1)
|
|
495
|
+
return { kind: 'unclosed' };
|
|
397
496
|
const yamlStart = firstNl + 1;
|
|
398
497
|
let i = yamlStart;
|
|
399
|
-
while(i <= content.length){
|
|
498
|
+
while (i <= content.length) {
|
|
400
499
|
const nl = content.indexOf('\n', i);
|
|
401
500
|
const lineEnd = nl === -1 ? content.length : nl;
|
|
402
501
|
let line = content.slice(i, lineEnd);
|
|
403
|
-
if (line.endsWith('\r'))
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
yamlStart,
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
if (nl === -1) return {
|
|
410
|
-
kind: 'unclosed'
|
|
411
|
-
};
|
|
502
|
+
if (line.endsWith('\r'))
|
|
503
|
+
line = line.slice(0, -1);
|
|
504
|
+
if (/^---[ \t]*$/.test(line))
|
|
505
|
+
return { kind: 'ok', yamlStart, yamlEnd: i };
|
|
506
|
+
if (nl === -1)
|
|
507
|
+
return { kind: 'unclosed' };
|
|
412
508
|
i = nl + 1;
|
|
413
509
|
}
|
|
414
|
-
return {
|
|
415
|
-
kind: 'unclosed'
|
|
416
|
-
};
|
|
510
|
+
return { kind: 'unclosed' };
|
|
417
511
|
}
|
|
418
512
|
export function equalValue(left, right) {
|
|
419
|
-
if (left === right)
|
|
513
|
+
if (left === right)
|
|
514
|
+
return true;
|
|
420
515
|
if (Array.isArray(left) && Array.isArray(right)) {
|
|
421
|
-
return left.length === right.length &&
|
|
516
|
+
return (left.length === right.length &&
|
|
517
|
+
Array.from(left).every((item, index) => equalValue(item, right[index])));
|
|
518
|
+
}
|
|
519
|
+
if (isRecord(left) && isRecord(right)) {
|
|
520
|
+
const keys = Object.keys(left);
|
|
521
|
+
return (keys.length === Object.keys(right).length &&
|
|
522
|
+
keys.every((key) => Object.hasOwn(right, key) && equalValue(left[key], right[key])));
|
|
422
523
|
}
|
|
423
524
|
return false;
|
|
424
525
|
}
|
|
425
526
|
export function lineEnding(content) {
|
|
426
527
|
return content.includes('\r\n') ? '\r\n' : '\n';
|
|
427
528
|
}
|
|
428
|
-
|
|
429
|
-
//# sourceMappingURL=yaml.js.map
|