@alisio/plugin-thesis 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (547) hide show
  1. package/.agents/agents/thesis-architect.md +38 -0
  2. package/.agents/agents/thesis-coordinator.md +39 -0
  3. package/.agents/agents/thesis-editor.md +35 -0
  4. package/.agents/agents/thesis-evidence-auditor.md +37 -0
  5. package/.agents/agents/thesis-librarian.md +38 -0
  6. package/.agents/agents/thesis-methodologist.md +39 -0
  7. package/.agents/agents/thesis-reviewer.md +36 -0
  8. package/.agents/agents/thesis-writer.md +38 -0
  9. package/.agents/skills/thesis-build/SKILL.md +48 -0
  10. package/.agents/skills/thesis-citations/SKILL.md +49 -0
  11. package/.agents/skills/thesis-csl-authoring/SKILL.md +48 -0
  12. package/.agents/skills/thesis-editing/SKILL.md +49 -0
  13. package/.agents/skills/thesis-evidence/SKILL.md +48 -0
  14. package/.agents/skills/thesis-figures/SKILL.md +50 -0
  15. package/.agents/skills/thesis-institution-norms/SKILL.md +50 -0
  16. package/.agents/skills/thesis-intake/SKILL.md +48 -0
  17. package/.agents/skills/thesis-math/SKILL.md +48 -0
  18. package/.agents/skills/thesis-methodology/SKILL.md +49 -0
  19. package/.agents/skills/thesis-outline/SKILL.md +48 -0
  20. package/.agents/skills/thesis-policy/SKILL.md +48 -0
  21. package/.agents/skills/thesis-review/SKILL.md +49 -0
  22. package/.agents/skills/thesis-search/SKILL.md +47 -0
  23. package/.agents/skills/thesis-writing/SKILL.md +52 -0
  24. package/LICENSE +21 -0
  25. package/README.es.md +242 -0
  26. package/README.md +235 -0
  27. package/THIRD_PARTY_NOTICES.md +94 -0
  28. package/assets/architecture.svg +1 -0
  29. package/assets/evidence-pipeline.svg +1 -0
  30. package/assets/lifecycle.svg +1 -0
  31. package/assets/policy-resolution.svg +1 -0
  32. package/cover.webp +0 -0
  33. package/dist/authoring.d.ts +30 -0
  34. package/dist/authoring.d.ts.map +1 -0
  35. package/dist/authoring.js +681 -0
  36. package/dist/authoring.js.map +1 -0
  37. package/dist/brief.d.ts +40 -0
  38. package/dist/brief.d.ts.map +1 -0
  39. package/dist/brief.js +566 -0
  40. package/dist/brief.js.map +1 -0
  41. package/dist/cache.d.ts +8 -0
  42. package/dist/cache.d.ts.map +1 -0
  43. package/dist/cache.js +20 -0
  44. package/dist/cache.js.map +1 -0
  45. package/dist/checks/brief.d.ts +5 -0
  46. package/dist/checks/brief.d.ts.map +1 -0
  47. package/dist/checks/brief.js +38 -0
  48. package/dist/checks/brief.js.map +1 -0
  49. package/dist/checks/citations.d.ts +14 -0
  50. package/dist/checks/citations.d.ts.map +1 -0
  51. package/dist/checks/citations.js +87 -0
  52. package/dist/checks/citations.js.map +1 -0
  53. package/dist/checks/claims.d.ts +16 -0
  54. package/dist/checks/claims.d.ts.map +1 -0
  55. package/dist/checks/claims.js +147 -0
  56. package/dist/checks/claims.js.map +1 -0
  57. package/dist/checks/closing.d.ts +20 -0
  58. package/dist/checks/closing.d.ts.map +1 -0
  59. package/dist/checks/closing.js +168 -0
  60. package/dist/checks/closing.js.map +1 -0
  61. package/dist/checks/design.d.ts +5 -0
  62. package/dist/checks/design.d.ts.map +1 -0
  63. package/dist/checks/design.js +107 -0
  64. package/dist/checks/design.js.map +1 -0
  65. package/dist/checks/document.d.ts +17 -0
  66. package/dist/checks/document.d.ts.map +1 -0
  67. package/dist/checks/document.js +213 -0
  68. package/dist/checks/document.js.map +1 -0
  69. package/dist/checks/evidence.d.ts +7 -0
  70. package/dist/checks/evidence.d.ts.map +1 -0
  71. package/dist/checks/evidence.js +133 -0
  72. package/dist/checks/evidence.js.map +1 -0
  73. package/dist/checks/hygiene.d.ts +5 -0
  74. package/dist/checks/hygiene.d.ts.map +1 -0
  75. package/dist/checks/hygiene.js +37 -0
  76. package/dist/checks/hygiene.js.map +1 -0
  77. package/dist/checks/index.d.ts +21 -0
  78. package/dist/checks/index.d.ts.map +1 -0
  79. package/dist/checks/index.js +98 -0
  80. package/dist/checks/index.js.map +1 -0
  81. package/dist/checks/language.d.ts +14 -0
  82. package/dist/checks/language.d.ts.map +1 -0
  83. package/dist/checks/language.js +73 -0
  84. package/dist/checks/language.js.map +1 -0
  85. package/dist/checks/outline.d.ts +25 -0
  86. package/dist/checks/outline.d.ts.map +1 -0
  87. package/dist/checks/outline.js +214 -0
  88. package/dist/checks/outline.js.map +1 -0
  89. package/dist/checks/policy.d.ts +5 -0
  90. package/dist/checks/policy.d.ts.map +1 -0
  91. package/dist/checks/policy.js +129 -0
  92. package/dist/checks/policy.js.map +1 -0
  93. package/dist/checks/project.d.ts +65 -0
  94. package/dist/checks/project.d.ts.map +1 -0
  95. package/dist/checks/project.js +203 -0
  96. package/dist/checks/project.js.map +1 -0
  97. package/dist/checks/styles.d.ts +12 -0
  98. package/dist/checks/styles.d.ts.map +1 -0
  99. package/dist/checks/styles.js +67 -0
  100. package/dist/checks/styles.js.map +1 -0
  101. package/dist/checks/writing.d.ts +6 -0
  102. package/dist/checks/writing.d.ts.map +1 -0
  103. package/dist/checks/writing.js +115 -0
  104. package/dist/checks/writing.js.map +1 -0
  105. package/dist/chrome/detect.d.ts +19 -0
  106. package/dist/chrome/detect.d.ts.map +1 -0
  107. package/dist/chrome/detect.js +116 -0
  108. package/dist/chrome/detect.js.map +1 -0
  109. package/dist/claims.d.ts +19 -0
  110. package/dist/claims.d.ts.map +1 -0
  111. package/dist/claims.js +99 -0
  112. package/dist/claims.js.map +1 -0
  113. package/dist/cli.d.ts +11 -0
  114. package/dist/cli.d.ts.map +1 -0
  115. package/dist/cli.js +262 -0
  116. package/dist/cli.js.map +1 -0
  117. package/dist/context.d.ts +55 -0
  118. package/dist/context.d.ts.map +1 -0
  119. package/dist/context.js +62 -0
  120. package/dist/context.js.map +1 -0
  121. package/dist/coordinator.d.ts +139 -0
  122. package/dist/coordinator.d.ts.map +1 -0
  123. package/dist/coordinator.js +710 -0
  124. package/dist/coordinator.js.map +1 -0
  125. package/dist/delegate.d.ts +34 -0
  126. package/dist/delegate.d.ts.map +1 -0
  127. package/dist/delegate.js +105 -0
  128. package/dist/delegate.js.map +1 -0
  129. package/dist/diffguard.d.ts +24 -0
  130. package/dist/diffguard.d.ts.map +1 -0
  131. package/dist/diffguard.js +92 -0
  132. package/dist/diffguard.js.map +1 -0
  133. package/dist/doctor.d.ts +34 -0
  134. package/dist/doctor.d.ts.map +1 -0
  135. package/dist/doctor.js +155 -0
  136. package/dist/doctor.js.map +1 -0
  137. package/dist/draft.d.ts +64 -0
  138. package/dist/draft.d.ts.map +1 -0
  139. package/dist/draft.js +801 -0
  140. package/dist/draft.js.map +1 -0
  141. package/dist/figure.d.ts +13 -0
  142. package/dist/figure.d.ts.map +1 -0
  143. package/dist/figure.js +143 -0
  144. package/dist/figure.js.map +1 -0
  145. package/dist/finalize.d.ts +29 -0
  146. package/dist/finalize.d.ts.map +1 -0
  147. package/dist/finalize.js +230 -0
  148. package/dist/finalize.js.map +1 -0
  149. package/dist/index.d.ts +33 -0
  150. package/dist/index.d.ts.map +1 -0
  151. package/dist/index.js +206 -0
  152. package/dist/index.js.map +1 -0
  153. package/dist/intake.d.ts +57 -0
  154. package/dist/intake.d.ts.map +1 -0
  155. package/dist/intake.js +772 -0
  156. package/dist/intake.js.map +1 -0
  157. package/dist/labels.d.ts +50 -0
  158. package/dist/labels.d.ts.map +1 -0
  159. package/dist/labels.js +98 -0
  160. package/dist/labels.js.map +1 -0
  161. package/dist/outline.d.ts +45 -0
  162. package/dist/outline.d.ts.map +1 -0
  163. package/dist/outline.js +148 -0
  164. package/dist/outline.js.map +1 -0
  165. package/dist/pack-commands.d.ts +18 -0
  166. package/dist/pack-commands.d.ts.map +1 -0
  167. package/dist/pack-commands.js +397 -0
  168. package/dist/pack-commands.js.map +1 -0
  169. package/dist/package-paths.d.ts +8 -0
  170. package/dist/package-paths.d.ts.map +1 -0
  171. package/dist/package-paths.js +13 -0
  172. package/dist/package-paths.js.map +1 -0
  173. package/dist/policy/context.d.ts +19 -0
  174. package/dist/policy/context.d.ts.map +1 -0
  175. package/dist/policy/context.js +62 -0
  176. package/dist/policy/context.js.map +1 -0
  177. package/dist/policy/ethics.d.ts +59 -0
  178. package/dist/policy/ethics.d.ts.map +1 -0
  179. package/dist/policy/ethics.js +106 -0
  180. package/dist/policy/ethics.js.map +1 -0
  181. package/dist/policy/kinds.d.ts +9 -0
  182. package/dist/policy/kinds.d.ts.map +1 -0
  183. package/dist/policy/kinds.js +68 -0
  184. package/dist/policy/kinds.js.map +1 -0
  185. package/dist/policy/packs.d.ts +53 -0
  186. package/dist/policy/packs.d.ts.map +1 -0
  187. package/dist/policy/packs.js +336 -0
  188. package/dist/policy/packs.js.map +1 -0
  189. package/dist/policy/resolver.d.ts +87 -0
  190. package/dist/policy/resolver.d.ts.map +1 -0
  191. package/dist/policy/resolver.js +337 -0
  192. package/dist/policy/resolver.js.map +1 -0
  193. package/dist/policy/rules.d.ts +65 -0
  194. package/dist/policy/rules.d.ts.map +1 -0
  195. package/dist/policy/rules.js +194 -0
  196. package/dist/policy/rules.js.map +1 -0
  197. package/dist/protocol.d.ts +46 -0
  198. package/dist/protocol.d.ts.map +1 -0
  199. package/dist/protocol.js +86 -0
  200. package/dist/protocol.js.map +1 -0
  201. package/dist/render/adapters/chrome-pdf/cdp.d.ts +36 -0
  202. package/dist/render/adapters/chrome-pdf/cdp.d.ts.map +1 -0
  203. package/dist/render/adapters/chrome-pdf/cdp.js +291 -0
  204. package/dist/render/adapters/chrome-pdf/cdp.js.map +1 -0
  205. package/dist/render/adapters/chrome-pdf/index.d.ts +10 -0
  206. package/dist/render/adapters/chrome-pdf/index.d.ts.map +1 -0
  207. package/dist/render/adapters/chrome-pdf/index.js +139 -0
  208. package/dist/render/adapters/chrome-pdf/index.js.map +1 -0
  209. package/dist/render/adapters/chrome-pdf/network.d.ts +7 -0
  210. package/dist/render/adapters/chrome-pdf/network.d.ts.map +1 -0
  211. package/dist/render/adapters/chrome-pdf/network.js +33 -0
  212. package/dist/render/adapters/chrome-pdf/network.js.map +1 -0
  213. package/dist/render/adapters/html-preview/index.d.ts +8 -0
  214. package/dist/render/adapters/html-preview/index.d.ts.map +1 -0
  215. package/dist/render/adapters/html-preview/index.js +62 -0
  216. package/dist/render/adapters/html-preview/index.js.map +1 -0
  217. package/dist/render/adapters/test-json/index.d.ts +8 -0
  218. package/dist/render/adapters/test-json/index.d.ts.map +1 -0
  219. package/dist/render/adapters/test-json/index.js +62 -0
  220. package/dist/render/adapters/test-json/index.js.map +1 -0
  221. package/dist/render/adapters/typst-pdf/emitter.d.ts +21 -0
  222. package/dist/render/adapters/typst-pdf/emitter.d.ts.map +1 -0
  223. package/dist/render/adapters/typst-pdf/emitter.js +259 -0
  224. package/dist/render/adapters/typst-pdf/emitter.js.map +1 -0
  225. package/dist/render/adapters/typst-pdf/escape.d.ts +14 -0
  226. package/dist/render/adapters/typst-pdf/escape.d.ts.map +1 -0
  227. package/dist/render/adapters/typst-pdf/escape.js +56 -0
  228. package/dist/render/adapters/typst-pdf/escape.js.map +1 -0
  229. package/dist/render/adapters/typst-pdf/index.d.ts +9 -0
  230. package/dist/render/adapters/typst-pdf/index.d.ts.map +1 -0
  231. package/dist/render/adapters/typst-pdf/index.js +154 -0
  232. package/dist/render/adapters/typst-pdf/index.js.map +1 -0
  233. package/dist/render/adapters/typst-pdf/profile.d.ts +3 -0
  234. package/dist/render/adapters/typst-pdf/profile.d.ts.map +1 -0
  235. package/dist/render/adapters/typst-pdf/profile.js +55 -0
  236. package/dist/render/adapters/typst-pdf/profile.js.map +1 -0
  237. package/dist/render/adapters/typst-pdf/runner.d.ts +52 -0
  238. package/dist/render/adapters/typst-pdf/runner.d.ts.map +1 -0
  239. package/dist/render/adapters/typst-pdf/runner.js +209 -0
  240. package/dist/render/adapters/typst-pdf/runner.js.map +1 -0
  241. package/dist/render/adapters/typst-pdf/setup.d.ts +30 -0
  242. package/dist/render/adapters/typst-pdf/setup.d.ts.map +1 -0
  243. package/dist/render/adapters/typst-pdf/setup.js +183 -0
  244. package/dist/render/adapters/typst-pdf/setup.js.map +1 -0
  245. package/dist/render/adapters/typst-pdf/version.d.ts +8 -0
  246. package/dist/render/adapters/typst-pdf/version.d.ts.map +1 -0
  247. package/dist/render/adapters/typst-pdf/version.js +14 -0
  248. package/dist/render/adapters/typst-pdf/version.js.map +1 -0
  249. package/dist/render/assemble.d.ts +28 -0
  250. package/dist/render/assemble.d.ts.map +1 -0
  251. package/dist/render/assemble.js +309 -0
  252. package/dist/render/assemble.js.map +1 -0
  253. package/dist/render/assets.d.ts +27 -0
  254. package/dist/render/assets.d.ts.map +1 -0
  255. package/dist/render/assets.js +232 -0
  256. package/dist/render/assets.js.map +1 -0
  257. package/dist/render/build.d.ts +43 -0
  258. package/dist/render/build.d.ts.map +1 -0
  259. package/dist/render/build.js +187 -0
  260. package/dist/render/build.js.map +1 -0
  261. package/dist/render/charts.d.ts +83 -0
  262. package/dist/render/charts.d.ts.map +1 -0
  263. package/dist/render/charts.js +633 -0
  264. package/dist/render/charts.js.map +1 -0
  265. package/dist/render/default-registry.d.ts +7 -0
  266. package/dist/render/default-registry.d.ts.map +1 -0
  267. package/dist/render/default-registry.js +15 -0
  268. package/dist/render/default-registry.js.map +1 -0
  269. package/dist/render/diagram-theme.d.ts +7 -0
  270. package/dist/render/diagram-theme.d.ts.map +1 -0
  271. package/dist/render/diagram-theme.js +50 -0
  272. package/dist/render/diagram-theme.js.map +1 -0
  273. package/dist/render/dialect.d.ts +23 -0
  274. package/dist/render/dialect.d.ts.map +1 -0
  275. package/dist/render/dialect.js +188 -0
  276. package/dist/render/dialect.js.map +1 -0
  277. package/dist/render/html/citations.d.ts +70 -0
  278. package/dist/render/html/citations.d.ts.map +1 -0
  279. package/dist/render/html/citations.js +371 -0
  280. package/dist/render/html/citations.js.map +1 -0
  281. package/dist/render/html/css.d.ts +14 -0
  282. package/dist/render/html/css.d.ts.map +1 -0
  283. package/dist/render/html/css.js +113 -0
  284. package/dist/render/html/css.js.map +1 -0
  285. package/dist/render/html/emitter.d.ts +20 -0
  286. package/dist/render/html/emitter.d.ts.map +1 -0
  287. package/dist/render/html/emitter.js +652 -0
  288. package/dist/render/html/emitter.js.map +1 -0
  289. package/dist/render/html/escape.d.ts +11 -0
  290. package/dist/render/html/escape.d.ts.map +1 -0
  291. package/dist/render/html/escape.js +32 -0
  292. package/dist/render/html/escape.js.map +1 -0
  293. package/dist/render/html/katex.d.ts +9 -0
  294. package/dist/render/html/katex.d.ts.map +1 -0
  295. package/dist/render/html/katex.js +39 -0
  296. package/dist/render/html/katex.js.map +1 -0
  297. package/dist/render/html/stage.d.ts +12 -0
  298. package/dist/render/html/stage.d.ts.map +1 -0
  299. package/dist/render/html/stage.js +30 -0
  300. package/dist/render/html/stage.js.map +1 -0
  301. package/dist/render/index.d.ts +5 -0
  302. package/dist/render/index.d.ts.map +1 -0
  303. package/dist/render/index.js +5 -0
  304. package/dist/render/index.js.map +1 -0
  305. package/dist/render/math.d.ts +9 -0
  306. package/dist/render/math.d.ts.map +1 -0
  307. package/dist/render/math.js +60 -0
  308. package/dist/render/math.js.map +1 -0
  309. package/dist/render/model.d.ts +233 -0
  310. package/dist/render/model.d.ts.map +1 -0
  311. package/dist/render/model.js +2 -0
  312. package/dist/render/model.js.map +1 -0
  313. package/dist/render/numbering.d.ts +51 -0
  314. package/dist/render/numbering.d.ts.map +1 -0
  315. package/dist/render/numbering.js +155 -0
  316. package/dist/render/numbering.js.map +1 -0
  317. package/dist/render/output-name.d.ts +4 -0
  318. package/dist/render/output-name.d.ts.map +1 -0
  319. package/dist/render/output-name.js +11 -0
  320. package/dist/render/output-name.js.map +1 -0
  321. package/dist/render/palettes.d.ts +22 -0
  322. package/dist/render/palettes.d.ts.map +1 -0
  323. package/dist/render/palettes.js +46 -0
  324. package/dist/render/palettes.js.map +1 -0
  325. package/dist/render/parse.d.ts +15 -0
  326. package/dist/render/parse.d.ts.map +1 -0
  327. package/dist/render/parse.js +637 -0
  328. package/dist/render/parse.js.map +1 -0
  329. package/dist/render/port.d.ts +79 -0
  330. package/dist/render/port.d.ts.map +1 -0
  331. package/dist/render/port.js +2 -0
  332. package/dist/render/port.js.map +1 -0
  333. package/dist/render/registry.d.ts +11 -0
  334. package/dist/render/registry.d.ts.map +1 -0
  335. package/dist/render/registry.js +21 -0
  336. package/dist/render/registry.js.map +1 -0
  337. package/dist/render/text.d.ts +13 -0
  338. package/dist/render/text.d.ts.map +1 -0
  339. package/dist/render/text.js +65 -0
  340. package/dist/render/text.js.map +1 -0
  341. package/dist/render/walk.d.ts +13 -0
  342. package/dist/render/walk.d.ts.map +1 -0
  343. package/dist/render/walk.js +69 -0
  344. package/dist/render/walk.js.map +1 -0
  345. package/dist/research/bibtex.d.ts +12 -0
  346. package/dist/research/bibtex.d.ts.map +1 -0
  347. package/dist/research/bibtex.js +99 -0
  348. package/dist/research/bibtex.js.map +1 -0
  349. package/dist/research/client.d.ts +112 -0
  350. package/dist/research/client.d.ts.map +1 -0
  351. package/dist/research/client.js +661 -0
  352. package/dist/research/client.js.map +1 -0
  353. package/dist/research/dossier.d.ts +31 -0
  354. package/dist/research/dossier.d.ts.map +1 -0
  355. package/dist/research/dossier.js +54 -0
  356. package/dist/research/dossier.js.map +1 -0
  357. package/dist/research/flow.d.ts +31 -0
  358. package/dist/research/flow.d.ts.map +1 -0
  359. package/dist/research/flow.js +635 -0
  360. package/dist/research/flow.js.map +1 -0
  361. package/dist/research/library.d.ts +79 -0
  362. package/dist/research/library.d.ts.map +1 -0
  363. package/dist/research/library.js +319 -0
  364. package/dist/research/library.js.map +1 -0
  365. package/dist/research/verify.d.ts +80 -0
  366. package/dist/research/verify.d.ts.map +1 -0
  367. package/dist/research/verify.js +307 -0
  368. package/dist/research/verify.js.map +1 -0
  369. package/dist/resources.d.ts +15 -0
  370. package/dist/resources.d.ts.map +1 -0
  371. package/dist/resources.js +148 -0
  372. package/dist/resources.js.map +1 -0
  373. package/dist/review.d.ts +22 -0
  374. package/dist/review.d.ts.map +1 -0
  375. package/dist/review.js +355 -0
  376. package/dist/review.js.map +1 -0
  377. package/dist/schemas.d.ts +252 -0
  378. package/dist/schemas.d.ts.map +1 -0
  379. package/dist/schemas.js +1020 -0
  380. package/dist/schemas.js.map +1 -0
  381. package/dist/sections.d.ts +30 -0
  382. package/dist/sections.d.ts.map +1 -0
  383. package/dist/sections.js +62 -0
  384. package/dist/sections.js.map +1 -0
  385. package/dist/storage.d.ts +21 -0
  386. package/dist/storage.d.ts.map +1 -0
  387. package/dist/storage.js +296 -0
  388. package/dist/storage.js.map +1 -0
  389. package/dist/style-commands.d.ts +15 -0
  390. package/dist/style-commands.d.ts.map +1 -0
  391. package/dist/style-commands.js +54 -0
  392. package/dist/style-commands.js.map +1 -0
  393. package/dist/styles/csl.d.ts +58 -0
  394. package/dist/styles/csl.d.ts.map +1 -0
  395. package/dist/styles/csl.js +112 -0
  396. package/dist/styles/csl.js.map +1 -0
  397. package/dist/styles/discovery.d.ts +45 -0
  398. package/dist/styles/discovery.d.ts.map +1 -0
  399. package/dist/styles/discovery.js +99 -0
  400. package/dist/styles/discovery.js.map +1 -0
  401. package/dist/styles/golden.d.ts +52 -0
  402. package/dist/styles/golden.d.ts.map +1 -0
  403. package/dist/styles/golden.js +216 -0
  404. package/dist/styles/golden.js.map +1 -0
  405. package/dist/styles/profile.d.ts +126 -0
  406. package/dist/styles/profile.d.ts.map +1 -0
  407. package/dist/styles/profile.js +582 -0
  408. package/dist/styles/profile.js.map +1 -0
  409. package/dist/styles/xml.d.ts +22 -0
  410. package/dist/styles/xml.d.ts.map +1 -0
  411. package/dist/styles/xml.js +179 -0
  412. package/dist/styles/xml.js.map +1 -0
  413. package/dist/types.d.ts +285 -0
  414. package/dist/types.d.ts.map +1 -0
  415. package/dist/types.js +155 -0
  416. package/dist/types.js.map +1 -0
  417. package/dist/typst-pins.d.ts +16 -0
  418. package/dist/typst-pins.d.ts.map +1 -0
  419. package/dist/typst-pins.js +39 -0
  420. package/dist/typst-pins.js.map +1 -0
  421. package/dist/version.d.ts +2 -0
  422. package/dist/version.d.ts.map +1 -0
  423. package/dist/version.js +3 -0
  424. package/dist/version.js.map +1 -0
  425. package/dist/workflow.d.ts +49 -0
  426. package/dist/workflow.d.ts.map +1 -0
  427. package/dist/workflow.js +722 -0
  428. package/dist/workflow.js.map +1 -0
  429. package/dist/workspace.d.ts +12 -0
  430. package/dist/workspace.d.ts.map +1 -0
  431. package/dist/workspace.js +71 -0
  432. package/dist/workspace.js.map +1 -0
  433. package/package.json +70 -0
  434. package/policy-packs/countries/CO/academic-standards/ntc-1486-2022.yaml +188 -0
  435. package/policy-packs/countries/CO/copyright/decision-andina-351.yaml +61 -0
  436. package/policy-packs/countries/CO/copyright/ley-1915-2018.yaml +25 -0
  437. package/policy-packs/countries/CO/copyright/ley-23-1982.yaml +64 -0
  438. package/policy-packs/countries/CO/domains/health/resolucion-8430-1993.yaml +219 -0
  439. package/policy-packs/countries/CO/higher-education/ley-30-1992.yaml +61 -0
  440. package/policy-packs/countries/CO/manifest.yaml +42 -0
  441. package/policy-packs/countries/CO/official-domains.yaml +90 -0
  442. package/policy-packs/countries/CO/privacy/ley-1581-2012.yaml +197 -0
  443. package/policy-packs/countries/CO/research-integrity/minciencias-res-0314-2018.yaml +64 -0
  444. package/policy-packs/global/academic-integrity.yaml +45 -0
  445. package/policy-packs/global/academic-writing.yaml +70 -0
  446. package/policy-packs/global/evidence-quality.yaml +81 -0
  447. package/policy-packs/global/manifest.yaml +54 -0
  448. package/policy-packs/global/objective-verbs.yaml +245 -0
  449. package/policy-packs/global/reporting-guidelines.yaml +392 -0
  450. package/policy-packs/global/work-types.yaml +195 -0
  451. package/styles/LICENSE-CSL +375 -0
  452. package/styles/apa.csl +2283 -0
  453. package/styles/catalog.json +43 -0
  454. package/styles/fixtures/apa-7.expected.json +25 -0
  455. package/styles/fixtures/icontec-ntc1486-2022.expected.json +25 -0
  456. package/styles/fixtures/ieee.expected.json +25 -0
  457. package/styles/fixtures/references.jsonl +8 -0
  458. package/styles/icontec-ntc1486-2022.csl +388 -0
  459. package/styles/ieee.csl +519 -0
  460. package/templates/html/runtime.js +159 -0
  461. package/templates/html/thesis.css +98 -0
  462. package/templates/html/vendor/katex/LICENSE +21 -0
  463. package/templates/html/vendor/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  464. package/templates/html/vendor/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  465. package/templates/html/vendor/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  466. package/templates/html/vendor/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  467. package/templates/html/vendor/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  468. package/templates/html/vendor/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
  469. package/templates/html/vendor/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  470. package/templates/html/vendor/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
  471. package/templates/html/vendor/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
  472. package/templates/html/vendor/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  473. package/templates/html/vendor/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
  474. package/templates/html/vendor/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  475. package/templates/html/vendor/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  476. package/templates/html/vendor/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  477. package/templates/html/vendor/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
  478. package/templates/html/vendor/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  479. package/templates/html/vendor/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  480. package/templates/html/vendor/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  481. package/templates/html/vendor/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  482. package/templates/html/vendor/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  483. package/templates/html/vendor/katex/katex.min.css +1 -0
  484. package/templates/html/vendor/katex/katex.min.js +1 -0
  485. package/templates/html/vendor/mermaid/LICENSE +21 -0
  486. package/templates/html/vendor/mermaid/mermaid.min.js +3587 -0
  487. package/templates/html/vendor/pagedjs/LICENSE +21 -0
  488. package/templates/html/vendor/pagedjs/paged.polyfill.min.js +4 -0
  489. package/templates/palettes.json +57 -0
  490. package/templates/profiles/apa-7.profile.yaml +15 -0
  491. package/templates/profiles/generic.profile.yaml +20 -0
  492. package/templates/profiles/icontec-ntc1486-2022.profile.yaml +36 -0
  493. package/templates/profiles/ieee.profile.yaml +14 -0
  494. package/templates/typst/i18n/en.yaml +31 -0
  495. package/templates/typst/i18n/es.yaml +31 -0
  496. package/templates/typst/i18n/pt.yaml +31 -0
  497. package/templates/typst/thesis.typ +276 -0
  498. package/typst-packages/preview/merman/0.3.0/LICENSE +231 -0
  499. package/typst-packages/preview/merman/0.3.0/README.md +388 -0
  500. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/cose-base-v1/LICENSE +21 -0
  501. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/cose-base-v2/LICENSE +21 -0
  502. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/cytoscape/LICENSE +19 -0
  503. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/cytoscape-cose-bilkent/LICENSE +21 -0
  504. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/cytoscape-fcose/LICENSE +19 -0
  505. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/d3-shape/LICENSE +13 -0
  506. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/dagre/LICENSE +19 -0
  507. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/dompurify/LICENSE +202 -0
  508. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/eclipse-elk/LICENSE.md +264 -0
  509. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/elkjs/LICENSE.md +264 -0
  510. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/fmin/LICENSE +27 -0
  511. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/graphlib/LICENSE +19 -0
  512. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/layout-base-v1/LICENSE +21 -0
  513. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/layout-base-v2/LICENSE +21 -0
  514. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/mermaid/LICENSE +21 -0
  515. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/rough-rs/LICENSE +21 -0
  516. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/roughjs/LICENSE +21 -0
  517. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/sanitize-url/LICENSE +21 -0
  518. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/venn-js/LICENSE +22 -0
  519. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/wasm-minimal-protocol/LICENSE +24 -0
  520. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_LICENSES/zenuml-core/LICENSE +21 -0
  521. package/typst-packages/preview/merman/0.3.0/THIRD_PARTY_NOTICES.md +265 -0
  522. package/typst-packages/preview/merman/0.3.0/lib.typ +1 -0
  523. package/typst-packages/preview/merman/0.3.0/merman_typst_plugin.wasm +0 -0
  524. package/typst-packages/preview/merman/0.3.0/src/capabilities.typ +5 -0
  525. package/typst-packages/preview/merman/0.3.0/src/context.typ +1 -0
  526. package/typst-packages/preview/merman/0.3.0/src/errors.typ +33 -0
  527. package/typst-packages/preview/merman/0.3.0/src/exports.typ +5 -0
  528. package/typst-packages/preview/merman/0.3.0/src/figure.typ +143 -0
  529. package/typst-packages/preview/merman/0.3.0/src/image.typ +50 -0
  530. package/typst-packages/preview/merman/0.3.0/src/options.typ +566 -0
  531. package/typst-packages/preview/merman/0.3.0/src/plugin.typ +1 -0
  532. package/typst-packages/preview/merman/0.3.0/src/raw.typ +22 -0
  533. package/typst-packages/preview/merman/0.3.0/src/render.typ +137 -0
  534. package/typst-packages/preview/merman/0.3.0/src/source.typ +7 -0
  535. package/typst-packages/preview/merman/0.3.0/src/units.typ +51 -0
  536. package/typst-packages/preview/merman/0.3.0/typst.toml +12 -0
  537. package/typst-packages/preview/mitex/0.2.7/CHANGELOG.md +69 -0
  538. package/typst-packages/preview/mitex/0.2.7/LICENSE +176 -0
  539. package/typst-packages/preview/mitex/0.2.7/README.md +154 -0
  540. package/typst-packages/preview/mitex/0.2.7/lib.typ +1 -0
  541. package/typst-packages/preview/mitex/0.2.7/mitex.typ +45 -0
  542. package/typst-packages/preview/mitex/0.2.7/mitex.wasm +0 -0
  543. package/typst-packages/preview/mitex/0.2.7/specs/README.md +250 -0
  544. package/typst-packages/preview/mitex/0.2.7/specs/latex/standard.typ +1187 -0
  545. package/typst-packages/preview/mitex/0.2.7/specs/mod.typ +12 -0
  546. package/typst-packages/preview/mitex/0.2.7/specs/prelude.typ +230 -0
  547. package/typst-packages/preview/mitex/0.2.7/typst.toml +12 -0
@@ -0,0 +1,637 @@
1
+ import MarkdownIt, {} from "markdown-it";
2
+ import footnote from "markdown-it-footnote";
3
+ import { parse as parseYaml } from "yaml";
4
+ import { labelKind, labelPattern, parseAttrs, thesisDialect } from "./dialect.js";
5
+ const sectionRoles = [
6
+ "body",
7
+ "annex",
8
+ "abstract",
9
+ "abstract-secondary",
10
+ "dedication",
11
+ "acknowledgments",
12
+ "ai-declaration",
13
+ ];
14
+ const frontKeys = ["role", "section", "lang", "keywords"];
15
+ const md = new MarkdownIt("commonmark", { html: true, linkify: false, typographer: false })
16
+ .enable("table")
17
+ .use(footnote)
18
+ .use(thesisDialect);
19
+ const placeholderPattern = /\b(?:TODO|TBD|XXX|FIXME)\b|\[citation needed\]|\{\{[^}]*\}\}/;
20
+ const rawTypstPattern = /(?:^|\s)#(?:set|show|import|include|let|eval|read|context|page|pagebreak|box|block|raw|image|figure|table|grid|place|text|par|align|heading|bibliography|cite|ref|label|metadata|counter|state|query|script|plugin|json|yaml|csv|toml|xml)\b/;
21
+ const pageBreakPattern = /\\(?:newpage|pagebreak|clearpage)(?![A-Za-z])/;
22
+ const claimPattern = /^<!--\s*claim:([A-Za-z0-9_-]{1,40})\s*-->(.*)$/s;
23
+ const trailingAttrs = /\s*\{\s*((?:#|width=)[^{}]*)\}\s*$/;
24
+ const sourceMarker = /(^|(?<=[.!?])\s+)(Source|Fuente|Fonte):\s*/;
25
+ const imageKinds = [
26
+ [/\.vl\.json$/i, "chart"],
27
+ [/\.mmd$/i, "mermaid"],
28
+ [/\.svg$/i, "svg"],
29
+ [/\.(?:png|jpe?g)$/i, "raster"],
30
+ ];
31
+ const attr = (token, name) => String(token.attrGet(name) ?? "");
32
+ // biome-ignore lint/suspicious/noExplicitAny: markdown-it token meta is an untyped bag set by our own rules
33
+ const meta = (token) => (token.meta ?? {});
34
+ class Converter {
35
+ path;
36
+ lineOffset;
37
+ footnotePrefix;
38
+ findings = [];
39
+ footnotes = {};
40
+ constructor(path, lineOffset, footnotePrefix) {
41
+ this.path = path;
42
+ this.lineOffset = lineOffset;
43
+ this.footnotePrefix = footnotePrefix;
44
+ }
45
+ add(line, message, hint) {
46
+ this.findings.push({
47
+ code: "HYG-001",
48
+ gate: "G7",
49
+ severity: "error",
50
+ file: this.path,
51
+ ...(line === undefined ? {} : { line }),
52
+ message,
53
+ ...(hint ? { hint } : {}),
54
+ });
55
+ }
56
+ lineOf(token) {
57
+ const start = token?.map?.[0];
58
+ return start === undefined ? undefined : start + 1 + this.lineOffset;
59
+ }
60
+ // ---------------------------------------------------------------------------------------
61
+ // Inline
62
+ // ---------------------------------------------------------------------------------------
63
+ inline(children, line) {
64
+ const stack = [
65
+ { kind: "root", nodes: [] },
66
+ ];
67
+ const top = () => stack[stack.length - 1];
68
+ const pushText = (text) => {
69
+ if (text === "")
70
+ return;
71
+ const nodes = top().nodes;
72
+ const last = nodes[nodes.length - 1];
73
+ if (last?.kind === "text")
74
+ last.text += text;
75
+ else
76
+ nodes.push({ kind: "text", text });
77
+ };
78
+ for (const token of children) {
79
+ switch (token.type) {
80
+ case "text":
81
+ case "text_special":
82
+ pushText(token.content);
83
+ break;
84
+ case "softbreak":
85
+ pushText(" ");
86
+ break;
87
+ case "hardbreak":
88
+ top().nodes.push({ kind: "break" });
89
+ break;
90
+ case "code_inline":
91
+ top().nodes.push({ kind: "code", text: token.content });
92
+ break;
93
+ case "em_open":
94
+ stack.push({ kind: "emph", nodes: [] });
95
+ break;
96
+ case "strong_open":
97
+ stack.push({ kind: "strong", nodes: [] });
98
+ break;
99
+ case "em_close":
100
+ case "strong_close": {
101
+ const done = stack.pop();
102
+ if (done && done.kind !== "root" && done.kind !== "link") {
103
+ top().nodes.push({ kind: done.kind, children: done.nodes });
104
+ }
105
+ break;
106
+ }
107
+ case "link_open": {
108
+ const href = attr(token, "href");
109
+ if (!/^(?:https?:\/\/|mailto:)[^\s]+$/i.test(href)) {
110
+ this.add(line, `Unsupported link target "${href.slice(0, 60)}"`, "Use an absolute http(s) or mailto link; cross-references use @fig-x, @tbl-x, @eq-x and @sec-x.");
111
+ stack.push({ kind: "link", nodes: [] });
112
+ }
113
+ else
114
+ stack.push({ kind: "link", href, nodes: [] });
115
+ break;
116
+ }
117
+ case "link_close": {
118
+ const done = stack.pop();
119
+ if (done?.kind === "link") {
120
+ if (done.href)
121
+ top().nodes.push({ kind: "link", href: done.href, children: done.nodes });
122
+ else
123
+ top().nodes.push(...done.nodes);
124
+ }
125
+ break;
126
+ }
127
+ case "math_inline":
128
+ top().nodes.push({ kind: "math", latex: token.content });
129
+ break;
130
+ case "thesis_cite":
131
+ top().nodes.push({
132
+ kind: "citation",
133
+ items: meta(token).items,
134
+ narrative: meta(token).narrative,
135
+ });
136
+ break;
137
+ case "thesis_ref":
138
+ top().nodes.push({
139
+ kind: "crossref",
140
+ label: meta(token).label,
141
+ refKind: meta(token).refKind,
142
+ });
143
+ break;
144
+ case "thesis_badref":
145
+ this.add(line, `Unrecognized reference ${token.content}`, "Citation keys are lowercase author + year (for example @perez2021); cross-references start with fig-, tbl-, eq- or sec-.");
146
+ pushText(token.content);
147
+ break;
148
+ case "footnote_ref":
149
+ top().nodes.push({
150
+ kind: "footnote",
151
+ id: `${this.footnotePrefix}${String(meta(token).id)}`,
152
+ });
153
+ break;
154
+ case "footnote_anchor":
155
+ break;
156
+ case "image":
157
+ this.add(line, "Images must stand alone in their own paragraph as a figure", "Write ![Caption](figures/images/x.png){#fig-x} on a line of its own.");
158
+ break;
159
+ case "html_inline":
160
+ this.add(line, "Raw HTML is not allowed", "Use Markdown or the thesis dialect instead.");
161
+ break;
162
+ default:
163
+ this.add(line, `Unsupported inline construct (${token.type})`);
164
+ }
165
+ }
166
+ while (stack.length > 1) {
167
+ const done = stack.pop();
168
+ if (done && done.kind !== "root")
169
+ top().nodes.push(...done.nodes);
170
+ }
171
+ const nodes = stack[0].nodes;
172
+ this.scanText(nodes, line);
173
+ return nodes;
174
+ }
175
+ scanText(nodes, line) {
176
+ for (const node of nodes) {
177
+ if (node.kind === "text") {
178
+ if (placeholderPattern.test(node.text)) {
179
+ this.add(line, "Placeholder text found (TODO, TBD, XXX, [citation needed] or {{...}})");
180
+ }
181
+ if (rawTypstPattern.test(node.text)) {
182
+ this.add(line, "Raw Typst markup is not allowed in Markdown sources");
183
+ }
184
+ if (pageBreakPattern.test(node.text)) {
185
+ this.add(line, "Page breaks cannot be requested from Markdown", "The template decides page breaks.");
186
+ }
187
+ }
188
+ else if (node.kind === "emph" || node.kind === "strong" || node.kind === "link") {
189
+ this.scanText(node.children, line);
190
+ }
191
+ }
192
+ }
193
+ /** Remove a trailing `{#label width=..}` group from the last text node. */
194
+ takeAttrs(nodes) {
195
+ const last = nodes[nodes.length - 1];
196
+ if (last?.kind !== "text")
197
+ return undefined;
198
+ const match = trailingAttrs.exec(last.text);
199
+ if (!match)
200
+ return undefined;
201
+ last.text = last.text.slice(0, match.index);
202
+ if (last.text === "")
203
+ nodes.pop();
204
+ return match[1];
205
+ }
206
+ labelFrom(attrText, expected, line, allowWidth = false) {
207
+ if (attrText === undefined)
208
+ return {};
209
+ const attrs = parseAttrs(attrText);
210
+ for (const part of attrs.unknown) {
211
+ this.add(line, `Unknown attribute "${part.slice(0, 40)}"`, "Allowed: {#label} and, on figures, width=80%.");
212
+ }
213
+ const result = {};
214
+ if (attrs.label !== undefined) {
215
+ if (labelKind(attrs.label) === expected)
216
+ result.label = attrs.label;
217
+ else
218
+ this.add(line, `Label ${attrs.label} must start with ${expected}- here`);
219
+ }
220
+ if (attrs.width !== undefined) {
221
+ if (allowWidth)
222
+ result.width = attrs.width;
223
+ else
224
+ this.add(line, "width= is only valid on figures");
225
+ }
226
+ return result;
227
+ }
228
+ // ---------------------------------------------------------------------------------------
229
+ // Blocks
230
+ // ---------------------------------------------------------------------------------------
231
+ matching(tokens, open) {
232
+ let depth = 0;
233
+ for (let index = open; index < tokens.length; index += 1) {
234
+ depth += tokens[index].nesting;
235
+ if (depth === 0)
236
+ return index;
237
+ }
238
+ return tokens.length - 1;
239
+ }
240
+ blocks(tokens) {
241
+ const out = [];
242
+ let pendingClaim;
243
+ const settleClaim = (line) => {
244
+ if (pendingClaim !== undefined) {
245
+ this.add(line, `Claim anchor "${pendingClaim}" is not followed by a paragraph`);
246
+ pendingClaim = undefined;
247
+ }
248
+ };
249
+ let index = 0;
250
+ while (index < tokens.length) {
251
+ const token = tokens[index];
252
+ const line = this.lineOf(token);
253
+ switch (token.type) {
254
+ case "heading_open": {
255
+ settleClaim(line);
256
+ const level = Number(token.tag.slice(1));
257
+ const inlineToken = tokens[index + 1];
258
+ const children = this.inline(inlineToken.children ?? [], line);
259
+ const attrText = this.takeAttrs(children);
260
+ const { label } = this.labelFrom(attrText, "sec", line);
261
+ if (level > 4)
262
+ this.add(line, "Headings deeper than level 4 are not supported");
263
+ out.push({
264
+ kind: "heading",
265
+ level: Math.min(level, 4),
266
+ children,
267
+ ...(label ? { label } : {}),
268
+ ...(line === undefined ? {} : { line }),
269
+ });
270
+ index = this.matching(tokens, index) + 1;
271
+ break;
272
+ }
273
+ case "paragraph_open": {
274
+ const inlineToken = tokens[index + 1];
275
+ const produced = this.paragraph(inlineToken, line, out, pendingClaim);
276
+ pendingClaim = undefined;
277
+ if (produced)
278
+ out.push(produced);
279
+ index = this.matching(tokens, index) + 1;
280
+ break;
281
+ }
282
+ case "html_block": {
283
+ const claim = claimPattern.exec(token.content.trim());
284
+ if (claim && !(claim[2] ?? "").includes("\n")) {
285
+ settleClaim(line);
286
+ const rest = (claim[2] ?? "").trim();
287
+ if (rest === "")
288
+ pendingClaim = claim[1];
289
+ else {
290
+ const [inlineToken] = md.parseInline(rest, {});
291
+ const paragraph = this.paragraph(inlineToken, line, out, claim[1]);
292
+ if (paragraph)
293
+ out.push(paragraph);
294
+ }
295
+ }
296
+ else {
297
+ settleClaim(line);
298
+ this.add(line, "Raw HTML is not allowed", "Only <!-- claim:id --> comments are accepted.");
299
+ }
300
+ index += 1;
301
+ break;
302
+ }
303
+ case "bullet_list_open":
304
+ case "ordered_list_open": {
305
+ settleClaim(line);
306
+ const end = this.matching(tokens, index);
307
+ const items = [];
308
+ let cursor = index + 1;
309
+ while (cursor < end) {
310
+ const itemEnd = this.matching(tokens, cursor);
311
+ items.push(this.blocks(tokens.slice(cursor + 1, itemEnd)));
312
+ cursor = itemEnd + 1;
313
+ }
314
+ out.push({
315
+ kind: "list",
316
+ ordered: token.type === "ordered_list_open",
317
+ items,
318
+ ...(line === undefined ? {} : { line }),
319
+ });
320
+ index = end + 1;
321
+ break;
322
+ }
323
+ case "blockquote_open": {
324
+ settleClaim(line);
325
+ const end = this.matching(tokens, index);
326
+ out.push({
327
+ kind: "quote",
328
+ children: this.blocks(tokens.slice(index + 1, end)),
329
+ ...(line === undefined ? {} : { line }),
330
+ });
331
+ index = end + 1;
332
+ break;
333
+ }
334
+ case "fence":
335
+ case "code_block": {
336
+ settleClaim(line);
337
+ const lang = token.info.trim().split(/\s+/)[0] ?? "";
338
+ out.push({
339
+ kind: "codeblock",
340
+ text: token.content.replace(/\n$/, ""),
341
+ ...(/^[A-Za-z0-9_+#-]{1,20}$/.test(lang) ? { lang } : {}),
342
+ ...(line === undefined ? {} : { line }),
343
+ });
344
+ index += 1;
345
+ break;
346
+ }
347
+ case "math_block": {
348
+ settleClaim(line);
349
+ const attrText = meta(token).attr;
350
+ const { label } = this.labelFrom(attrText?.trim(), "eq", line);
351
+ out.push({
352
+ kind: "equation",
353
+ latex: token.content,
354
+ ...(label ? { label } : {}),
355
+ ...(line === undefined ? {} : { line }),
356
+ });
357
+ index += 1;
358
+ break;
359
+ }
360
+ case "table_open": {
361
+ settleClaim(line);
362
+ const end = this.matching(tokens, index);
363
+ out.push(this.table(tokens.slice(index, end + 1), line));
364
+ index = end + 1;
365
+ break;
366
+ }
367
+ case "footnote_block_open": {
368
+ const end = this.matching(tokens, index);
369
+ let cursor = index + 1;
370
+ while (cursor < end) {
371
+ const open = tokens[cursor];
372
+ if (open.type === "footnote_open") {
373
+ const itemEnd = this.matching(tokens, cursor);
374
+ this.footnotes[`${this.footnotePrefix}${String(meta(open).id)}`] = this.blocks(tokens.slice(cursor + 1, itemEnd));
375
+ cursor = itemEnd + 1;
376
+ }
377
+ else
378
+ cursor += 1;
379
+ }
380
+ index = end + 1;
381
+ break;
382
+ }
383
+ case "footnote_anchor":
384
+ index += 1;
385
+ break;
386
+ case "hr":
387
+ settleClaim(line);
388
+ this.add(line, "Thematic breaks (---) are not supported");
389
+ index += 1;
390
+ break;
391
+ default:
392
+ settleClaim(line);
393
+ this.add(line, `Unsupported construct (${token.type})`);
394
+ index = token.nesting === 1 ? this.matching(tokens, index) + 1 : index + 1;
395
+ }
396
+ }
397
+ settleClaim(undefined);
398
+ return out;
399
+ }
400
+ paragraph(inlineToken, line, out, claim) {
401
+ const children = inlineToken.children ?? [];
402
+ const meaningful = children.filter((child) => !(child.type === "softbreak" || (child.type === "text" && child.content.trim() === "")));
403
+ const imageAt = meaningful.findIndex((child) => child.type === "image");
404
+ if (imageAt >= 0) {
405
+ const figure = this.figure(meaningful, line);
406
+ if (claim !== undefined)
407
+ this.add(line, "A claim anchor cannot precede a figure");
408
+ return figure;
409
+ }
410
+ const nodes = this.inline(children, line);
411
+ // `Table: Caption {#tbl-x}` attaches to the table just before it.
412
+ const first = nodes[0];
413
+ const previous = out[out.length - 1];
414
+ if (first?.kind === "text" && /^Table:\s/.test(first.text)) {
415
+ if (previous?.kind === "table" && previous.caption === undefined) {
416
+ first.text = first.text.replace(/^Table:\s+/, "");
417
+ const attrText = this.takeAttrs(nodes);
418
+ const { label } = this.labelFrom(attrText, "tbl", line);
419
+ const { caption, source } = splitSource(nodes);
420
+ previous.caption = caption;
421
+ if (source)
422
+ previous.source = source;
423
+ if (label)
424
+ previous.label = label;
425
+ return undefined;
426
+ }
427
+ this.add(line, "A Table: caption must directly follow a table");
428
+ }
429
+ if (nodes.length === 0)
430
+ return undefined;
431
+ return {
432
+ kind: "paragraph",
433
+ children: nodes,
434
+ ...(claim === undefined ? {} : { claim }),
435
+ ...(line === undefined ? {} : { line }),
436
+ };
437
+ }
438
+ figure(meaningful, line) {
439
+ const image = meaningful[0];
440
+ if (image.type !== "image") {
441
+ this.add(line, "Images must stand alone in their own paragraph as a figure");
442
+ return undefined;
443
+ }
444
+ let attrText;
445
+ for (const extra of meaningful.slice(1)) {
446
+ const match = extra.type === "text" ? /^\s*\{\s*([^{}]*)\}\s*$/.exec(extra.content) : null;
447
+ if (match && attrText === undefined && /^(?:#|width=)/.test((match[1] ?? "").trim())) {
448
+ attrText = (match[1] ?? "").trim();
449
+ }
450
+ else {
451
+ this.add(line, "Unexpected text next to a figure; only {#fig-x width=80%} may follow it");
452
+ return undefined;
453
+ }
454
+ }
455
+ const { label, width } = this.labelFrom(attrText, "fig", line, true);
456
+ const src = attr(image, "src");
457
+ const kindEntry = imageKinds.find(([pattern]) => pattern.test(src));
458
+ const safe = src.startsWith("figures/") &&
459
+ !src.includes("\\") &&
460
+ !src.includes("\0") &&
461
+ src.split("/").every((part) => part !== "" && part !== "." && part !== "..");
462
+ if (!safe) {
463
+ this.add(line, `Unsafe or unsupported figure path "${src.slice(0, 80)}"`, "Figures are workspace-relative paths under figures/, for example figures/diagrams/flow.mmd.");
464
+ return undefined;
465
+ }
466
+ if (!kindEntry) {
467
+ this.add(line, `Unsupported figure type "${src.slice(0, 80)}"`, "Use .mmd, .svg, .png, .jpg or .vl.json.");
468
+ return undefined;
469
+ }
470
+ const asset = { kind: kindEntry[1], path: src };
471
+ const { caption, source } = splitSource(this.inline(image.children ?? [], line));
472
+ return {
473
+ kind: "figure",
474
+ asset,
475
+ caption,
476
+ ...(source ? { source } : {}),
477
+ ...(label ? { label } : {}),
478
+ ...(width ? { width } : {}),
479
+ ...(line === undefined ? {} : { line }),
480
+ };
481
+ }
482
+ table(tokens, line) {
483
+ const align = [];
484
+ const header = [];
485
+ const rows = [];
486
+ let current;
487
+ let inHead = false;
488
+ for (const token of tokens) {
489
+ if (token.type === "thead_open")
490
+ inHead = true;
491
+ else if (token.type === "thead_close")
492
+ inHead = false;
493
+ else if (token.type === "tr_open")
494
+ current = [];
495
+ else if (token.type === "tr_close" && current) {
496
+ if (inHead)
497
+ header.splice(0, header.length, ...current);
498
+ else
499
+ rows.push(current);
500
+ current = undefined;
501
+ }
502
+ else if (token.type === "th_open" || token.type === "td_open") {
503
+ if (inHead) {
504
+ const style = attr(token, "style");
505
+ const found = /text-align:(left|center|right)/.exec(style)?.[1];
506
+ align.push(found ?? null);
507
+ }
508
+ }
509
+ else if (token.type === "inline" && current) {
510
+ current.push(this.inline(token.children ?? [], line));
511
+ }
512
+ }
513
+ return {
514
+ kind: "table",
515
+ align,
516
+ header,
517
+ rows,
518
+ ...(line === undefined ? {} : { line }),
519
+ };
520
+ }
521
+ }
522
+ /** Split a caption at its "Source: ..." sentence (also Fuente:, Fonte:). */
523
+ export function splitSource(nodes) {
524
+ for (let index = 0; index < nodes.length; index += 1) {
525
+ const node = nodes[index];
526
+ if (node.kind !== "text")
527
+ continue;
528
+ const match = sourceMarker.exec(node.text);
529
+ if (!match)
530
+ continue;
531
+ const before = node.text.slice(0, match.index);
532
+ const sourceText = node.text.slice(match.index + (match[1]?.length ?? 0));
533
+ const caption = [...nodes.slice(0, index)];
534
+ if (before !== "")
535
+ caption.push({ kind: "text", text: before });
536
+ return {
537
+ caption,
538
+ source: [{ kind: "text", text: sourceText }, ...nodes.slice(index + 1)],
539
+ };
540
+ }
541
+ return { caption: nodes };
542
+ }
543
+ function splitFrontMatter(path, source, findings) {
544
+ const base = {
545
+ role: path.includes("/annexes/") ? "annex" : "body",
546
+ body: source,
547
+ lineOffset: 0,
548
+ };
549
+ const match = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(source);
550
+ if (!match)
551
+ return base;
552
+ const fail = (message) => findings.push({ code: "HYG-001", gate: "G7", severity: "error", file: path, line: 1, message });
553
+ let data;
554
+ try {
555
+ data = parseYaml(match[1]);
556
+ }
557
+ catch {
558
+ fail("The YAML front matter of this chapter is not valid YAML");
559
+ return {
560
+ ...base,
561
+ body: source.slice(match[0].length),
562
+ lineOffset: match[0].split("\n").length - 1,
563
+ };
564
+ }
565
+ const result = {
566
+ ...base,
567
+ body: source.slice(match[0].length),
568
+ lineOffset: match[0].split("\n").length - 1,
569
+ };
570
+ if (data === null || data === undefined)
571
+ return result;
572
+ if (typeof data !== "object" || Array.isArray(data)) {
573
+ fail("The YAML front matter must be a mapping");
574
+ return result;
575
+ }
576
+ const record = data;
577
+ for (const key of Object.keys(record)) {
578
+ if (!frontKeys.includes(key))
579
+ fail(`Unknown front matter key "${key}"`);
580
+ }
581
+ if (record.role !== undefined) {
582
+ if (typeof record.role === "string" &&
583
+ sectionRoles.includes(record.role)) {
584
+ result.role = record.role;
585
+ }
586
+ else
587
+ fail(`role must be one of ${sectionRoles.join(", ")}`);
588
+ }
589
+ if (record.section !== undefined) {
590
+ if (typeof record.section === "string" && /^SEC-\d{2}(\.\d{2}){0,2}$/.test(record.section)) {
591
+ result.section = record.section;
592
+ }
593
+ else
594
+ fail("section must be an outline id such as SEC-03");
595
+ }
596
+ if (record.lang !== undefined) {
597
+ if (typeof record.lang === "string" &&
598
+ /^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$/.test(record.lang)) {
599
+ result.lang = record.lang;
600
+ }
601
+ else
602
+ fail("lang must be a BCP-47 tag");
603
+ }
604
+ if (record.keywords !== undefined) {
605
+ if (Array.isArray(record.keywords) &&
606
+ record.keywords.length <= 12 &&
607
+ record.keywords.every((item) => typeof item === "string" && item.length > 0 && item.length <= 80)) {
608
+ result.keywords = record.keywords;
609
+ }
610
+ else
611
+ fail("keywords must be a list of at most 12 short strings");
612
+ }
613
+ return result;
614
+ }
615
+ /** Parse one Markdown chapter into the neutral model. Pure: no file access. */
616
+ export function parseChapter(path, source, options = {}) {
617
+ const findings = [];
618
+ const front = splitFrontMatter(path, source, findings);
619
+ const converter = new Converter(path, front.lineOffset, options.footnotePrefix ?? `${path}#`);
620
+ const tokens = md.parse(front.body, {});
621
+ const blocks = converter.blocks(tokens);
622
+ const section = {
623
+ path,
624
+ role: front.role,
625
+ blocks,
626
+ ...(front.section ? { section: front.section } : {}),
627
+ ...(front.lang ? { lang: front.lang } : {}),
628
+ ...(front.keywords ? { keywords: front.keywords } : {}),
629
+ };
630
+ return {
631
+ section,
632
+ footnotes: converter.footnotes,
633
+ findings: [...findings, ...converter.findings],
634
+ };
635
+ }
636
+ export { labelPattern };
637
+ //# sourceMappingURL=parse.js.map