@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.
Files changed (461) hide show
  1. package/API.md +287 -278
  2. package/README.md +28 -29
  3. package/dist/body.d.ts +85 -0
  4. package/dist/body.d.ts.map +1 -0
  5. package/dist/body.js +1083 -0
  6. package/dist/built-in.d.ts +4 -0
  7. package/dist/built-in.d.ts.map +1 -0
  8. package/dist/built-in.js +19 -0
  9. package/dist/definition.d.ts +26 -11
  10. package/dist/definition.d.ts.map +1 -1
  11. package/dist/definition.js +259 -93
  12. package/dist/document.d.ts +16 -9
  13. package/dist/document.d.ts.map +1 -1
  14. package/dist/document.js +996 -254
  15. package/dist/event.d.ts +77 -0
  16. package/dist/event.d.ts.map +1 -0
  17. package/dist/event.js +200 -0
  18. package/dist/facts.d.ts +15 -0
  19. package/dist/facts.d.ts.map +1 -0
  20. package/dist/facts.js +41 -0
  21. package/dist/fields.d.ts +1 -1
  22. package/dist/fields.d.ts.map +1 -1
  23. package/dist/fields.js +2 -2
  24. package/dist/form.d.ts +4 -0
  25. package/dist/form.d.ts.map +1 -0
  26. package/dist/form.js +153 -0
  27. package/dist/house-model.d.ts +920 -0
  28. package/dist/house-model.d.ts.map +1 -0
  29. package/dist/house-model.js +504 -0
  30. package/dist/house-references/crockford.d.ts +4 -0
  31. package/dist/house-references/crockford.d.ts.map +1 -0
  32. package/dist/house-references/crockford.js +3 -0
  33. package/dist/house-references/patterns.d.ts +9 -0
  34. package/dist/house-references/patterns.d.ts.map +1 -0
  35. package/dist/house-references/patterns.js +13 -0
  36. package/dist/index.d.ts +45 -16
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +27 -11
  39. package/dist/indexed.d.ts +9 -0
  40. package/dist/indexed.d.ts.map +1 -0
  41. package/dist/indexed.js +55 -0
  42. package/dist/kinds.d.ts +21 -0
  43. package/dist/kinds.d.ts.map +1 -0
  44. package/dist/kinds.js +210 -0
  45. package/dist/markdown.d.ts +71 -0
  46. package/dist/markdown.d.ts.map +1 -0
  47. package/dist/markdown.js +232 -0
  48. package/dist/media-type.d.ts +72 -0
  49. package/dist/media-type.d.ts.map +1 -0
  50. package/dist/media-type.js +157 -0
  51. package/dist/moment.d.ts +7 -0
  52. package/dist/moment.d.ts.map +1 -0
  53. package/dist/moment.js +18 -0
  54. package/dist/not-ready.d.ts +2 -0
  55. package/dist/not-ready.d.ts.map +1 -0
  56. package/dist/not-ready.js +5 -0
  57. package/dist/paths.d.ts +25 -2
  58. package/dist/paths.d.ts.map +1 -1
  59. package/dist/paths.js +129 -18
  60. package/dist/pattern.d.ts +10 -0
  61. package/dist/pattern.d.ts.map +1 -0
  62. package/dist/pattern.js +356 -0
  63. package/dist/query/language.d.ts +257 -0
  64. package/dist/query/language.d.ts.map +1 -0
  65. package/dist/query/language.js +621 -0
  66. package/dist/query/match.d.ts +14 -0
  67. package/dist/query/match.d.ts.map +1 -0
  68. package/dist/query/match.js +129 -0
  69. package/dist/query/rows.d.ts +36 -0
  70. package/dist/query/rows.d.ts.map +1 -0
  71. package/dist/query/rows.js +179 -0
  72. package/dist/query/sql.d.ts +45 -0
  73. package/dist/query/sql.d.ts.map +1 -0
  74. package/dist/query/sql.js +296 -0
  75. package/dist/query/walk.d.ts +69 -0
  76. package/dist/query/walk.d.ts.map +1 -0
  77. package/dist/query/walk.js +274 -0
  78. package/dist/references.d.ts +2 -2
  79. package/dist/references.d.ts.map +1 -1
  80. package/dist/references.js +7 -2
  81. package/dist/refuse.d.ts +1 -0
  82. package/dist/refuse.d.ts.map +1 -1
  83. package/dist/refuse.js +1 -0
  84. package/dist/reserved.d.ts +7 -0
  85. package/dist/reserved.d.ts.map +1 -0
  86. package/dist/reserved.js +32 -0
  87. package/dist/room-types.d.ts +8 -0
  88. package/dist/room-types.d.ts.map +1 -0
  89. package/dist/room-types.js +144 -0
  90. package/dist/schema.d.ts +1 -2
  91. package/dist/schema.d.ts.map +1 -1
  92. package/dist/schema.js +10 -23
  93. package/dist/types.d.ts +44 -34
  94. package/dist/types.d.ts.map +1 -1
  95. package/dist/validate.d.ts +34 -5
  96. package/dist/validate.d.ts.map +1 -1
  97. package/dist/validate.js +345 -151
  98. package/dist/view.d.ts +5 -0
  99. package/dist/view.d.ts.map +1 -0
  100. package/dist/view.js +27 -0
  101. package/dist/yaml.d.ts +7 -5
  102. package/dist/yaml.d.ts.map +1 -1
  103. package/dist/yaml.js +190 -43
  104. package/fixtures/README.md +93 -65
  105. package/fixtures/cases/absent-link-dangles/library/item.md +1 -1
  106. package/fixtures/cases/absent-link-dangles/schema.yaml +2 -3
  107. package/fixtures/cases/absent-optional-field/library/companies/acme.md +1 -1
  108. package/fixtures/cases/absent-optional-field/library/deals/lead.md +3 -3
  109. package/fixtures/cases/absent-optional-field/schema.yaml +10 -11
  110. package/fixtures/cases/absolute-link/library/item.md +1 -1
  111. package/fixtures/cases/absolute-link/schema.yaml +2 -3
  112. package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +1 -1
  113. package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +13 -10
  114. package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +1 -1
  115. package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +1 -1
  116. package/fixtures/cases/attachment-reference-any-file/library/products/support.md +1 -1
  117. package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +1 -1
  118. package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +13 -10
  119. package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +1 -1
  120. package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +1 -1
  121. package/fixtures/cases/attachment-reference-dangles/library/products/support.md +1 -1
  122. package/fixtures/cases/attachment-reference-outside/expected.json +2 -1
  123. package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +1 -1
  124. package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +13 -10
  125. package/fixtures/cases/attachment-reference-outside/library/places/depot.md +1 -1
  126. package/fixtures/cases/attachment-reference-outside/library/products/seats.md +1 -1
  127. package/fixtures/cases/attachment-reference-outside/library/products/support.md +1 -1
  128. package/fixtures/cases/binary-any-reference/expected.json +2 -1
  129. package/fixtures/cases/binary-any-reference/library/notes/draft.md +1 -1
  130. package/fixtures/cases/binary-prototype-reference/expected.json +2 -1
  131. package/fixtures/cases/binary-prototype-reference/library/notes/draft.md +1 -1
  132. package/fixtures/cases/binary-typed-reference/expected.json +2 -1
  133. package/fixtures/cases/binary-typed-reference/library/notes/draft.md +1 -1
  134. package/fixtures/cases/block-scalar-frontmatter/library/notes/literal.md +17 -0
  135. package/fixtures/cases/block-scalar-frontmatter/library/skills/notes/SKILL.md +10 -0
  136. package/fixtures/cases/boolean-field/expected.json +2 -1
  137. package/fixtures/cases/boolean-field/library/companies/acme.md +1 -1
  138. package/fixtures/cases/boolean-field/library/deals/renewal.md +49 -24
  139. package/fixtures/cases/boolean-field/schema.yaml +10 -11
  140. package/fixtures/cases/bracketed-link-definition/library/item.md +1 -1
  141. package/fixtures/cases/bracketed-link-definition/schema.yaml +2 -3
  142. package/fixtures/cases/closed-nested-object/expected.json +2 -1
  143. package/fixtures/cases/closed-nested-object/library/companies/acme.md +1 -1
  144. package/fixtures/cases/closed-nested-object/library/deals/renewal.md +50 -25
  145. package/fixtures/cases/closed-nested-object/schema.yaml +10 -11
  146. package/fixtures/cases/composed-root-reference/library/a.md +2 -2
  147. package/fixtures/cases/conditional-long-text/expected.json +7 -0
  148. package/fixtures/cases/conditional-long-text/library/questions/hosting.md +9 -0
  149. package/fixtures/cases/conditional-long-text/library/questions/payments.md +12 -0
  150. package/fixtures/cases/conditional-long-text/schema.yaml +13 -0
  151. package/fixtures/cases/cross-room-link/expected.json +1 -0
  152. package/fixtures/cases/cross-room-link/library/clients/acme.md +6 -0
  153. package/fixtures/cases/cross-room-link/schema.yaml +3 -0
  154. package/fixtures/cases/cross-room-reference/expected.json +1 -0
  155. package/fixtures/cases/cross-room-reference/library/clients/acme.md +9 -0
  156. package/fixtures/cases/cross-room-reference/schema.yaml +8 -0
  157. package/fixtures/cases/date-time-format/expected.json +2 -1
  158. package/fixtures/cases/date-time-format/library/companies/acme.md +1 -1
  159. package/fixtures/cases/date-time-format/library/deals/renewal.md +49 -24
  160. package/fixtures/cases/date-time-format/schema.yaml +10 -11
  161. package/fixtures/cases/default-unfilled/library/companies/acme.md +1 -1
  162. package/fixtures/cases/default-unfilled/library/deals/renewal.md +47 -22
  163. package/fixtures/cases/default-unfilled/schema.yaml +10 -11
  164. package/fixtures/cases/defs-pattern/expected.json +2 -1
  165. package/fixtures/cases/defs-pattern/library/companies/acme.md +1 -1
  166. package/fixtures/cases/defs-pattern/library/deals/renewal.md +49 -24
  167. package/fixtures/cases/defs-pattern/schema.yaml +10 -11
  168. package/fixtures/cases/dependent-rule/library/companies/acme.md +1 -1
  169. package/fixtures/cases/dependent-rule/library/deals/renewal.md +48 -23
  170. package/fixtures/cases/dependent-rule/schema.yaml +10 -11
  171. package/fixtures/cases/duplicate-link-definition/library/item.md +1 -1
  172. package/fixtures/cases/duplicate-link-definition/schema.yaml +2 -3
  173. package/fixtures/cases/email-format/expected.json +2 -1
  174. package/fixtures/cases/email-format/library/companies/acme.md +1 -1
  175. package/fixtures/cases/email-format/library/deals/renewal.md +49 -24
  176. package/fixtures/cases/email-format/schema.yaml +10 -11
  177. package/fixtures/cases/equal-labels/expected.json +5 -0
  178. package/fixtures/cases/equal-labels/schema.yaml +4 -0
  179. package/fixtures/cases/fenced-link-definition/library/item.md +1 -1
  180. package/fixtures/cases/fenced-link-definition/schema.yaml +2 -3
  181. package/fixtures/cases/field-enum/expected.json +2 -1
  182. package/fixtures/cases/field-enum/library/item.md +2 -2
  183. package/fixtures/cases/field-enum/schema.yaml +3 -4
  184. package/fixtures/cases/frontmatter-construct/expected.json +7 -0
  185. package/fixtures/cases/frontmatter-construct/library/note.md +6 -0
  186. package/fixtures/cases/integer-field/expected.json +2 -1
  187. package/fixtures/cases/integer-field/library/companies/acme.md +1 -1
  188. package/fixtures/cases/integer-field/library/deals/renewal.md +49 -24
  189. package/fixtures/cases/integer-field/schema.yaml +10 -11
  190. package/fixtures/cases/json-schema-constructs/library/companies/acme.md +1 -1
  191. package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +49 -24
  192. package/fixtures/cases/json-schema-constructs/schema.yaml +10 -11
  193. package/fixtures/cases/labels-in-the-rooms-language/expected.json +1 -0
  194. package/fixtures/cases/labels-in-the-rooms-language/library/deals/atlas.md +7 -0
  195. package/fixtures/cases/labels-in-the-rooms-language/schema.yaml +9 -0
  196. package/fixtures/cases/lazy-list-item/expected.json +3 -0
  197. package/fixtures/cases/lazy-list-item/library/item.md +10 -0
  198. package/fixtures/cases/lazy-list-item/schema.yaml +3 -0
  199. package/fixtures/cases/link-into-a-reserved-name/context.json +1 -0
  200. package/fixtures/cases/link-into-a-reserved-name/expected.json +5 -0
  201. package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +6 -0
  202. package/fixtures/cases/link-into-a-reserved-name/schema.yaml +3 -0
  203. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/expected.json +5 -0
  204. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/library/notes/b.md +5 -0
  205. package/fixtures/cases/list-item-enum/context.json +1 -0
  206. package/fixtures/cases/list-item-enum/expected.json +7 -0
  207. package/fixtures/cases/list-item-enum/library/task.md +7 -0
  208. package/fixtures/cases/list-item-enum/schema.yaml +3 -0
  209. package/fixtures/cases/list-item-kind/context.json +1 -0
  210. package/fixtures/cases/list-item-kind/expected.json +7 -0
  211. package/fixtures/cases/list-item-kind/library/task.md +6 -0
  212. package/fixtures/cases/list-item-kind/schema.yaml +3 -0
  213. package/fixtures/cases/list-items/context.json +1 -0
  214. package/fixtures/cases/list-items/expected.json +1 -0
  215. package/fixtures/cases/list-items/library/page.md +26 -0
  216. package/fixtures/cases/list-items/schema.yaml +10 -0
  217. package/fixtures/cases/list-of-objects-closed/expected.json +2 -1
  218. package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +1 -1
  219. package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +49 -25
  220. package/fixtures/cases/list-of-objects-closed/schema.yaml +10 -11
  221. package/fixtures/cases/list-of-objects-item/expected.json +2 -1
  222. package/fixtures/cases/list-of-objects-item/library/companies/acme.md +1 -1
  223. package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +49 -24
  224. package/fixtures/cases/list-of-objects-item/schema.yaml +10 -11
  225. package/fixtures/cases/list-of-objects-reference/expected.json +2 -1
  226. package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +1 -1
  227. package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +12 -9
  228. package/fixtures/cases/list-of-objects-reference/library/places/depot.md +1 -1
  229. package/fixtures/cases/list-of-objects-reference/library/products/seats.md +1 -1
  230. package/fixtures/cases/list-of-objects-reference/library/products/support.md +1 -1
  231. package/fixtures/cases/list-reference-path/context.json +1 -0
  232. package/fixtures/cases/list-reference-path/expected.json +7 -0
  233. package/fixtures/cases/list-reference-path/library/page.md +5 -0
  234. package/fixtures/cases/list-reference-path/schema.yaml +3 -0
  235. package/fixtures/cases/list-reference-type/context.json +1 -0
  236. package/fixtures/cases/list-reference-type/expected.json +7 -0
  237. package/fixtures/cases/list-reference-type/library/page.md +6 -0
  238. package/fixtures/cases/list-reference-type/schema.yaml +3 -0
  239. package/fixtures/cases/list-size/expected.json +2 -1
  240. package/fixtures/cases/list-size/library/companies/acme.md +1 -1
  241. package/fixtures/cases/list-size/library/deals/renewal.md +51 -24
  242. package/fixtures/cases/list-size/schema.yaml +10 -11
  243. package/fixtures/cases/long-value-past-six-levels/context.json +1 -0
  244. package/fixtures/cases/long-value-past-six-levels/expected.json +5 -0
  245. package/fixtures/cases/long-value-past-six-levels/schema.yaml +15 -0
  246. package/fixtures/cases/malformed-list/context.json +1 -0
  247. package/fixtures/cases/malformed-list/expected.json +7 -0
  248. package/fixtures/cases/{structured-section → malformed-list}/library/item.md +1 -1
  249. package/fixtures/cases/malformed-list/schema.yaml +6 -0
  250. package/fixtures/cases/member-document/library/people/ana.md +2 -2
  251. package/fixtures/cases/member-on-an-untyped-document/context.json +1 -0
  252. package/fixtures/cases/member-on-an-untyped-document/expected.json +6 -0
  253. package/fixtures/cases/member-on-an-untyped-document/library/note.md +4 -0
  254. package/fixtures/cases/member-on-another-type/context.json +1 -0
  255. package/fixtures/cases/member-on-another-type/expected.json +6 -0
  256. package/fixtures/cases/member-on-another-type/library/note.md +4 -0
  257. package/fixtures/cases/member-on-another-type/schema.yaml +7 -0
  258. package/fixtures/cases/missing-required-field/library/item.md +1 -1
  259. package/fixtures/cases/missing-required-field/schema.yaml +3 -4
  260. package/fixtures/cases/misspelled-key/expected.json +2 -1
  261. package/fixtures/cases/misspelled-key/library/companies/acme.md +1 -1
  262. package/fixtures/cases/misspelled-key/library/deals/renewal.md +50 -25
  263. package/fixtures/cases/misspelled-key/schema.yaml +10 -11
  264. package/fixtures/cases/name-not-a-string/context.json +1 -0
  265. package/fixtures/cases/name-not-a-string/expected.json +5 -0
  266. package/fixtures/cases/name-not-a-string/schema.yaml +5 -0
  267. package/fixtures/cases/nested-defs/expected.json +2 -1
  268. package/fixtures/cases/nested-defs/library/deal.md +3 -3
  269. package/fixtures/cases/nested-object-reference/expected.json +2 -1
  270. package/fixtures/cases/nested-object-reference/library/companies/acme.md +1 -1
  271. package/fixtures/cases/nested-object-reference/library/deals/renewal.md +12 -9
  272. package/fixtures/cases/nested-object-reference/library/places/depot.md +1 -1
  273. package/fixtures/cases/nested-object-reference/library/products/seats.md +1 -1
  274. package/fixtures/cases/nested-object-reference/library/products/support.md +1 -1
  275. package/fixtures/cases/nested-reference/library/companies/acme.md +1 -1
  276. package/fixtures/cases/nested-reference/library/deals/renewal.md +13 -10
  277. package/fixtures/cases/nested-reference/library/places/depot.md +1 -1
  278. package/fixtures/cases/nested-reference/library/products/seats.md +1 -1
  279. package/fixtures/cases/nested-reference/library/products/support.md +1 -1
  280. package/fixtures/cases/nested-required-field/expected.json +2 -1
  281. package/fixtures/cases/nested-required-field/library/companies/acme.md +1 -1
  282. package/fixtures/cases/nested-required-field/library/deals/renewal.md +48 -23
  283. package/fixtures/cases/nested-required-field/schema.yaml +10 -11
  284. package/fixtures/cases/numeric-range/expected.json +2 -1
  285. package/fixtures/cases/numeric-range/library/companies/acme.md +1 -1
  286. package/fixtures/cases/numeric-range/library/deals/renewal.md +49 -24
  287. package/fixtures/cases/numeric-range/schema.yaml +10 -11
  288. package/fixtures/cases/one-key-two-labels/context.json +1 -0
  289. package/fixtures/cases/one-key-two-labels/expected.json +5 -0
  290. package/fixtures/cases/one-key-two-labels/schema.yaml +5 -0
  291. package/fixtures/cases/one-key-two-types/context.json +1 -0
  292. package/fixtures/cases/one-key-two-types/expected.json +5 -0
  293. package/fixtures/cases/one-key-two-types/schema.yaml +4 -0
  294. package/fixtures/cases/one-of-variant/expected.json +2 -1
  295. package/fixtures/cases/one-of-variant/library/companies/acme.md +1 -1
  296. package/fixtures/cases/one-of-variant/library/deals/renewal.md +49 -24
  297. package/fixtures/cases/one-of-variant/schema.yaml +10 -11
  298. package/fixtures/cases/other-room-reference/expected.json +2 -1
  299. package/fixtures/cases/other-room-reference/library/companies/acme.md +1 -1
  300. package/fixtures/cases/other-room-reference/library/deals/renewal.md +12 -9
  301. package/fixtures/cases/other-room-reference/library/places/depot.md +1 -1
  302. package/fixtures/cases/other-room-reference/library/products/seats.md +1 -1
  303. package/fixtures/cases/other-room-reference/library/products/support.md +1 -1
  304. package/fixtures/cases/prototype-field/expected.json +2 -1
  305. package/fixtures/cases/prototype-field/library/item.md +2 -2
  306. package/fixtures/cases/prototype-field/schema.yaml +2 -3
  307. package/fixtures/cases/reference-into-a-reserved-name/context.json +1 -0
  308. package/fixtures/cases/reference-into-a-reserved-name/expected.json +7 -0
  309. package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +4 -0
  310. package/fixtures/cases/reference-into-a-reserved-name/library/settings/brief.md +1 -0
  311. package/fixtures/cases/reference-into-a-reserved-name/schema.yaml +3 -0
  312. package/fixtures/cases/reference-to-any-file-name/context.json +1 -0
  313. package/fixtures/cases/reference-to-any-file-name/expected.json +1 -0
  314. package/fixtures/cases/reference-to-any-file-name/library/people/100%.md +4 -0
  315. package/fixtures/cases/reference-to-any-file-name/library/people/C#.md +4 -0
  316. package/fixtures/cases/reference-to-any-file-name/library/people/My notes.md +4 -0
  317. package/fixtures/cases/reference-to-any-file-name/library/people/[draft].md +4 -0
  318. package/fixtures/cases/reference-to-any-file-name/library/people/c (d).md +4 -0
  319. package/fixtures/cases/reference-to-any-file-name/library/people/caf/303/251.md +4 -0
  320. package/fixtures/cases/reference-to-any-file-name/library/people//320/236/321/202/321/207/321/221/321/202.md +4 -0
  321. package/fixtures/cases/reference-to-any-file-name/library/tasks/bracket.md +9 -0
  322. package/fixtures/cases/reference-to-any-file-name/library/tasks/cyrillic.md +9 -0
  323. package/fixtures/cases/reference-to-any-file-name/library/tasks/decomposed.md +9 -0
  324. package/fixtures/cases/reference-to-any-file-name/library/tasks/hash.md +9 -0
  325. package/fixtures/cases/reference-to-any-file-name/library/tasks/parenthesis.md +9 -0
  326. package/fixtures/cases/reference-to-any-file-name/library/tasks/percent.md +9 -0
  327. package/fixtures/cases/reference-to-any-file-name/library/tasks/spaced.md +9 -0
  328. package/fixtures/cases/reference-to-any-file-name/schema.yaml +10 -0
  329. package/fixtures/cases/referenced-missing-file/library/a.md +2 -2
  330. package/fixtures/cases/referenced-missing-file/library/b.md +2 -2
  331. package/fixtures/cases/referenced-missing-file/schema.yaml +3 -4
  332. package/fixtures/cases/referenced-missing-non-latin-file/context.json +1 -0
  333. package/fixtures/cases/referenced-missing-non-latin-file/expected.json +6 -0
  334. package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/a.md +9 -0
  335. package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/b.md +9 -0
  336. package/fixtures/cases/referenced-missing-non-latin-file/schema.yaml +10 -0
  337. package/fixtures/cases/room-md-declares-a-type/context.json +1 -0
  338. package/fixtures/cases/room-md-declares-a-type/expected.json +6 -0
  339. package/fixtures/cases/room-md-declares-a-type/library/ROOM.md +5 -0
  340. package/fixtures/cases/sections-keyword-refused/context.json +1 -0
  341. package/fixtures/cases/sections-keyword-refused/expected.json +5 -0
  342. package/fixtures/cases/{structured-section → sections-keyword-refused}/schema.yaml +1 -2
  343. package/fixtures/cases/shortcut-reference-link/library/item.md +1 -1
  344. package/fixtures/cases/shortcut-reference-link/schema.yaml +2 -3
  345. package/fixtures/cases/string-length/expected.json +2 -1
  346. package/fixtures/cases/string-length/library/companies/acme.md +1 -1
  347. package/fixtures/cases/string-length/library/deals/renewal.md +49 -24
  348. package/fixtures/cases/string-length/schema.yaml +10 -11
  349. package/fixtures/cases/submission-keys/library/notes/visitor.md +2 -2
  350. package/fixtures/cases/text-field-kind/expected.json +1 -4
  351. package/fixtures/cases/text-field-kind/library/page.md +1 -1
  352. package/fixtures/cases/thematic-break-ends-the-values/context.json +1 -0
  353. package/fixtures/cases/thematic-break-ends-the-values/expected.json +1 -0
  354. package/fixtures/cases/thematic-break-ends-the-values/library/item.md +10 -0
  355. package/fixtures/cases/thematic-break-ends-the-values/schema.yaml +3 -0
  356. package/fixtures/cases/typed-path-names-another-type/context.json +11 -0
  357. package/fixtures/cases/typed-path-names-another-type/expected.json +6 -0
  358. package/fixtures/cases/typed-path-names-another-type/library/settings/prefs/one.md +3 -0
  359. package/fixtures/cases/typed-path-names-another-type/schema.yaml +6 -0
  360. package/fixtures/cases/typed-path-names-its-type/context.json +11 -0
  361. package/fixtures/cases/typed-path-names-its-type/expected.json +3 -0
  362. package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/deeper/two.md +1 -0
  363. package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +4 -0
  364. package/fixtures/cases/typed-path-names-its-type/schema.yaml +6 -0
  365. package/fixtures/cases/typed-path-names-no-type/context.json +11 -0
  366. package/fixtures/cases/typed-path-names-no-type/expected.json +6 -0
  367. package/fixtures/cases/typed-path-names-no-type/library/settings/prefs/one.md +1 -0
  368. package/fixtures/cases/typed-path-names-no-type/schema.yaml +6 -0
  369. package/fixtures/cases/types-folder-content/library/types/task.md +1 -1
  370. package/fixtures/cases/undeclared-field/expected.json +2 -1
  371. package/fixtures/cases/undeclared-field/library/item.md +2 -2
  372. package/fixtures/cases/undeclared-field/schema.yaml +2 -3
  373. package/fixtures/cases/unevaluated-items-closed/expected.json +2 -1
  374. package/fixtures/cases/unevaluated-items-closed/library/trip.md +13 -3
  375. package/fixtures/cases/unnamed-typed-path-checks-its-fields/context.json +11 -0
  376. package/fixtures/cases/unnamed-typed-path-checks-its-fields/expected.json +6 -0
  377. package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +5 -0
  378. package/fixtures/cases/unnamed-typed-path-checks-its-fields/schema.yaml +5 -0
  379. package/fixtures/cases/unnamed-typed-path-names-a-type/context.json +11 -0
  380. package/fixtures/cases/unnamed-typed-path-names-a-type/expected.json +6 -0
  381. package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +7 -0
  382. package/fixtures/cases/unnamed-typed-path-names-a-type/schema.yaml +5 -0
  383. package/fixtures/cases/unnamed-typed-path-reads-its-type/context.json +11 -0
  384. package/fixtures/cases/unnamed-typed-path-reads-its-type/expected.json +3 -0
  385. package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/plan.md +1 -0
  386. package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +6 -0
  387. package/fixtures/cases/unnamed-typed-path-reads-its-type/schema.yaml +5 -0
  388. package/fixtures/cases/unnamed-typed-path-without-a-body/context.json +11 -0
  389. package/fixtures/cases/unnamed-typed-path-without-a-body/expected.json +5 -0
  390. package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +5 -0
  391. package/fixtures/cases/unnamed-typed-path-without-a-body/schema.yaml +5 -0
  392. package/fixtures/cases/unresolved-link/library/item.md +1 -1
  393. package/fixtures/cases/unresolved-link/schema.yaml +2 -3
  394. package/fixtures/cases/valid-typed-document/library/people/ada.md +1 -1
  395. package/fixtures/cases/valid-typed-document/library/tasks/one.md +11 -11
  396. package/fixtures/cases/valid-typed-document/schema.yaml +5 -6
  397. package/fixtures/forms.json +371 -0
  398. package/fixtures/preamble.json +29 -8
  399. package/fixtures/queries.json +1562 -0
  400. package/package.json +16 -2
  401. package/dist/blocks.d.ts +0 -11
  402. package/dist/blocks.d.ts.map +0 -1
  403. package/dist/blocks.js +0 -69
  404. package/dist/condition.d.ts +0 -149
  405. package/dist/condition.d.ts.map +0 -1
  406. package/dist/condition.js +0 -500
  407. package/dist/divide.d.ts +0 -3
  408. package/dist/divide.d.ts.map +0 -1
  409. package/dist/divide.js +0 -320
  410. package/dist/links.d.ts +0 -28
  411. package/dist/links.d.ts.map +0 -1
  412. package/dist/links.js +0 -785
  413. package/dist/profile.d.ts +0 -6
  414. package/dist/profile.d.ts.map +0 -1
  415. package/dist/profile.js +0 -5
  416. package/dist/project.d.ts +0 -22
  417. package/dist/project.d.ts.map +0 -1
  418. package/dist/project.js +0 -128
  419. package/dist/sections.d.ts +0 -11
  420. package/dist/sections.d.ts.map +0 -1
  421. package/dist/sections.js +0 -57
  422. package/fixtures/cases/missing-section-item-kind/expected.json +0 -5
  423. package/fixtures/cases/missing-section-item-kind/schema.yaml +0 -6
  424. package/fixtures/cases/null-refused/expected.json +0 -6
  425. package/fixtures/cases/null-refused/library/companies/acme.md +0 -4
  426. package/fixtures/cases/null-refused/library/deals/renewal.md +0 -31
  427. package/fixtures/cases/null-refused/schema.yaml +0 -56
  428. package/fixtures/cases/open-map-value/expected.json +0 -6
  429. package/fixtures/cases/open-map-value/library/companies/acme.md +0 -4
  430. package/fixtures/cases/open-map-value/library/deals/renewal.md +0 -31
  431. package/fixtures/cases/open-map-value/schema.yaml +0 -56
  432. package/fixtures/cases/section-item-enum/expected.json +0 -6
  433. package/fixtures/cases/section-item-enum/library/task.md +0 -8
  434. package/fixtures/cases/section-item-enum/schema.yaml +0 -3
  435. package/fixtures/cases/section-item-kind/expected.json +0 -6
  436. package/fixtures/cases/section-item-kind/library/task.md +0 -8
  437. package/fixtures/cases/section-item-kind/schema.yaml +0 -3
  438. package/fixtures/cases/section-items/library/page.md +0 -42
  439. package/fixtures/cases/section-items/schema.yaml +0 -10
  440. package/fixtures/cases/section-reference-path/expected.json +0 -6
  441. package/fixtures/cases/section-reference-path/library/page.md +0 -7
  442. package/fixtures/cases/section-reference-path/schema.yaml +0 -3
  443. package/fixtures/cases/section-reference-type/expected.json +0 -6
  444. package/fixtures/cases/section-reference-type/library/page.md +0 -7
  445. package/fixtures/cases/section-reference-type/schema.yaml +0 -3
  446. package/fixtures/cases/structured-section/expected.json +0 -6
  447. package/fixtures/division.json +0 -409
  448. package/fixtures/projection.json +0 -255
  449. /package/fixtures/cases/{missing-section-item-kind → block-scalar-frontmatter}/context.json +0 -0
  450. /package/fixtures/cases/{section-items → block-scalar-frontmatter}/expected.json +0 -0
  451. /package/fixtures/cases/{null-refused → conditional-long-text}/context.json +0 -0
  452. /package/fixtures/cases/{open-map-value → cross-room-link}/context.json +0 -0
  453. /package/fixtures/cases/{section-item-enum → cross-room-reference}/context.json +0 -0
  454. /package/fixtures/cases/{section-item-kind → equal-labels}/context.json +0 -0
  455. /package/fixtures/cases/{section-items → frontmatter-construct}/context.json +0 -0
  456. /package/fixtures/cases/{section-reference-path → labels-in-the-rooms-language}/context.json +0 -0
  457. /package/fixtures/cases/{section-reference-type → lazy-list-item}/context.json +0 -0
  458. /package/fixtures/cases/{structured-section → link-into-a-reserved-name-from-an-untyped-document}/context.json +0 -0
  459. /package/fixtures/cases/{section-items → list-items}/library/other.md +0 -0
  460. /package/fixtures/cases/{section-reference-path → list-reference-path}/library/other.md +0 -0
  461. /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
- }