@agentshouse/mdmodel 0.1.0-cbce4f1da228f → 0.1.0-cbd3c46de90bf
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 +287 -278
- package/README.md +28 -29
- package/dist/body.d.ts +85 -0
- package/dist/body.d.ts.map +1 -0
- package/dist/body.js +1083 -0
- package/dist/built-in.d.ts +4 -0
- package/dist/built-in.d.ts.map +1 -0
- package/dist/built-in.js +19 -0
- package/dist/definition.d.ts +26 -11
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +259 -93
- package/dist/document.d.ts +16 -9
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +996 -254
- package/dist/event.d.ts +77 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +200 -0
- package/dist/facts.d.ts +15 -0
- package/dist/facts.d.ts.map +1 -0
- package/dist/facts.js +41 -0
- package/dist/fields.d.ts +1 -1
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +2 -2
- package/dist/form.d.ts +4 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +153 -0
- package/dist/house-model.d.ts +920 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +504 -0
- package/dist/house-references/crockford.d.ts +4 -0
- package/dist/house-references/crockford.d.ts.map +1 -0
- package/dist/house-references/crockford.js +3 -0
- package/dist/house-references/patterns.d.ts +9 -0
- package/dist/house-references/patterns.d.ts.map +1 -0
- package/dist/house-references/patterns.js +13 -0
- package/dist/index.d.ts +45 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -11
- package/dist/indexed.d.ts +9 -0
- package/dist/indexed.d.ts.map +1 -0
- package/dist/indexed.js +55 -0
- package/dist/kinds.d.ts +21 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/kinds.js +210 -0
- package/dist/markdown.d.ts +71 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +232 -0
- package/dist/media-type.d.ts +72 -0
- package/dist/media-type.d.ts.map +1 -0
- package/dist/media-type.js +157 -0
- package/dist/moment.d.ts +7 -0
- package/dist/moment.d.ts.map +1 -0
- package/dist/moment.js +18 -0
- package/dist/not-ready.d.ts +2 -0
- package/dist/not-ready.d.ts.map +1 -0
- package/dist/not-ready.js +5 -0
- package/dist/paths.d.ts +25 -2
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +129 -18
- package/dist/pattern.d.ts +10 -0
- package/dist/pattern.d.ts.map +1 -0
- package/dist/pattern.js +356 -0
- package/dist/query/language.d.ts +257 -0
- package/dist/query/language.d.ts.map +1 -0
- package/dist/query/language.js +621 -0
- package/dist/query/match.d.ts +14 -0
- package/dist/query/match.d.ts.map +1 -0
- package/dist/query/match.js +129 -0
- package/dist/query/rows.d.ts +36 -0
- package/dist/query/rows.d.ts.map +1 -0
- package/dist/query/rows.js +179 -0
- package/dist/query/sql.d.ts +45 -0
- package/dist/query/sql.d.ts.map +1 -0
- package/dist/query/sql.js +296 -0
- package/dist/query/walk.d.ts +69 -0
- package/dist/query/walk.d.ts.map +1 -0
- package/dist/query/walk.js +274 -0
- package/dist/references.d.ts +2 -2
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +7 -2
- package/dist/refuse.d.ts +1 -0
- package/dist/refuse.d.ts.map +1 -1
- package/dist/refuse.js +1 -0
- package/dist/reserved.d.ts +7 -0
- package/dist/reserved.d.ts.map +1 -0
- package/dist/reserved.js +32 -0
- package/dist/room-types.d.ts +8 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +144 -0
- package/dist/schema.d.ts +1 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +10 -23
- package/dist/types.d.ts +44 -34
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +34 -5
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +345 -151
- package/dist/view.d.ts +5 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/view.js +27 -0
- package/dist/yaml.d.ts +7 -5
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +190 -43
- package/fixtures/README.md +93 -65
- package/fixtures/cases/absent-link-dangles/library/item.md +1 -1
- package/fixtures/cases/absent-link-dangles/schema.yaml +2 -3
- package/fixtures/cases/absent-optional-field/library/companies/acme.md +1 -1
- package/fixtures/cases/absent-optional-field/library/deals/lead.md +3 -3
- package/fixtures/cases/absent-optional-field/schema.yaml +10 -11
- package/fixtures/cases/absolute-link/library/item.md +1 -1
- package/fixtures/cases/absolute-link/schema.yaml +2 -3
- package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/products/support.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/products/support.md +1 -1
- package/fixtures/cases/attachment-reference-outside/expected.json +2 -1
- package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-outside/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/products/support.md +1 -1
- package/fixtures/cases/binary-any-reference/expected.json +2 -1
- package/fixtures/cases/binary-any-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-prototype-reference/expected.json +2 -1
- package/fixtures/cases/binary-prototype-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-typed-reference/expected.json +2 -1
- package/fixtures/cases/binary-typed-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/block-scalar-frontmatter/library/notes/literal.md +17 -0
- package/fixtures/cases/block-scalar-frontmatter/library/skills/notes/SKILL.md +10 -0
- package/fixtures/cases/boolean-field/expected.json +2 -1
- package/fixtures/cases/boolean-field/library/companies/acme.md +1 -1
- package/fixtures/cases/boolean-field/library/deals/renewal.md +49 -24
- package/fixtures/cases/boolean-field/schema.yaml +10 -11
- package/fixtures/cases/bracketed-link-definition/library/item.md +1 -1
- package/fixtures/cases/bracketed-link-definition/schema.yaml +2 -3
- package/fixtures/cases/closed-nested-object/expected.json +2 -1
- package/fixtures/cases/closed-nested-object/library/companies/acme.md +1 -1
- package/fixtures/cases/closed-nested-object/library/deals/renewal.md +50 -25
- package/fixtures/cases/closed-nested-object/schema.yaml +10 -11
- package/fixtures/cases/composed-root-reference/library/a.md +2 -2
- package/fixtures/cases/conditional-long-text/expected.json +7 -0
- package/fixtures/cases/conditional-long-text/library/questions/hosting.md +9 -0
- package/fixtures/cases/conditional-long-text/library/questions/payments.md +12 -0
- package/fixtures/cases/conditional-long-text/schema.yaml +13 -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/expected.json +1 -0
- package/fixtures/cases/cross-room-reference/library/clients/acme.md +9 -0
- package/fixtures/cases/cross-room-reference/schema.yaml +8 -0
- package/fixtures/cases/date-time-format/expected.json +2 -1
- package/fixtures/cases/date-time-format/library/companies/acme.md +1 -1
- package/fixtures/cases/date-time-format/library/deals/renewal.md +49 -24
- package/fixtures/cases/date-time-format/schema.yaml +10 -11
- package/fixtures/cases/default-unfilled/library/companies/acme.md +1 -1
- package/fixtures/cases/default-unfilled/library/deals/renewal.md +47 -22
- package/fixtures/cases/default-unfilled/schema.yaml +10 -11
- package/fixtures/cases/defs-pattern/expected.json +2 -1
- package/fixtures/cases/defs-pattern/library/companies/acme.md +1 -1
- package/fixtures/cases/defs-pattern/library/deals/renewal.md +49 -24
- package/fixtures/cases/defs-pattern/schema.yaml +10 -11
- package/fixtures/cases/dependent-rule/library/companies/acme.md +1 -1
- package/fixtures/cases/dependent-rule/library/deals/renewal.md +48 -23
- package/fixtures/cases/dependent-rule/schema.yaml +10 -11
- package/fixtures/cases/duplicate-link-definition/library/item.md +1 -1
- package/fixtures/cases/duplicate-link-definition/schema.yaml +2 -3
- package/fixtures/cases/email-format/expected.json +2 -1
- package/fixtures/cases/email-format/library/companies/acme.md +1 -1
- package/fixtures/cases/email-format/library/deals/renewal.md +49 -24
- package/fixtures/cases/email-format/schema.yaml +10 -11
- package/fixtures/cases/equal-labels/expected.json +5 -0
- package/fixtures/cases/equal-labels/schema.yaml +4 -0
- package/fixtures/cases/fenced-link-definition/library/item.md +1 -1
- package/fixtures/cases/fenced-link-definition/schema.yaml +2 -3
- package/fixtures/cases/field-enum/expected.json +2 -1
- package/fixtures/cases/field-enum/library/item.md +2 -2
- package/fixtures/cases/field-enum/schema.yaml +3 -4
- package/fixtures/cases/frontmatter-construct/expected.json +7 -0
- package/fixtures/cases/frontmatter-construct/library/note.md +6 -0
- package/fixtures/cases/integer-field/expected.json +2 -1
- package/fixtures/cases/integer-field/library/companies/acme.md +1 -1
- package/fixtures/cases/integer-field/library/deals/renewal.md +49 -24
- package/fixtures/cases/integer-field/schema.yaml +10 -11
- package/fixtures/cases/json-schema-constructs/library/companies/acme.md +1 -1
- package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +49 -24
- package/fixtures/cases/json-schema-constructs/schema.yaml +10 -11
- package/fixtures/cases/labels-in-the-rooms-language/expected.json +1 -0
- package/fixtures/cases/labels-in-the-rooms-language/library/deals/atlas.md +7 -0
- package/fixtures/cases/labels-in-the-rooms-language/schema.yaml +9 -0
- package/fixtures/cases/lazy-list-item/expected.json +3 -0
- package/fixtures/cases/lazy-list-item/library/item.md +10 -0
- package/fixtures/cases/lazy-list-item/schema.yaml +3 -0
- package/fixtures/cases/link-into-a-reserved-name/context.json +1 -0
- package/fixtures/cases/link-into-a-reserved-name/expected.json +5 -0
- package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +6 -0
- package/fixtures/cases/link-into-a-reserved-name/schema.yaml +3 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/expected.json +5 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/library/notes/b.md +5 -0
- package/fixtures/cases/list-item-enum/context.json +1 -0
- package/fixtures/cases/list-item-enum/expected.json +7 -0
- package/fixtures/cases/list-item-enum/library/task.md +7 -0
- package/fixtures/cases/list-item-enum/schema.yaml +3 -0
- package/fixtures/cases/list-item-kind/context.json +1 -0
- package/fixtures/cases/list-item-kind/expected.json +7 -0
- package/fixtures/cases/list-item-kind/library/task.md +6 -0
- package/fixtures/cases/list-item-kind/schema.yaml +3 -0
- package/fixtures/cases/list-items/context.json +1 -0
- package/fixtures/cases/list-items/expected.json +1 -0
- package/fixtures/cases/list-items/library/page.md +26 -0
- package/fixtures/cases/list-items/schema.yaml +10 -0
- package/fixtures/cases/list-of-objects-closed/expected.json +2 -1
- package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +49 -25
- package/fixtures/cases/list-of-objects-closed/schema.yaml +10 -11
- package/fixtures/cases/list-of-objects-item/expected.json +2 -1
- package/fixtures/cases/list-of-objects-item/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +49 -24
- package/fixtures/cases/list-of-objects-item/schema.yaml +10 -11
- package/fixtures/cases/list-of-objects-reference/expected.json +2 -1
- package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/list-of-objects-reference/library/places/depot.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/products/seats.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/products/support.md +1 -1
- package/fixtures/cases/list-reference-path/context.json +1 -0
- package/fixtures/cases/list-reference-path/expected.json +7 -0
- package/fixtures/cases/list-reference-path/library/page.md +5 -0
- package/fixtures/cases/list-reference-path/schema.yaml +3 -0
- package/fixtures/cases/list-reference-type/context.json +1 -0
- package/fixtures/cases/list-reference-type/expected.json +7 -0
- package/fixtures/cases/list-reference-type/library/page.md +6 -0
- package/fixtures/cases/list-reference-type/schema.yaml +3 -0
- package/fixtures/cases/list-size/expected.json +2 -1
- package/fixtures/cases/list-size/library/companies/acme.md +1 -1
- package/fixtures/cases/list-size/library/deals/renewal.md +51 -24
- package/fixtures/cases/list-size/schema.yaml +10 -11
- package/fixtures/cases/long-value-past-six-levels/context.json +1 -0
- package/fixtures/cases/long-value-past-six-levels/expected.json +5 -0
- package/fixtures/cases/long-value-past-six-levels/schema.yaml +15 -0
- package/fixtures/cases/malformed-list/context.json +1 -0
- package/fixtures/cases/malformed-list/expected.json +7 -0
- package/fixtures/cases/{structured-section → malformed-list}/library/item.md +1 -1
- package/fixtures/cases/malformed-list/schema.yaml +6 -0
- package/fixtures/cases/member-document/library/people/ana.md +2 -2
- package/fixtures/cases/member-on-an-untyped-document/context.json +1 -0
- package/fixtures/cases/member-on-an-untyped-document/expected.json +6 -0
- package/fixtures/cases/member-on-an-untyped-document/library/note.md +4 -0
- package/fixtures/cases/member-on-another-type/context.json +1 -0
- package/fixtures/cases/member-on-another-type/expected.json +6 -0
- package/fixtures/cases/member-on-another-type/library/note.md +4 -0
- package/fixtures/cases/member-on-another-type/schema.yaml +7 -0
- package/fixtures/cases/missing-required-field/library/item.md +1 -1
- package/fixtures/cases/missing-required-field/schema.yaml +3 -4
- package/fixtures/cases/misspelled-key/expected.json +2 -1
- package/fixtures/cases/misspelled-key/library/companies/acme.md +1 -1
- package/fixtures/cases/misspelled-key/library/deals/renewal.md +50 -25
- package/fixtures/cases/misspelled-key/schema.yaml +10 -11
- package/fixtures/cases/name-not-a-string/context.json +1 -0
- package/fixtures/cases/name-not-a-string/expected.json +5 -0
- package/fixtures/cases/name-not-a-string/schema.yaml +5 -0
- package/fixtures/cases/nested-defs/expected.json +2 -1
- package/fixtures/cases/nested-defs/library/deal.md +3 -3
- package/fixtures/cases/nested-object-reference/expected.json +2 -1
- package/fixtures/cases/nested-object-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-object-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/nested-object-reference/library/places/depot.md +1 -1
- package/fixtures/cases/nested-object-reference/library/products/seats.md +1 -1
- package/fixtures/cases/nested-object-reference/library/products/support.md +1 -1
- package/fixtures/cases/nested-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-reference/library/deals/renewal.md +13 -10
- package/fixtures/cases/nested-reference/library/places/depot.md +1 -1
- package/fixtures/cases/nested-reference/library/products/seats.md +1 -1
- package/fixtures/cases/nested-reference/library/products/support.md +1 -1
- package/fixtures/cases/nested-required-field/expected.json +2 -1
- package/fixtures/cases/nested-required-field/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-required-field/library/deals/renewal.md +48 -23
- package/fixtures/cases/nested-required-field/schema.yaml +10 -11
- package/fixtures/cases/numeric-range/expected.json +2 -1
- package/fixtures/cases/numeric-range/library/companies/acme.md +1 -1
- package/fixtures/cases/numeric-range/library/deals/renewal.md +49 -24
- package/fixtures/cases/numeric-range/schema.yaml +10 -11
- package/fixtures/cases/one-key-two-labels/context.json +1 -0
- package/fixtures/cases/one-key-two-labels/expected.json +5 -0
- package/fixtures/cases/one-key-two-labels/schema.yaml +5 -0
- package/fixtures/cases/one-key-two-types/context.json +1 -0
- package/fixtures/cases/one-key-two-types/expected.json +5 -0
- package/fixtures/cases/one-key-two-types/schema.yaml +4 -0
- package/fixtures/cases/one-of-variant/expected.json +2 -1
- package/fixtures/cases/one-of-variant/library/companies/acme.md +1 -1
- package/fixtures/cases/one-of-variant/library/deals/renewal.md +49 -24
- package/fixtures/cases/one-of-variant/schema.yaml +10 -11
- package/fixtures/cases/other-room-reference/expected.json +2 -1
- package/fixtures/cases/other-room-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/other-room-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/other-room-reference/library/places/depot.md +1 -1
- package/fixtures/cases/other-room-reference/library/products/seats.md +1 -1
- package/fixtures/cases/other-room-reference/library/products/support.md +1 -1
- package/fixtures/cases/prototype-field/expected.json +2 -1
- package/fixtures/cases/prototype-field/library/item.md +2 -2
- package/fixtures/cases/prototype-field/schema.yaml +2 -3
- package/fixtures/cases/reference-into-a-reserved-name/context.json +1 -0
- package/fixtures/cases/reference-into-a-reserved-name/expected.json +7 -0
- package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +4 -0
- package/fixtures/cases/reference-into-a-reserved-name/library/settings/brief.md +1 -0
- package/fixtures/cases/reference-into-a-reserved-name/schema.yaml +3 -0
- package/fixtures/cases/reference-to-any-file-name/context.json +1 -0
- package/fixtures/cases/reference-to-any-file-name/expected.json +1 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/100%.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/C#.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/My notes.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/[draft].md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/c (d).md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/caf/303/251.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people//320/236/321/202/321/207/321/221/321/202.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/bracket.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/cyrillic.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/decomposed.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/hash.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/parenthesis.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/percent.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/spaced.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/schema.yaml +10 -0
- package/fixtures/cases/referenced-missing-file/library/a.md +2 -2
- package/fixtures/cases/referenced-missing-file/library/b.md +2 -2
- package/fixtures/cases/referenced-missing-file/schema.yaml +3 -4
- package/fixtures/cases/referenced-missing-non-latin-file/context.json +1 -0
- package/fixtures/cases/referenced-missing-non-latin-file/expected.json +6 -0
- package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/a.md +9 -0
- package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/b.md +9 -0
- package/fixtures/cases/referenced-missing-non-latin-file/schema.yaml +10 -0
- package/fixtures/cases/room-md-declares-a-type/context.json +1 -0
- package/fixtures/cases/room-md-declares-a-type/expected.json +6 -0
- package/fixtures/cases/room-md-declares-a-type/library/ROOM.md +5 -0
- package/fixtures/cases/sections-keyword-refused/context.json +1 -0
- package/fixtures/cases/sections-keyword-refused/expected.json +5 -0
- package/fixtures/cases/{structured-section → sections-keyword-refused}/schema.yaml +1 -2
- package/fixtures/cases/shortcut-reference-link/library/item.md +1 -1
- package/fixtures/cases/shortcut-reference-link/schema.yaml +2 -3
- package/fixtures/cases/string-length/expected.json +2 -1
- package/fixtures/cases/string-length/library/companies/acme.md +1 -1
- package/fixtures/cases/string-length/library/deals/renewal.md +49 -24
- package/fixtures/cases/string-length/schema.yaml +10 -11
- package/fixtures/cases/submission-keys/library/notes/visitor.md +2 -2
- package/fixtures/cases/text-field-kind/expected.json +1 -4
- package/fixtures/cases/text-field-kind/library/page.md +1 -1
- package/fixtures/cases/thematic-break-ends-the-values/context.json +1 -0
- package/fixtures/cases/thematic-break-ends-the-values/expected.json +1 -0
- package/fixtures/cases/thematic-break-ends-the-values/library/item.md +10 -0
- package/fixtures/cases/thematic-break-ends-the-values/schema.yaml +3 -0
- package/fixtures/cases/typed-path-names-another-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-another-type/expected.json +6 -0
- package/fixtures/cases/typed-path-names-another-type/library/settings/prefs/one.md +3 -0
- package/fixtures/cases/typed-path-names-another-type/schema.yaml +6 -0
- package/fixtures/cases/typed-path-names-its-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-its-type/expected.json +3 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/deeper/two.md +1 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +4 -0
- package/fixtures/cases/typed-path-names-its-type/schema.yaml +6 -0
- package/fixtures/cases/typed-path-names-no-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-no-type/expected.json +6 -0
- package/fixtures/cases/typed-path-names-no-type/library/settings/prefs/one.md +1 -0
- package/fixtures/cases/typed-path-names-no-type/schema.yaml +6 -0
- package/fixtures/cases/types-folder-content/library/types/task.md +1 -1
- package/fixtures/cases/undeclared-field/expected.json +2 -1
- package/fixtures/cases/undeclared-field/library/item.md +2 -2
- package/fixtures/cases/undeclared-field/schema.yaml +2 -3
- package/fixtures/cases/unevaluated-items-closed/expected.json +2 -1
- package/fixtures/cases/unevaluated-items-closed/library/trip.md +13 -3
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/expected.json +6 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +5 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/expected.json +6 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +7 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/expected.json +3 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/plan.md +1 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +6 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/expected.json +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/schema.yaml +5 -0
- package/fixtures/cases/unresolved-link/library/item.md +1 -1
- package/fixtures/cases/unresolved-link/schema.yaml +2 -3
- package/fixtures/cases/valid-typed-document/library/people/ada.md +1 -1
- package/fixtures/cases/valid-typed-document/library/tasks/one.md +11 -11
- package/fixtures/cases/valid-typed-document/schema.yaml +5 -6
- package/fixtures/forms.json +371 -0
- package/fixtures/preamble.json +29 -8
- package/fixtures/queries.json +1562 -0
- package/package.json +16 -2
- package/dist/blocks.d.ts +0 -11
- package/dist/blocks.d.ts.map +0 -1
- package/dist/blocks.js +0 -69
- package/dist/condition.d.ts +0 -149
- package/dist/condition.d.ts.map +0 -1
- package/dist/condition.js +0 -500
- package/dist/divide.d.ts +0 -3
- package/dist/divide.d.ts.map +0 -1
- package/dist/divide.js +0 -320
- package/dist/links.d.ts +0 -28
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -785
- package/dist/profile.d.ts +0 -6
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -5
- package/dist/project.d.ts +0 -22
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js +0 -128
- package/dist/sections.d.ts +0 -11
- package/dist/sections.d.ts.map +0 -1
- package/dist/sections.js +0 -57
- package/fixtures/cases/missing-section-item-kind/expected.json +0 -5
- package/fixtures/cases/missing-section-item-kind/schema.yaml +0 -6
- package/fixtures/cases/null-refused/expected.json +0 -6
- package/fixtures/cases/null-refused/library/companies/acme.md +0 -4
- package/fixtures/cases/null-refused/library/deals/renewal.md +0 -31
- package/fixtures/cases/null-refused/schema.yaml +0 -56
- package/fixtures/cases/open-map-value/expected.json +0 -6
- package/fixtures/cases/open-map-value/library/companies/acme.md +0 -4
- package/fixtures/cases/open-map-value/library/deals/renewal.md +0 -31
- package/fixtures/cases/open-map-value/schema.yaml +0 -56
- package/fixtures/cases/section-item-enum/expected.json +0 -6
- package/fixtures/cases/section-item-enum/library/task.md +0 -8
- package/fixtures/cases/section-item-enum/schema.yaml +0 -3
- package/fixtures/cases/section-item-kind/expected.json +0 -6
- package/fixtures/cases/section-item-kind/library/task.md +0 -8
- package/fixtures/cases/section-item-kind/schema.yaml +0 -3
- package/fixtures/cases/section-items/library/page.md +0 -42
- package/fixtures/cases/section-items/schema.yaml +0 -10
- package/fixtures/cases/section-reference-path/expected.json +0 -6
- package/fixtures/cases/section-reference-path/library/page.md +0 -7
- package/fixtures/cases/section-reference-path/schema.yaml +0 -3
- package/fixtures/cases/section-reference-type/expected.json +0 -6
- package/fixtures/cases/section-reference-type/library/page.md +0 -7
- package/fixtures/cases/section-reference-type/schema.yaml +0 -3
- package/fixtures/cases/structured-section/expected.json +0 -6
- package/fixtures/division.json +0 -409
- package/fixtures/projection.json +0 -255
- /package/fixtures/cases/{missing-section-item-kind → block-scalar-frontmatter}/context.json +0 -0
- /package/fixtures/cases/{section-items → block-scalar-frontmatter}/expected.json +0 -0
- /package/fixtures/cases/{null-refused → conditional-long-text}/context.json +0 -0
- /package/fixtures/cases/{open-map-value → cross-room-link}/context.json +0 -0
- /package/fixtures/cases/{section-item-enum → cross-room-reference}/context.json +0 -0
- /package/fixtures/cases/{section-item-kind → equal-labels}/context.json +0 -0
- /package/fixtures/cases/{section-items → frontmatter-construct}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → labels-in-the-rooms-language}/context.json +0 -0
- /package/fixtures/cases/{section-reference-type → lazy-list-item}/context.json +0 -0
- /package/fixtures/cases/{structured-section → link-into-a-reserved-name-from-an-untyped-document}/context.json +0 -0
- /package/fixtures/cases/{section-items → list-items}/library/other.md +0 -0
- /package/fixtures/cases/{section-reference-path → list-reference-path}/library/other.md +0 -0
- /package/fixtures/cases/{section-reference-type → list-reference-type}/library/note.md +0 -0
package/dist/links.js
DELETED
|
@@ -1,785 +0,0 @@
|
|
|
1
|
-
const TAB_STOP = 4;
|
|
2
|
-
const CLOSING_FENCE_INDENT = 3;
|
|
3
|
-
const CODE_INDENT = 4;
|
|
4
|
-
const HEADING = /^#{1,6}(?:[ \t]|$)/;
|
|
5
|
-
const BREAK = /^(?:(?:\*[ \t]*){3,}|(?:-[ \t]*){3,}|(?:_[ \t]*){3,})$/;
|
|
6
|
-
const SETEXT = /^(?:=+|-+)[ \t]*$/;
|
|
7
|
-
const BLANK = /^[ \t\v\f]*\r?$/;
|
|
8
|
-
const HTML_CLOSED = [
|
|
9
|
-
[/^<(?:script|pre|style)(?:[ \t\v\f>]|$)/i, /<\/(?:script|pre|style)>/i],
|
|
10
|
-
[/^<!--/, /-->/],
|
|
11
|
-
[/^<\?/, /\?>/],
|
|
12
|
-
[/^<![A-Z]/, />/],
|
|
13
|
-
[/^<!\[CDATA\[/, /\]\]>/],
|
|
14
|
-
];
|
|
15
|
-
const HTML_BLOCK_TAG = /^<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:[ \t\v\f>]|\/>|$)/i;
|
|
16
|
-
const HTML_TAG_LINE = /^(?:<[A-Za-z][A-Za-z0-9-]*(?:[ \t\v\f]+[A-Za-z_:][A-Za-z0-9_.:-]*(?:[ \t\v\f]*=[ \t\v\f]*(?:[^ \t\v\f\r\n"'=<>`]+|'[^']*'|"[^"]*"))?)*[ \t\v\f]*\/?>|<\/[A-Za-z][A-Za-z0-9-]*[ \t\v\f]*>)[ \t\v\f]*$/;
|
|
17
|
-
const ORDERED = /^(\d{1,9})[.)]/;
|
|
18
|
-
const LABEL_LENGTH = 999;
|
|
19
|
-
const PUNCTUATION = /^[!-/:-@[-`{-~]$/;
|
|
20
|
-
const INLINE_RAW = new RegExp([
|
|
21
|
-
'<[A-Za-z][A-Za-z0-9-]*(?:[ \\t\\n\\v\\f\\r]+[A-Za-z_:][A-Za-z0-9_.:-]*(?:[ \\t\\n\\v\\f\\r]*=[ \\t\\n\\v\\f\\r]*(?:[^ \\t\\n\\v\\f\\r"\'=<>`]+|\'[^\']*\'|"[^"]*"))?)*[ \\t\\n\\v\\f\\r]*\\/?>',
|
|
22
|
-
'<\\/[A-Za-z][A-Za-z0-9-]*[ \\t\\n\\v\\f\\r]*>',
|
|
23
|
-
'<!--(?!-?>)(?:-?[^-])*-->',
|
|
24
|
-
'<\\?[\\s\\S]*?\\?>',
|
|
25
|
-
'<![A-Z]+[ \\t\\n\\v\\f\\r]+[^>]*>',
|
|
26
|
-
'<!\\[CDATA\\[[\\s\\S]*?\\]\\]>',
|
|
27
|
-
'<[A-Za-z][A-Za-z0-9+.-]{1,31}:[^\\x00-\\x20<>]*>',
|
|
28
|
-
"<[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*>",
|
|
29
|
-
].join('|'), 'y');
|
|
30
|
-
const DELIMITER_ROW = /^\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)*\|?[ \t]*$/;
|
|
31
|
-
const GAP = /^[ \t\v\f]+/;
|
|
32
|
-
function endOfLine(text, from) {
|
|
33
|
-
const nl = text.indexOf('\n', from);
|
|
34
|
-
return nl === -1 ? text.length : nl;
|
|
35
|
-
}
|
|
36
|
-
function afterLine(text, end) {
|
|
37
|
-
return end < text.length ? end + 1 : text.length;
|
|
38
|
-
}
|
|
39
|
-
function itemMarker(text, index, end) {
|
|
40
|
-
let i = index;
|
|
41
|
-
const bullet = text[i];
|
|
42
|
-
if (bullet === '-' || bullet === '*' || bullet === '+')
|
|
43
|
-
i += 1;
|
|
44
|
-
else {
|
|
45
|
-
let digits = 0;
|
|
46
|
-
while (digits < 9 && i + digits < end && text[i + digits] >= '0' && text[i + digits] <= '9')
|
|
47
|
-
digits += 1;
|
|
48
|
-
const delimiter = text[i + digits];
|
|
49
|
-
if (digits === 0 || (delimiter !== '.' && delimiter !== ')'))
|
|
50
|
-
return null;
|
|
51
|
-
i += digits + 1;
|
|
52
|
-
}
|
|
53
|
-
if (i >= end)
|
|
54
|
-
return i;
|
|
55
|
-
if (text[i] !== ' ' && text[i] !== '\t')
|
|
56
|
-
return null;
|
|
57
|
-
return i + 1;
|
|
58
|
-
}
|
|
59
|
-
function readLine(text, start, end) {
|
|
60
|
-
let i = start;
|
|
61
|
-
let depth = 0;
|
|
62
|
-
let item = false;
|
|
63
|
-
let inner = start;
|
|
64
|
-
for (;;) {
|
|
65
|
-
let spaces = 0;
|
|
66
|
-
while (spaces < 3 && i < end && text[i] === ' ') {
|
|
67
|
-
i += 1;
|
|
68
|
-
spaces += 1;
|
|
69
|
-
}
|
|
70
|
-
if (i < end && text[i] === '>') {
|
|
71
|
-
depth += 1;
|
|
72
|
-
i += 1;
|
|
73
|
-
if (i < end && text[i] === ' ')
|
|
74
|
-
i += 1;
|
|
75
|
-
inner = i;
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
const after = i < end ? itemMarker(text, i, end) : null;
|
|
79
|
-
if (after === null)
|
|
80
|
-
break;
|
|
81
|
-
item = true;
|
|
82
|
-
i = after;
|
|
83
|
-
}
|
|
84
|
-
return { start, end, content: i, depth, item, inner };
|
|
85
|
-
}
|
|
86
|
-
function widthOf(text, from, to) {
|
|
87
|
-
let width = 0;
|
|
88
|
-
for (let i = from; i < to; i += 1)
|
|
89
|
-
width += text[i] === '\t' ? TAB_STOP - (width % TAB_STOP) : 1;
|
|
90
|
-
return width;
|
|
91
|
-
}
|
|
92
|
-
function afterIndent(text, line) {
|
|
93
|
-
let i = line.inner;
|
|
94
|
-
while (i < line.end && (text[i] === ' ' || text[i] === '\t'))
|
|
95
|
-
i += 1;
|
|
96
|
-
return i;
|
|
97
|
-
}
|
|
98
|
-
function indentWidth(text, line) {
|
|
99
|
-
return widthOf(text, line.inner, afterIndent(text, line));
|
|
100
|
-
}
|
|
101
|
-
function lineText(text, line) {
|
|
102
|
-
const raw = text.slice(line.content, line.end);
|
|
103
|
-
return raw.endsWith('\r') ? raw.slice(0, -1) : raw;
|
|
104
|
-
}
|
|
105
|
-
function fenceRun(text, at, end) {
|
|
106
|
-
const char = text[at];
|
|
107
|
-
if (char !== '`' && char !== '~')
|
|
108
|
-
return null;
|
|
109
|
-
let length = 0;
|
|
110
|
-
while (at + length < end && text[at + length] === char)
|
|
111
|
-
length += 1;
|
|
112
|
-
return length < 3 ? null : { char, length };
|
|
113
|
-
}
|
|
114
|
-
function fenceAt(text, line) {
|
|
115
|
-
const run = fenceRun(text, line.content, line.end);
|
|
116
|
-
if (run === null)
|
|
117
|
-
return null;
|
|
118
|
-
return {
|
|
119
|
-
char: run.char,
|
|
120
|
-
length: run.length,
|
|
121
|
-
depth: line.depth,
|
|
122
|
-
column: line.item ? widthOf(text, line.inner, line.content) : 0,
|
|
123
|
-
item: line.item,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
function closesFence(text, line, open) {
|
|
127
|
-
if (line.depth !== open.depth || line.item)
|
|
128
|
-
return false;
|
|
129
|
-
const indent = indentWidth(text, line);
|
|
130
|
-
if (indent < open.column || indent > open.column + CLOSING_FENCE_INDENT)
|
|
131
|
-
return false;
|
|
132
|
-
const at = afterIndent(text, line);
|
|
133
|
-
const run = fenceRun(text, at, line.end);
|
|
134
|
-
if (run === null || run.char !== open.char || run.length < open.length)
|
|
135
|
-
return false;
|
|
136
|
-
return text.slice(at + run.length, line.end).trim() === '';
|
|
137
|
-
}
|
|
138
|
-
function leavesContainer(text, line, open) {
|
|
139
|
-
if (line.depth < open.depth)
|
|
140
|
-
return true;
|
|
141
|
-
if (!open.item || lineText(text, line).trim() === '')
|
|
142
|
-
return false;
|
|
143
|
-
return indentWidth(text, line) < open.column;
|
|
144
|
-
}
|
|
145
|
-
function fenceSpan(text, line, open) {
|
|
146
|
-
let cursor = afterLine(text, line.end);
|
|
147
|
-
while (cursor < text.length) {
|
|
148
|
-
const end = endOfLine(text, cursor);
|
|
149
|
-
const next = readLine(text, cursor, end);
|
|
150
|
-
if (leavesContainer(text, next, open))
|
|
151
|
-
return cursor;
|
|
152
|
-
if (closesFence(text, next, open))
|
|
153
|
-
return afterLine(text, end);
|
|
154
|
-
cursor = afterLine(text, end);
|
|
155
|
-
}
|
|
156
|
-
return text.length;
|
|
157
|
-
}
|
|
158
|
-
function skipInlineCode(text, index, joins, unclosed) {
|
|
159
|
-
let ticks = 0;
|
|
160
|
-
while (text[index + ticks] === '`')
|
|
161
|
-
ticks += 1;
|
|
162
|
-
if (index < unclosed.stop && (unclosed.runs.get(ticks) ?? -1) <= index)
|
|
163
|
-
return index + ticks;
|
|
164
|
-
const runs = new Map();
|
|
165
|
-
let i = index + ticks;
|
|
166
|
-
while (i < text.length) {
|
|
167
|
-
const ch = text[i];
|
|
168
|
-
if (ch === '`') {
|
|
169
|
-
let run = 0;
|
|
170
|
-
while (text[i + run] === '`')
|
|
171
|
-
run += 1;
|
|
172
|
-
if (run === ticks)
|
|
173
|
-
return i + run;
|
|
174
|
-
runs.set(run, i);
|
|
175
|
-
i += run;
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
if (ch === '\r' && text[i + 1] !== '\n')
|
|
179
|
-
break;
|
|
180
|
-
if (ch === '\n' && !joins.has(i))
|
|
181
|
-
break;
|
|
182
|
-
i += 1;
|
|
183
|
-
}
|
|
184
|
-
unclosed.stop = i;
|
|
185
|
-
unclosed.runs = runs;
|
|
186
|
-
return index + ticks;
|
|
187
|
-
}
|
|
188
|
-
function skipLinkSpace(text, start) {
|
|
189
|
-
let i = start;
|
|
190
|
-
while (text[i] === ' ' || text[i] === '\t')
|
|
191
|
-
i += 1;
|
|
192
|
-
return i;
|
|
193
|
-
}
|
|
194
|
-
function skipInlineSpace(text, start, joins) {
|
|
195
|
-
let i = skipLinkSpace(text, start);
|
|
196
|
-
if (text[i] === '\r' && text[i + 1] === '\n')
|
|
197
|
-
i += 1;
|
|
198
|
-
if (text[i] !== '\n' || !joins.has(i))
|
|
199
|
-
return i;
|
|
200
|
-
return afterIndent(text, readLine(text, i + 1, endOfLine(text, i + 1)));
|
|
201
|
-
}
|
|
202
|
-
function closeEnd(text, start, open, joins) {
|
|
203
|
-
const close = open === '(' ? ')' : open;
|
|
204
|
-
let i = start;
|
|
205
|
-
while (i < text.length) {
|
|
206
|
-
const ch = text[i];
|
|
207
|
-
if (escapes(text, i)) {
|
|
208
|
-
i += 2;
|
|
209
|
-
continue;
|
|
210
|
-
}
|
|
211
|
-
if (ch === close)
|
|
212
|
-
return i + 1;
|
|
213
|
-
if (open === '(' && ch === '(')
|
|
214
|
-
return null;
|
|
215
|
-
if (ch === '\r' && text[i + 1] !== '\n')
|
|
216
|
-
return null;
|
|
217
|
-
if (ch === '\n' && !joins.has(i))
|
|
218
|
-
return null;
|
|
219
|
-
i += 1;
|
|
220
|
-
}
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
function skipTitle(text, start, joins) {
|
|
224
|
-
const open = text[start];
|
|
225
|
-
if (open !== '"' && open !== "'" && open !== '(')
|
|
226
|
-
return start;
|
|
227
|
-
return closeEnd(text, start + 1, open, joins);
|
|
228
|
-
}
|
|
229
|
-
function destinationAt(text, at, end) {
|
|
230
|
-
if (text[at] === '<') {
|
|
231
|
-
let close = at + 1;
|
|
232
|
-
while (close < end && text[close] !== '>') {
|
|
233
|
-
if (text[close] === '<')
|
|
234
|
-
return null;
|
|
235
|
-
close += escapes(text, close) ? 2 : 1;
|
|
236
|
-
}
|
|
237
|
-
if (close >= end)
|
|
238
|
-
return null;
|
|
239
|
-
return { href: text.slice(at + 1, close), start: at, end: close + 1, bracketed: true };
|
|
240
|
-
}
|
|
241
|
-
let i = at;
|
|
242
|
-
let depth = 0;
|
|
243
|
-
while (i < end) {
|
|
244
|
-
if (escapes(text, i)) {
|
|
245
|
-
i += 2;
|
|
246
|
-
continue;
|
|
247
|
-
}
|
|
248
|
-
const ch = text[i];
|
|
249
|
-
if (ch <= ' ' || ch === '\x7f')
|
|
250
|
-
break;
|
|
251
|
-
if (ch === '(')
|
|
252
|
-
depth += 1;
|
|
253
|
-
else if (ch === ')') {
|
|
254
|
-
if (depth === 0)
|
|
255
|
-
break;
|
|
256
|
-
depth -= 1;
|
|
257
|
-
}
|
|
258
|
-
i += 1;
|
|
259
|
-
}
|
|
260
|
-
if (depth !== 0)
|
|
261
|
-
return null;
|
|
262
|
-
return { href: text.slice(at, i), start: at, end: i, bracketed: false };
|
|
263
|
-
}
|
|
264
|
-
function destination(text, start, joins) {
|
|
265
|
-
let i = skipInlineSpace(text, start + 1, joins);
|
|
266
|
-
const occurrence = destinationAt(text, i, endOfLine(text, i));
|
|
267
|
-
if (occurrence === null)
|
|
268
|
-
return null;
|
|
269
|
-
i = occurrence.end;
|
|
270
|
-
const spaced = skipInlineSpace(text, i, joins);
|
|
271
|
-
if (spaced === i && text[i] !== ')')
|
|
272
|
-
return null;
|
|
273
|
-
i = spaced;
|
|
274
|
-
const afterTitle = skipTitle(text, i, joins);
|
|
275
|
-
if (afterTitle === null)
|
|
276
|
-
return null;
|
|
277
|
-
i = skipInlineSpace(text, afterTitle, joins);
|
|
278
|
-
if (text[i] !== ')')
|
|
279
|
-
return null;
|
|
280
|
-
return { occurrence, end: i + 1 };
|
|
281
|
-
}
|
|
282
|
-
function cellCount(row) {
|
|
283
|
-
return row
|
|
284
|
-
.trim()
|
|
285
|
-
.replace(/^\|/, '')
|
|
286
|
-
.replace(/(?<!\\)\|$/, '')
|
|
287
|
-
.split(/(?<!\\)\|/).length;
|
|
288
|
-
}
|
|
289
|
-
function headsTable(text, header, end) {
|
|
290
|
-
if (end >= text.length)
|
|
291
|
-
return false;
|
|
292
|
-
const row = lineText(text, readLine(text, end + 1, endOfLine(text, end + 1)));
|
|
293
|
-
return row.includes('|') && DELIMITER_ROW.test(row) && cellCount(row) === cellCount(header);
|
|
294
|
-
}
|
|
295
|
-
function blockText(text, line) {
|
|
296
|
-
if (!line.item)
|
|
297
|
-
return lineText(text, line);
|
|
298
|
-
const raw = text.slice(afterIndent(text, line), line.end);
|
|
299
|
-
return raw.endsWith('\r') ? raw.slice(0, -1) : raw;
|
|
300
|
-
}
|
|
301
|
-
function interruptsWithHtml(head) {
|
|
302
|
-
return HTML_CLOSED.some(([open]) => open.test(head)) || HTML_BLOCK_TAG.test(head);
|
|
303
|
-
}
|
|
304
|
-
function markerColumn(text, line) {
|
|
305
|
-
return widthOf(text, line.inner, afterIndent(text, line));
|
|
306
|
-
}
|
|
307
|
-
function markerEnd(text, at, end) {
|
|
308
|
-
const after = itemMarker(text, at, end);
|
|
309
|
-
if (after === null)
|
|
310
|
-
return null;
|
|
311
|
-
return after > at && (text[after - 1] === ' ' || text[after - 1] === '\t') ? after - 1 : after;
|
|
312
|
-
}
|
|
313
|
-
function itemContent(text, line) {
|
|
314
|
-
let marker = markerEnd(text, afterIndent(text, line), line.end);
|
|
315
|
-
for (;;) {
|
|
316
|
-
let next = marker + 1;
|
|
317
|
-
let spaces = 0;
|
|
318
|
-
while (spaces < 3 && text[next] === ' ') {
|
|
319
|
-
next += 1;
|
|
320
|
-
spaces += 1;
|
|
321
|
-
}
|
|
322
|
-
const nested = next < line.end ? markerEnd(text, next, line.end) : null;
|
|
323
|
-
if (nested === null)
|
|
324
|
-
break;
|
|
325
|
-
marker = nested;
|
|
326
|
-
}
|
|
327
|
-
const at = skipLinkSpace(text, marker);
|
|
328
|
-
const rest = text.slice(at, line.end).trim();
|
|
329
|
-
const column = widthOf(text, line.inner, at);
|
|
330
|
-
const start = widthOf(text, line.inner, marker);
|
|
331
|
-
if (rest !== '' && column - start <= CODE_INDENT)
|
|
332
|
-
return { column, code: null };
|
|
333
|
-
return { column: start + 1, code: rest === '' ? null : marker + 1 };
|
|
334
|
-
}
|
|
335
|
-
function joinsParagraph(text, line, depth, item) {
|
|
336
|
-
if (line.depth > depth)
|
|
337
|
-
return false;
|
|
338
|
-
const head = blockText(text, line);
|
|
339
|
-
if (head.trim() === '' || endsBlock(head) || interruptsWithHtml(head))
|
|
340
|
-
return false;
|
|
341
|
-
if (fenceAt(text, line) !== null)
|
|
342
|
-
return false;
|
|
343
|
-
if (!line.item)
|
|
344
|
-
return true;
|
|
345
|
-
if (item !== undefined && markerColumn(text, line) < item)
|
|
346
|
-
return false;
|
|
347
|
-
if (lineText(text, line).trim() === '')
|
|
348
|
-
return true;
|
|
349
|
-
const ordered = ORDERED.exec(head);
|
|
350
|
-
return ordered !== null && Number(ordered[1]) !== 1;
|
|
351
|
-
}
|
|
352
|
-
function startsParagraph(text, line) {
|
|
353
|
-
return lineText(text, line).trim() !== '' && !endsBlock(blockText(text, line));
|
|
354
|
-
}
|
|
355
|
-
function lineColumn(text, line) {
|
|
356
|
-
return line.item ? markerColumn(text, line) : indentWidth(text, line);
|
|
357
|
-
}
|
|
358
|
-
function endsTable(text, line, depth) {
|
|
359
|
-
const head = blockText(text, line);
|
|
360
|
-
return (head.trim() === '' ||
|
|
361
|
-
line.depth !== depth ||
|
|
362
|
-
line.item ||
|
|
363
|
-
endsBlock(head) ||
|
|
364
|
-
interruptsWithHtml(head) ||
|
|
365
|
-
fenceAt(text, line) !== null);
|
|
366
|
-
}
|
|
367
|
-
function quoteInner(text, start, end, depth) {
|
|
368
|
-
let i = start;
|
|
369
|
-
for (let level = 0; level < depth; level += 1) {
|
|
370
|
-
let spaces = 0;
|
|
371
|
-
while (spaces < 3 && i < end && text[i] === ' ') {
|
|
372
|
-
i += 1;
|
|
373
|
-
spaces += 1;
|
|
374
|
-
}
|
|
375
|
-
if (text[i] !== '>')
|
|
376
|
-
return null;
|
|
377
|
-
i += 1;
|
|
378
|
-
if (text[i] === ' ')
|
|
379
|
-
i += 1;
|
|
380
|
-
}
|
|
381
|
-
return i;
|
|
382
|
-
}
|
|
383
|
-
function htmlEnd(text, line, item) {
|
|
384
|
-
const head = lineText(text, line);
|
|
385
|
-
const closed = HTML_CLOSED.find(([open]) => open.test(head));
|
|
386
|
-
if (closed === undefined && !HTML_BLOCK_TAG.test(head) && !HTML_TAG_LINE.test(head))
|
|
387
|
-
return null;
|
|
388
|
-
if (closed !== undefined && closed[1].test(head))
|
|
389
|
-
return afterLine(text, line.end);
|
|
390
|
-
let cursor = afterLine(text, line.end);
|
|
391
|
-
while (cursor < text.length) {
|
|
392
|
-
const end = endOfLine(text, cursor);
|
|
393
|
-
const inner = quoteInner(text, cursor, end, line.depth);
|
|
394
|
-
if (inner === null)
|
|
395
|
-
return cursor;
|
|
396
|
-
const at = skipLinkSpace(text, inner);
|
|
397
|
-
const body = text.slice(inner, end);
|
|
398
|
-
const blank = BLANK.test(text.slice(at, end));
|
|
399
|
-
if (item !== undefined && !blank && widthOf(text, inner, at) < item)
|
|
400
|
-
return cursor;
|
|
401
|
-
if (closed === undefined && blank)
|
|
402
|
-
return cursor;
|
|
403
|
-
if (closed !== undefined && closed[1].test(body))
|
|
404
|
-
return afterLine(text, end);
|
|
405
|
-
cursor = afterLine(text, end);
|
|
406
|
-
if (cursor === end)
|
|
407
|
-
break;
|
|
408
|
-
}
|
|
409
|
-
return text.length;
|
|
410
|
-
}
|
|
411
|
-
function codeEnd(text, line, base) {
|
|
412
|
-
let stop = afterLine(text, line.end);
|
|
413
|
-
let cursor = stop;
|
|
414
|
-
while (cursor < text.length) {
|
|
415
|
-
const end = endOfLine(text, cursor);
|
|
416
|
-
const current = readLine(text, cursor, end);
|
|
417
|
-
if (current.depth !== line.depth)
|
|
418
|
-
break;
|
|
419
|
-
const blank = lineText(text, current).trim() === '' && !current.item;
|
|
420
|
-
if (!blank && (current.item || indentWidth(text, current) < base + CODE_INDENT))
|
|
421
|
-
break;
|
|
422
|
-
cursor = afterLine(text, end);
|
|
423
|
-
if (!blank)
|
|
424
|
-
stop = cursor;
|
|
425
|
-
if (cursor === end)
|
|
426
|
-
break;
|
|
427
|
-
}
|
|
428
|
-
return stop;
|
|
429
|
-
}
|
|
430
|
-
function structure(text) {
|
|
431
|
-
const joins = new Set();
|
|
432
|
-
const raw = [];
|
|
433
|
-
const items = [];
|
|
434
|
-
let paragraph = null;
|
|
435
|
-
let table = null;
|
|
436
|
-
let depth = 0;
|
|
437
|
-
let cursor = 0;
|
|
438
|
-
while (cursor < text.length) {
|
|
439
|
-
const end = endOfLine(text, cursor);
|
|
440
|
-
const line = readLine(text, cursor, end);
|
|
441
|
-
const content = lineText(text, line);
|
|
442
|
-
const blank = content.trim() === '' && !line.item;
|
|
443
|
-
if (table !== null && endsTable(text, line, table))
|
|
444
|
-
table = null;
|
|
445
|
-
if (table !== null) {
|
|
446
|
-
cursor = afterLine(text, end);
|
|
447
|
-
if (cursor === end)
|
|
448
|
-
break;
|
|
449
|
-
continue;
|
|
450
|
-
}
|
|
451
|
-
if (paragraph !== null && joinsParagraph(text, line, paragraph, items.at(-1))) {
|
|
452
|
-
if (headsTable(text, content, end)) {
|
|
453
|
-
table = line.depth;
|
|
454
|
-
paragraph = null;
|
|
455
|
-
}
|
|
456
|
-
else
|
|
457
|
-
joins.add(cursor - 1);
|
|
458
|
-
cursor = afterLine(text, end);
|
|
459
|
-
if (cursor === end)
|
|
460
|
-
break;
|
|
461
|
-
continue;
|
|
462
|
-
}
|
|
463
|
-
paragraph = null;
|
|
464
|
-
if (line.depth !== depth)
|
|
465
|
-
items.length = 0;
|
|
466
|
-
depth = line.depth;
|
|
467
|
-
if (!blank) {
|
|
468
|
-
while (items.length > 0 && items.at(-1) > lineColumn(text, line))
|
|
469
|
-
items.pop();
|
|
470
|
-
}
|
|
471
|
-
if (line.item && !BREAK.test(blockText(text, line))) {
|
|
472
|
-
const opened = itemContent(text, line);
|
|
473
|
-
items.push(opened.column);
|
|
474
|
-
if (opened.code !== null) {
|
|
475
|
-
const stop = codeEnd(text, line, opened.column);
|
|
476
|
-
raw.push([opened.code, stop]);
|
|
477
|
-
cursor = stop;
|
|
478
|
-
continue;
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
const open = fenceAt(text, line);
|
|
482
|
-
if (open !== null) {
|
|
483
|
-
const stop = fenceSpan(text, line, open);
|
|
484
|
-
raw.push([cursor, stop]);
|
|
485
|
-
cursor = stop;
|
|
486
|
-
continue;
|
|
487
|
-
}
|
|
488
|
-
const base = items.at(-1) ?? 0;
|
|
489
|
-
if (!blank && !line.item && indentWidth(text, line) >= base + CODE_INDENT) {
|
|
490
|
-
const stop = codeEnd(text, line, base);
|
|
491
|
-
raw.push([cursor, stop]);
|
|
492
|
-
cursor = stop;
|
|
493
|
-
continue;
|
|
494
|
-
}
|
|
495
|
-
const html = htmlEnd(text, line, items.at(-1));
|
|
496
|
-
if (html !== null) {
|
|
497
|
-
raw.push([cursor, html]);
|
|
498
|
-
cursor = html;
|
|
499
|
-
continue;
|
|
500
|
-
}
|
|
501
|
-
if (startsParagraph(text, line)) {
|
|
502
|
-
if (headsTable(text, content, end))
|
|
503
|
-
table = line.depth;
|
|
504
|
-
else
|
|
505
|
-
paragraph = line.depth;
|
|
506
|
-
}
|
|
507
|
-
cursor = afterLine(text, end);
|
|
508
|
-
if (cursor === end)
|
|
509
|
-
break;
|
|
510
|
-
}
|
|
511
|
-
return { joins, raw };
|
|
512
|
-
}
|
|
513
|
-
export function escapes(text, index) {
|
|
514
|
-
return text[index] === '\\' && PUNCTUATION.test(text[index + 1] ?? '');
|
|
515
|
-
}
|
|
516
|
-
function referenceEnd(text, start, joins) {
|
|
517
|
-
let i = start;
|
|
518
|
-
while (i < text.length) {
|
|
519
|
-
const ch = text[i];
|
|
520
|
-
if (escapes(text, i)) {
|
|
521
|
-
i += 2;
|
|
522
|
-
continue;
|
|
523
|
-
}
|
|
524
|
-
if (ch === ']')
|
|
525
|
-
return i + 1;
|
|
526
|
-
if (ch === '[')
|
|
527
|
-
return -1;
|
|
528
|
-
if (ch === '\r' && text[i + 1] !== '\n')
|
|
529
|
-
return -1;
|
|
530
|
-
if (ch === '\n' && !joins.has(i))
|
|
531
|
-
return -1;
|
|
532
|
-
i += 1;
|
|
533
|
-
}
|
|
534
|
-
return -1;
|
|
535
|
-
}
|
|
536
|
-
function labelText(text, from, to) {
|
|
537
|
-
let label = '';
|
|
538
|
-
let cursor = from;
|
|
539
|
-
let newline = text.indexOf('\n', cursor);
|
|
540
|
-
while (newline !== -1 && newline < to) {
|
|
541
|
-
label += `${text.slice(cursor, newline)}\n`;
|
|
542
|
-
cursor = afterIndent(text, readLine(text, newline + 1, endOfLine(text, newline + 1)));
|
|
543
|
-
newline = text.indexOf('\n', cursor);
|
|
544
|
-
}
|
|
545
|
-
return label + text.slice(cursor, to);
|
|
546
|
-
}
|
|
547
|
-
function labelKey(label) {
|
|
548
|
-
return label
|
|
549
|
-
.replace(/[ \t\n\v\f\r]+/g, ' ')
|
|
550
|
-
.replace(/^ | $/g, '')
|
|
551
|
-
.toLowerCase()
|
|
552
|
-
.split('\u0131')
|
|
553
|
-
.map((part) => part.toUpperCase())
|
|
554
|
-
.join('\u0131');
|
|
555
|
-
}
|
|
556
|
-
function labelKeyAt(text, from, to) {
|
|
557
|
-
const label = labelText(text, from, to);
|
|
558
|
-
if (label.length > LABEL_LENGTH && [...label].length > LABEL_LENGTH)
|
|
559
|
-
return '';
|
|
560
|
-
return labelKey(label);
|
|
561
|
-
}
|
|
562
|
-
function closeLink(text, opener, close, defs, joins) {
|
|
563
|
-
const end = close + 1;
|
|
564
|
-
const use = (destination, to) => ({
|
|
565
|
-
start: opener.start,
|
|
566
|
-
end: to,
|
|
567
|
-
labelStart: opener.at + 1,
|
|
568
|
-
labelEnd: close,
|
|
569
|
-
destination,
|
|
570
|
-
});
|
|
571
|
-
if (text[end] === '(') {
|
|
572
|
-
const dest = destination(text, end, joins);
|
|
573
|
-
if (dest !== null)
|
|
574
|
-
return use(dest.occurrence, dest.end);
|
|
575
|
-
}
|
|
576
|
-
if (text[end] === '[') {
|
|
577
|
-
const second = referenceEnd(text, end + 1, joins);
|
|
578
|
-
const collapsed = second === end + 2;
|
|
579
|
-
const named = collapsed
|
|
580
|
-
? opener.bracketAfter
|
|
581
|
-
? ''
|
|
582
|
-
: labelKeyAt(text, opener.at + 1, close)
|
|
583
|
-
: labelKeyAt(text, end + 1, second - 1);
|
|
584
|
-
if (second !== -1 && (named !== '' || collapsed)) {
|
|
585
|
-
const defined = defs.get(named);
|
|
586
|
-
return defined === undefined ? null : use(defined, second);
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
if (opener.bracketAfter)
|
|
590
|
-
return null;
|
|
591
|
-
const shortcut = defs.get(labelKeyAt(text, opener.at + 1, close));
|
|
592
|
-
return shortcut === undefined ? null : use(shortcut, end);
|
|
593
|
-
}
|
|
594
|
-
function definitionDestination(text, from, to) {
|
|
595
|
-
const occurrence = destinationAt(text, skipLinkSpace(text, from), to);
|
|
596
|
-
return occurrence === null || (occurrence.href === '' && !occurrence.bracketed)
|
|
597
|
-
? null
|
|
598
|
-
: occurrence;
|
|
599
|
-
}
|
|
600
|
-
function titleEnd(text, at, joins) {
|
|
601
|
-
const open = text[at];
|
|
602
|
-
if (open !== '"' && open !== "'" && open !== '(')
|
|
603
|
-
return null;
|
|
604
|
-
const closed = closeEnd(text, at + 1, open, joins);
|
|
605
|
-
if (closed === null)
|
|
606
|
-
return null;
|
|
607
|
-
const end = endOfLine(text, closed);
|
|
608
|
-
return BLANK.test(text.slice(closed, end)) ? afterLine(text, end) : null;
|
|
609
|
-
}
|
|
610
|
-
function definitionAt(text, line, joins) {
|
|
611
|
-
if (text[line.content] !== '[')
|
|
612
|
-
return null;
|
|
613
|
-
const close = referenceEnd(text, line.content + 1, joins);
|
|
614
|
-
if (close === -1 || text[close] !== ':')
|
|
615
|
-
return null;
|
|
616
|
-
const id = labelKeyAt(text, line.content + 1, close - 1);
|
|
617
|
-
if (id === '')
|
|
618
|
-
return null;
|
|
619
|
-
const from = close + 1;
|
|
620
|
-
let end = endOfLine(text, from);
|
|
621
|
-
let occurrence = definitionDestination(text, from, end);
|
|
622
|
-
if (occurrence === null) {
|
|
623
|
-
if (text.slice(from, end).trim() !== '' || !joins.has(end))
|
|
624
|
-
return null;
|
|
625
|
-
const start = end + 1;
|
|
626
|
-
end = endOfLine(text, start);
|
|
627
|
-
occurrence = definitionDestination(text, afterIndent(text, readLine(text, start, end)), end);
|
|
628
|
-
if (occurrence === null)
|
|
629
|
-
return null;
|
|
630
|
-
}
|
|
631
|
-
const rest = text.slice(occurrence.end, end);
|
|
632
|
-
if (!BLANK.test(rest)) {
|
|
633
|
-
const gap = GAP.exec(rest);
|
|
634
|
-
const titled = gap === null ? null : titleEnd(text, occurrence.end + gap[0].length, joins);
|
|
635
|
-
return titled === null ? null : { id, occurrence, next: titled };
|
|
636
|
-
}
|
|
637
|
-
const next = afterLine(text, end);
|
|
638
|
-
if (joins.has(end)) {
|
|
639
|
-
const titled = titleEnd(text, afterIndent(text, readLine(text, next, endOfLine(text, next))), joins);
|
|
640
|
-
if (titled !== null)
|
|
641
|
-
return { id, occurrence, next: titled };
|
|
642
|
-
}
|
|
643
|
-
return { id, occurrence, next };
|
|
644
|
-
}
|
|
645
|
-
function endsBlock(content) {
|
|
646
|
-
return HEADING.test(content) || BREAK.test(content) || SETEXT.test(content);
|
|
647
|
-
}
|
|
648
|
-
function scanBlocks(text) {
|
|
649
|
-
const { joins, raw } = structure(text);
|
|
650
|
-
const rawEnd = spanCursor(raw);
|
|
651
|
-
const definitions = new Map();
|
|
652
|
-
const blocks = [];
|
|
653
|
-
let fresh = 0;
|
|
654
|
-
let i = 0;
|
|
655
|
-
while (i < text.length) {
|
|
656
|
-
const skip = rawEnd(i);
|
|
657
|
-
if (skip !== undefined) {
|
|
658
|
-
i = skip;
|
|
659
|
-
continue;
|
|
660
|
-
}
|
|
661
|
-
const line = readLine(text, i, endOfLine(text, i));
|
|
662
|
-
const definition = lineText(text, line).trim() === '' || (i !== fresh && joins.has(i - 1))
|
|
663
|
-
? null
|
|
664
|
-
: definitionAt(text, line, joins);
|
|
665
|
-
if (definition !== null) {
|
|
666
|
-
if (!definitions.has(definition.id))
|
|
667
|
-
definitions.set(definition.id, definition.occurrence);
|
|
668
|
-
blocks.push({ start: line.start, end: definition.next, destination: definition.occurrence });
|
|
669
|
-
i = definition.next;
|
|
670
|
-
fresh = i;
|
|
671
|
-
continue;
|
|
672
|
-
}
|
|
673
|
-
i = afterLine(text, line.end);
|
|
674
|
-
}
|
|
675
|
-
return { raw, definitions, blocks, joins };
|
|
676
|
-
}
|
|
677
|
-
export function spanCursor(spans) {
|
|
678
|
-
let next = 0;
|
|
679
|
-
return (index) => {
|
|
680
|
-
while (next < spans.length && spans[next][1] <= index)
|
|
681
|
-
next += 1;
|
|
682
|
-
const span = spans[next];
|
|
683
|
-
return span !== undefined && span[0] <= index ? span[1] : undefined;
|
|
684
|
-
};
|
|
685
|
-
}
|
|
686
|
-
export function fenceSpans(text) {
|
|
687
|
-
const fences = [];
|
|
688
|
-
let i = 0;
|
|
689
|
-
while (i < text.length) {
|
|
690
|
-
const line = readLine(text, i, endOfLine(text, i));
|
|
691
|
-
const open = fenceAt(text, line);
|
|
692
|
-
if (open === null) {
|
|
693
|
-
i = afterLine(text, line.end);
|
|
694
|
-
continue;
|
|
695
|
-
}
|
|
696
|
-
const stop = fenceSpan(text, line, open);
|
|
697
|
-
fences.push([i, stop]);
|
|
698
|
-
i = stop;
|
|
699
|
-
}
|
|
700
|
-
return fences;
|
|
701
|
-
}
|
|
702
|
-
function paragraphEnd(text, from, joins) {
|
|
703
|
-
let i = from;
|
|
704
|
-
while (i < text.length) {
|
|
705
|
-
if (text[i] === '\n' && !joins.has(i))
|
|
706
|
-
return i;
|
|
707
|
-
if (text[i] === '\r' && text[i + 1] !== '\n')
|
|
708
|
-
return i;
|
|
709
|
-
i += 1;
|
|
710
|
-
}
|
|
711
|
-
return i;
|
|
712
|
-
}
|
|
713
|
-
export function linkInventory(body) {
|
|
714
|
-
const { raw, definitions, blocks, joins } = scanBlocks(body);
|
|
715
|
-
const rawEnd = spanCursor(raw);
|
|
716
|
-
const blockEnd = spanCursor(blocks.map((block) => [block.start, block.end]));
|
|
717
|
-
const uses = [];
|
|
718
|
-
const openers = [];
|
|
719
|
-
const unclosed = { stop: 0, runs: new Map() };
|
|
720
|
-
let paragraph = { start: 0, end: -1, text: '' };
|
|
721
|
-
let i = 0;
|
|
722
|
-
while (i < body.length) {
|
|
723
|
-
const skipEnd = rawEnd(i) ?? blockEnd(i);
|
|
724
|
-
if (skipEnd !== undefined) {
|
|
725
|
-
openers.length = 0;
|
|
726
|
-
i = skipEnd;
|
|
727
|
-
continue;
|
|
728
|
-
}
|
|
729
|
-
const ch = body[i];
|
|
730
|
-
if (escapes(body, i)) {
|
|
731
|
-
i += 2;
|
|
732
|
-
continue;
|
|
733
|
-
}
|
|
734
|
-
if (ch === '`') {
|
|
735
|
-
i = skipInlineCode(body, i, joins, unclosed);
|
|
736
|
-
continue;
|
|
737
|
-
}
|
|
738
|
-
if (ch === '<') {
|
|
739
|
-
if (i >= paragraph.end) {
|
|
740
|
-
const end = paragraphEnd(body, i, joins);
|
|
741
|
-
paragraph = { start: i, end, text: body.slice(i, end) };
|
|
742
|
-
}
|
|
743
|
-
INLINE_RAW.lastIndex = i - paragraph.start;
|
|
744
|
-
const raw = INLINE_RAW.exec(paragraph.text);
|
|
745
|
-
if (raw !== null) {
|
|
746
|
-
i += raw[0].length;
|
|
747
|
-
continue;
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
if ((ch === '\n' && !joins.has(i)) || (ch === '\r' && body[i + 1] !== '\n'))
|
|
751
|
-
openers.length = 0;
|
|
752
|
-
if (ch === '[' || (ch === '!' && body[i + 1] === '[')) {
|
|
753
|
-
const previous = openers.at(-1);
|
|
754
|
-
if (previous !== undefined)
|
|
755
|
-
previous.bracketAfter = true;
|
|
756
|
-
const image = ch === '!';
|
|
757
|
-
openers.push({ at: image ? i + 1 : i, start: i, image, active: true, bracketAfter: false });
|
|
758
|
-
i += image ? 2 : 1;
|
|
759
|
-
continue;
|
|
760
|
-
}
|
|
761
|
-
if (ch === ']') {
|
|
762
|
-
const opener = openers.pop();
|
|
763
|
-
const use = opener?.active ? closeLink(body, opener, i, definitions, joins) : null;
|
|
764
|
-
if (opener === undefined || use === null) {
|
|
765
|
-
i += 1;
|
|
766
|
-
continue;
|
|
767
|
-
}
|
|
768
|
-
uses.push(use);
|
|
769
|
-
if (!opener.image)
|
|
770
|
-
for (const earlier of openers)
|
|
771
|
-
if (!earlier.image)
|
|
772
|
-
earlier.active = false;
|
|
773
|
-
i = use.end;
|
|
774
|
-
continue;
|
|
775
|
-
}
|
|
776
|
-
i += 1;
|
|
777
|
-
}
|
|
778
|
-
return { uses, blocks };
|
|
779
|
-
}
|
|
780
|
-
export function hrefOccurrences(body) {
|
|
781
|
-
const byStart = new Map();
|
|
782
|
-
for (const use of linkInventory(body).uses)
|
|
783
|
-
byStart.set(use.destination.start, use.destination);
|
|
784
|
-
return [...byStart.values()].sort((left, right) => left.start - right.start);
|
|
785
|
-
}
|