@bendyline/squisq 2.1.0 → 2.2.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 (446) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +24 -0
  3. package/dist/{ContentContainer-BXUlIf18.d.ts → ContentContainer-B2w9sUoL.d.ts} +15 -0
  4. package/dist/{Doc-DynJleo-.d.ts → Doc-BubIpWsp.d.ts} +1 -1
  5. package/dist/{ImageEditDoc-Ca4Tr9uN.d.ts → ImageEditDoc-CGxk5CHc.d.ts} +1 -1
  6. package/dist/{annotationCoercion-Dr_DY9Hx.d.ts → annotationCoercion-PtRQhk5V.d.ts} +1 -1
  7. package/dist/chunk-2L55443L.js +0 -0
  8. package/dist/{chunk-VWCJ2WXC.js → chunk-2ZWIXGAC.js} +0 -1
  9. package/dist/{chunk-VYFRI7R6.js → chunk-32R2RZAO.js} +72 -3
  10. package/dist/chunk-3IGPAPQ7.js +645 -0
  11. package/dist/{chunk-QE7TWGVT.js → chunk-4VOD55SX.js} +0 -1
  12. package/dist/{chunk-3E5F2XMR.js → chunk-67L6WRJN.js} +0 -1
  13. package/dist/{chunk-5DKBFXPY.js → chunk-6ECMNUIP.js} +26 -18
  14. package/dist/{chunk-JI77MGAK.js → chunk-7ARJZYQY.js} +159 -120
  15. package/dist/{chunk-DBS6RIFL.js → chunk-7N4G32LG.js} +0 -1
  16. package/dist/{chunk-JOQYPRDZ.js → chunk-7YEZFHLS.js} +10 -8
  17. package/dist/{chunk-2UQOHYE2.js → chunk-7ZAAICW4.js} +0 -1
  18. package/dist/{chunk-66QO7XFB.js → chunk-ACZOVWX3.js} +117 -7
  19. package/dist/{chunk-5J4HKRJF.js → chunk-BAOV476U.js} +0 -1
  20. package/dist/chunk-BCCXTMN5.js +699 -0
  21. package/dist/{chunk-JHZWYRSW.js → chunk-C33GTPUZ.js} +11 -4
  22. package/dist/{chunk-QUUPYOSP.js → chunk-CB45YGAM.js} +2 -3
  23. package/dist/{chunk-XNLB57UD.js → chunk-DYPMOPIW.js} +18 -2
  24. package/dist/{chunk-VR7UPJ7C.js → chunk-FCG3BIZN.js} +12 -1
  25. package/dist/{chunk-5UYI3RJB.js → chunk-FDYDYL77.js} +54 -40
  26. package/dist/{chunk-OTKVFVL6.js → chunk-I2O6W7DX.js} +116 -44
  27. package/dist/{chunk-Q7LROV2H.js → chunk-NKNMGIIN.js} +0 -1
  28. package/dist/chunk-OPO5K4DZ.js +241 -0
  29. package/dist/{chunk-TUWMK62B.js → chunk-PUS54YU6.js} +45 -2
  30. package/dist/chunk-QKPXHDLR.js +0 -0
  31. package/dist/{chunk-GZY66SDN.js → chunk-R3KTTOMS.js} +0 -1
  32. package/dist/{chunk-ILWDXLUK.js → chunk-RS5AP3J4.js} +49 -10
  33. package/dist/chunk-WV5ARNDA.js +0 -0
  34. package/dist/{chunk-4X3JQXNM.js → chunk-XOFT65EX.js} +1 -2
  35. package/dist/{chunk-FVTQSNR7.js → chunk-XRW6P7IF.js} +13 -5
  36. package/dist/chunk-XWNNA3KE.js +0 -0
  37. package/dist/chunk-YZNGMV3G.js +0 -0
  38. package/dist/{chunk-R2YZTCLO.js → chunk-ZQKZSJAX.js} +1 -2
  39. package/dist/doc/index.d.ts +27 -12
  40. package/dist/doc/index.js +16 -17
  41. package/dist/generate/index.d.ts +2 -2
  42. package/dist/generate/index.js +2 -3
  43. package/dist/icons/index.js +3 -4
  44. package/dist/icons/inlineIconMarker.js +1 -2
  45. package/dist/imageEdit/index.d.ts +48 -17
  46. package/dist/imageEdit/index.js +3 -4
  47. package/dist/index.d.ts +11 -11
  48. package/dist/index.js +60 -33
  49. package/dist/jsonForm/index.d.ts +10 -3
  50. package/dist/jsonForm/index.js +8 -7
  51. package/dist/markdown/index.d.ts +75 -11
  52. package/dist/markdown/index.js +32 -7
  53. package/dist/{materializePageSection-DDzubQXo.d.ts → materializePageSection-wSLA2A1g.d.ts} +2 -2
  54. package/dist/narration/index.d.ts +16 -3
  55. package/dist/narration/index.js +13 -14
  56. package/dist/random/index.d.ts +11 -2
  57. package/dist/random/index.js +2 -3
  58. package/dist/recommend/index.d.ts +1 -1
  59. package/dist/recommend/index.js +3 -4
  60. package/dist/schemas/index.d.ts +5 -5
  61. package/dist/schemas/index.js +5 -6
  62. package/dist/spatial/index.d.ts +2 -1
  63. package/dist/spatial/index.js +1 -2
  64. package/dist/storage/index.d.ts +4 -2
  65. package/dist/storage/index.js +1 -2
  66. package/dist/{themeLibrary-B72m0W1y.d.ts → themeLibrary-DU9mUmVl.d.ts} +1 -1
  67. package/dist/timing/index.js +3 -4
  68. package/dist/transform/index.d.ts +3 -3
  69. package/dist/transform/index.js +6 -7
  70. package/dist/{types-C4kiRn_k.d.ts → types-8QjefM9J.d.ts} +38 -2
  71. package/dist/{types-BwMPl2CB.d.ts → types-CUNc9biN.d.ts} +24 -1
  72. package/dist/versions/index.d.ts +14 -11
  73. package/dist/versions/index.js +2 -3
  74. package/package.json +4 -2
  75. package/dist/chunk-2UQOHYE2.js.map +0 -1
  76. package/dist/chunk-3E5F2XMR.js.map +0 -1
  77. package/dist/chunk-4X3JQXNM.js.map +0 -1
  78. package/dist/chunk-5DKBFXPY.js.map +0 -1
  79. package/dist/chunk-5J4HKRJF.js.map +0 -1
  80. package/dist/chunk-5UYI3RJB.js.map +0 -1
  81. package/dist/chunk-66QO7XFB.js.map +0 -1
  82. package/dist/chunk-AMIR72JP.js +0 -380
  83. package/dist/chunk-AMIR72JP.js.map +0 -1
  84. package/dist/chunk-DBS6RIFL.js.map +0 -1
  85. package/dist/chunk-DNJKBAI7.js +0 -1
  86. package/dist/chunk-DNJKBAI7.js.map +0 -1
  87. package/dist/chunk-ET53IIEP.js +0 -1
  88. package/dist/chunk-ET53IIEP.js.map +0 -1
  89. package/dist/chunk-FVTQSNR7.js.map +0 -1
  90. package/dist/chunk-GZY66SDN.js.map +0 -1
  91. package/dist/chunk-ILWDXLUK.js.map +0 -1
  92. package/dist/chunk-JHZWYRSW.js.map +0 -1
  93. package/dist/chunk-JI77MGAK.js.map +0 -1
  94. package/dist/chunk-JOQYPRDZ.js.map +0 -1
  95. package/dist/chunk-OTKVFVL6.js.map +0 -1
  96. package/dist/chunk-PGGGKYWG.js +0 -1
  97. package/dist/chunk-PGGGKYWG.js.map +0 -1
  98. package/dist/chunk-Q7LROV2H.js.map +0 -1
  99. package/dist/chunk-QE7TWGVT.js.map +0 -1
  100. package/dist/chunk-QUUPYOSP.js.map +0 -1
  101. package/dist/chunk-R2GC6RLD.js +0 -344
  102. package/dist/chunk-R2GC6RLD.js.map +0 -1
  103. package/dist/chunk-R2YZTCLO.js.map +0 -1
  104. package/dist/chunk-S7A5D7ZJ.js +0 -174
  105. package/dist/chunk-S7A5D7ZJ.js.map +0 -1
  106. package/dist/chunk-TUWMK62B.js.map +0 -1
  107. package/dist/chunk-V543AI2F.js +0 -1
  108. package/dist/chunk-V543AI2F.js.map +0 -1
  109. package/dist/chunk-VR7UPJ7C.js.map +0 -1
  110. package/dist/chunk-VWCJ2WXC.js.map +0 -1
  111. package/dist/chunk-VYFRI7R6.js.map +0 -1
  112. package/dist/chunk-XNLB57UD.js.map +0 -1
  113. package/dist/chunk-ZLQKNOZQ.js +0 -1
  114. package/dist/chunk-ZLQKNOZQ.js.map +0 -1
  115. package/dist/doc/index.js.map +0 -1
  116. package/dist/generate/index.js.map +0 -1
  117. package/dist/icons/index.js.map +0 -1
  118. package/dist/icons/inlineIconMarker.js.map +0 -1
  119. package/dist/imageEdit/index.js.map +0 -1
  120. package/dist/index.js.map +0 -1
  121. package/dist/jsonForm/index.js.map +0 -1
  122. package/dist/markdown/index.js.map +0 -1
  123. package/dist/narration/index.js.map +0 -1
  124. package/dist/random/index.js.map +0 -1
  125. package/dist/recommend/index.js.map +0 -1
  126. package/dist/schemas/index.js.map +0 -1
  127. package/dist/spatial/index.js.map +0 -1
  128. package/dist/storage/index.js.map +0 -1
  129. package/dist/timing/index.js.map +0 -1
  130. package/dist/transform/index.js.map +0 -1
  131. package/dist/versions/index.js.map +0 -1
  132. package/src/__tests__/animationUtils.test.ts +0 -117
  133. package/src/__tests__/annotationCoercion.test.ts +0 -243
  134. package/src/__tests__/applyNarrationTiming.test.ts +0 -190
  135. package/src/__tests__/applyRenderStyle.test.ts +0 -146
  136. package/src/__tests__/asciiDiagramBattle.test.ts +0 -246
  137. package/src/__tests__/asciiDiagramDetect.test.ts +0 -162
  138. package/src/__tests__/asciiDiagramMapping.test.ts +0 -38
  139. package/src/__tests__/asciiDiagramParse.test.ts +0 -233
  140. package/src/__tests__/asciiDiagramPipeline.test.ts +0 -273
  141. package/src/__tests__/asciiDiagramRender.test.ts +0 -162
  142. package/src/__tests__/asciiDiagramRepair.test.ts +0 -84
  143. package/src/__tests__/asciiTimelineDetect.test.ts +0 -157
  144. package/src/__tests__/asciiTimelineParse.test.ts +0 -205
  145. package/src/__tests__/asciiTimelinePipeline.test.ts +0 -349
  146. package/src/__tests__/asciiTimelineRender.test.ts +0 -376
  147. package/src/__tests__/atmosphereLayers.test.ts +0 -108
  148. package/src/__tests__/attrTokens.test.ts +0 -167
  149. package/src/__tests__/colorUtils.test.ts +0 -112
  150. package/src/__tests__/contentContainer.test.ts +0 -325
  151. package/src/__tests__/contentExtractor.test.ts +0 -243
  152. package/src/__tests__/coverBlock.test.ts +0 -310
  153. package/src/__tests__/customTemplateSample.test.ts +0 -144
  154. package/src/__tests__/customTemplatesFrontmatter.test.ts +0 -221
  155. package/src/__tests__/customThemesFrontmatter.test.ts +0 -146
  156. package/src/__tests__/dataTable.test.ts +0 -145
  157. package/src/__tests__/diagramBlock.test.ts +0 -122
  158. package/src/__tests__/diagramLayout.test.ts +0 -134
  159. package/src/__tests__/diagramText.test.ts +0 -26
  160. package/src/__tests__/docToMarkdownMedia.test.ts +0 -83
  161. package/src/__tests__/drawing.test.ts +0 -109
  162. package/src/__tests__/drawingBlock.test.ts +0 -124
  163. package/src/__tests__/drawingLayout.test.ts +0 -171
  164. package/src/__tests__/fixtures/asciiDiagramBattle.ts +0 -512
  165. package/src/__tests__/fixtures/asciiDiagrams.ts +0 -287
  166. package/src/__tests__/fixtures/asciiTimelines.ts +0 -35
  167. package/src/__tests__/fixtures/treeviewFixtures.ts +0 -243
  168. package/src/__tests__/geohash.test.ts +0 -110
  169. package/src/__tests__/getLayers.test.ts +0 -243
  170. package/src/__tests__/getLayersFallback.test.ts +0 -103
  171. package/src/__tests__/haversine.test.ts +0 -63
  172. package/src/__tests__/iconResolve.test.ts +0 -122
  173. package/src/__tests__/imageEditExportSvg.test.ts +0 -70
  174. package/src/__tests__/imageEditState.test.ts +0 -74
  175. package/src/__tests__/imageEditVersions.test.ts +0 -243
  176. package/src/__tests__/inferDocumentTitle.test.ts +0 -50
  177. package/src/__tests__/inlineIconMarker.test.ts +0 -36
  178. package/src/__tests__/inputDescriptors.test.ts +0 -162
  179. package/src/__tests__/jsonForm.chooseControl.test.ts +0 -86
  180. package/src/__tests__/jsonForm.evaluateWhen.test.ts +0 -59
  181. package/src/__tests__/jsonForm.inferSchema.test.ts +0 -25
  182. package/src/__tests__/jsonForm.pointer.test.ts +0 -149
  183. package/src/__tests__/jsonForm.tokens.test.ts +0 -84
  184. package/src/__tests__/layoutBlock.test.ts +0 -83
  185. package/src/__tests__/layoutLayout.test.ts +0 -169
  186. package/src/__tests__/localForageAdapter.test.ts +0 -155
  187. package/src/__tests__/majorApiTypes.test.ts +0 -18
  188. package/src/__tests__/markdown.test.ts +0 -1009
  189. package/src/__tests__/markdownIcons.test.ts +0 -104
  190. package/src/__tests__/markdownSanitize.test.ts +0 -81
  191. package/src/__tests__/markdownToDoc.test.ts +0 -957
  192. package/src/__tests__/matchFontFamily.test.ts +0 -114
  193. package/src/__tests__/materializeBlockLayers.test.ts +0 -167
  194. package/src/__tests__/materializePageSections.test.ts +0 -404
  195. package/src/__tests__/materializeTestUtils.ts +0 -17
  196. package/src/__tests__/mediaAnnotations.test.ts +0 -91
  197. package/src/__tests__/mediaSchedule.test.ts +0 -118
  198. package/src/__tests__/narrationAlign.test.ts +0 -150
  199. package/src/__tests__/narrationFeatures.test.ts +0 -71
  200. package/src/__tests__/narrationNuclei.test.ts +0 -45
  201. package/src/__tests__/narrationPacing.test.ts +0 -189
  202. package/src/__tests__/narrationScript.test.ts +0 -149
  203. package/src/__tests__/narrationSessionRepro.test.ts +0 -62
  204. package/src/__tests__/narrationSidecar.test.ts +0 -88
  205. package/src/__tests__/narrationSyllables.test.ts +0 -65
  206. package/src/__tests__/narrationTestSignals.ts +0 -167
  207. package/src/__tests__/narrationVad.test.ts +0 -66
  208. package/src/__tests__/pageStyle.test.ts +0 -258
  209. package/src/__tests__/pandocAttrParse.test.ts +0 -187
  210. package/src/__tests__/recommendTemplates.test.ts +0 -183
  211. package/src/__tests__/resolveDocTheme.test.ts +0 -69
  212. package/src/__tests__/rootExports.test.ts +0 -61
  213. package/src/__tests__/scopedContentContainer.test.ts +0 -109
  214. package/src/__tests__/seededRandom.test.ts +0 -142
  215. package/src/__tests__/shapeGeometry.test.ts +0 -138
  216. package/src/__tests__/shapeVocabulary.test.ts +0 -133
  217. package/src/__tests__/storage.test.ts +0 -60
  218. package/src/__tests__/structuredData.test.ts +0 -249
  219. package/src/__tests__/surface.test.ts +0 -68
  220. package/src/__tests__/templateAnnotationParse.test.ts +0 -173
  221. package/src/__tests__/templateInputs.test.ts +0 -69
  222. package/src/__tests__/templateMetadata.test.ts +0 -32
  223. package/src/__tests__/templates.test.ts +0 -710
  224. package/src/__tests__/themeCompile.test.ts +0 -225
  225. package/src/__tests__/themeValidator.test.ts +0 -131
  226. package/src/__tests__/timing.test.ts +0 -167
  227. package/src/__tests__/transformProvenance.test.ts +0 -160
  228. package/src/__tests__/transformV2.test.ts +0 -163
  229. package/src/__tests__/transitionNormalize.test.ts +0 -61
  230. package/src/__tests__/treeviewBattle.test.ts +0 -76
  231. package/src/__tests__/treeviewDetect.test.ts +0 -168
  232. package/src/__tests__/treeviewParse.test.ts +0 -118
  233. package/src/__tests__/treeviewPipeline.test.ts +0 -183
  234. package/src/__tests__/treeviewRender.test.ts +0 -91
  235. package/src/__tests__/validateDoc.test.ts +0 -260
  236. package/src/__tests__/versions.test.ts +0 -459
  237. package/src/doc/annotationBlocks.ts +0 -117
  238. package/src/doc/applyNarrationTiming.ts +0 -244
  239. package/src/doc/asciiDiagram/chars.ts +0 -210
  240. package/src/doc/asciiDiagram/detect.ts +0 -175
  241. package/src/doc/asciiDiagram/index.ts +0 -38
  242. package/src/doc/asciiDiagram/mapping.ts +0 -225
  243. package/src/doc/asciiDiagram/parse.ts +0 -1095
  244. package/src/doc/asciiDiagram/render.ts +0 -963
  245. package/src/doc/asciiDiagram/repair.ts +0 -400
  246. package/src/doc/asciiDiagram/types.ts +0 -65
  247. package/src/doc/asciiTimeline/detect.ts +0 -138
  248. package/src/doc/asciiTimeline/index.ts +0 -26
  249. package/src/doc/asciiTimeline/mapping.ts +0 -43
  250. package/src/doc/asciiTimeline/parse.ts +0 -870
  251. package/src/doc/asciiTimeline/render.ts +0 -427
  252. package/src/doc/asciiTimeline/types.ts +0 -73
  253. package/src/doc/asciiTimeline/wrappedFlow.ts +0 -427
  254. package/src/doc/audioMapping.ts +0 -442
  255. package/src/doc/customTemplatesFrontmatter.ts +0 -273
  256. package/src/doc/customThemesFrontmatter.ts +0 -95
  257. package/src/doc/docToMarkdown.ts +0 -284
  258. package/src/doc/index.ts +0 -161
  259. package/src/doc/markdownToDoc.ts +0 -1054
  260. package/src/doc/materializeBlockLayers.ts +0 -465
  261. package/src/doc/mediaAnnotations.ts +0 -120
  262. package/src/doc/page/PageSection.ts +0 -174
  263. package/src/doc/page/materializePageSection.ts +0 -616
  264. package/src/doc/page/resolvePageBlock.ts +0 -108
  265. package/src/doc/page/sectionExtractors.ts +0 -466
  266. package/src/doc/pageCss.ts +0 -628
  267. package/src/doc/resolveDocTheme.ts +0 -56
  268. package/src/doc/standaloneAnnotation.ts +0 -58
  269. package/src/doc/structuredData.ts +0 -301
  270. package/src/doc/templateInputs.ts +0 -424
  271. package/src/doc/templates/__tests__/customTemplate.test.ts +0 -170
  272. package/src/doc/templates/__tests__/customTemplateRegistry.test.ts +0 -124
  273. package/src/doc/templates/__tests__/listBlock.test.ts +0 -64
  274. package/src/doc/templates/accentImage.ts +0 -362
  275. package/src/doc/templates/captionUtils.ts +0 -56
  276. package/src/doc/templates/comparisonBar.ts +0 -173
  277. package/src/doc/templates/coverBlock.ts +0 -255
  278. package/src/doc/templates/customTemplate.ts +0 -51
  279. package/src/doc/templates/dataTable.ts +0 -102
  280. package/src/doc/templates/dateEvent.ts +0 -147
  281. package/src/doc/templates/definitionCard.ts +0 -140
  282. package/src/doc/templates/diagramBlock.ts +0 -403
  283. package/src/doc/templates/diagramLayout.ts +0 -159
  284. package/src/doc/templates/drawingBlock.ts +0 -325
  285. package/src/doc/templates/drawingLayout.ts +0 -539
  286. package/src/doc/templates/factCard.ts +0 -146
  287. package/src/doc/templates/fallbackBlock.ts +0 -123
  288. package/src/doc/templates/featureBlock.ts +0 -209
  289. package/src/doc/templates/fullBleedQuote.ts +0 -83
  290. package/src/doc/templates/imageWithCaption.ts +0 -186
  291. package/src/doc/templates/index.ts +0 -642
  292. package/src/doc/templates/inputDescriptors.ts +0 -451
  293. package/src/doc/templates/layoutBlock.ts +0 -43
  294. package/src/doc/templates/layoutLayout.ts +0 -243
  295. package/src/doc/templates/listBlock.ts +0 -207
  296. package/src/doc/templates/mapBlock.ts +0 -138
  297. package/src/doc/templates/metadata.ts +0 -130
  298. package/src/doc/templates/persistentLayers.ts +0 -526
  299. package/src/doc/templates/photoGrid.ts +0 -190
  300. package/src/doc/templates/pullQuote.ts +0 -141
  301. package/src/doc/templates/quoteBlock.ts +0 -141
  302. package/src/doc/templates/registry.ts +0 -88
  303. package/src/doc/templates/sectionHeader.ts +0 -120
  304. package/src/doc/templates/statHighlight.ts +0 -146
  305. package/src/doc/templates/templateNames.ts +0 -22
  306. package/src/doc/templates/timelineBlock.ts +0 -613
  307. package/src/doc/templates/titleBlock.ts +0 -150
  308. package/src/doc/templates/tokens/__tests__/resolveTokens.test.ts +0 -487
  309. package/src/doc/templates/tokens/resolveTokens.ts +0 -453
  310. package/src/doc/templates/treeBlock.ts +0 -131
  311. package/src/doc/templates/twoColumn.ts +0 -263
  312. package/src/doc/templates/videoPullQuote.ts +0 -142
  313. package/src/doc/templates/videoWithCaption.ts +0 -135
  314. package/src/doc/treeview/chars.ts +0 -72
  315. package/src/doc/treeview/detect.ts +0 -145
  316. package/src/doc/treeview/index.ts +0 -30
  317. package/src/doc/treeview/mapping.ts +0 -95
  318. package/src/doc/treeview/parse.ts +0 -201
  319. package/src/doc/treeview/render.ts +0 -41
  320. package/src/doc/treeview/types.ts +0 -43
  321. package/src/doc/utils/animationUtils.ts +0 -399
  322. package/src/doc/utils/applyRenderStyle.ts +0 -106
  323. package/src/doc/utils/diagramText.ts +0 -78
  324. package/src/doc/utils/imageTreatment.ts +0 -70
  325. package/src/doc/utils/nearest.ts +0 -59
  326. package/src/doc/utils/shapeGeometry.ts +0 -614
  327. package/src/doc/utils/themeUtils.ts +0 -243
  328. package/src/doc/validate.ts +0 -575
  329. package/src/generate/contentExtractor.ts +0 -921
  330. package/src/generate/index.ts +0 -18
  331. package/src/generate/templateMapper.ts +0 -177
  332. package/src/icons/iconData.ts +0 -31
  333. package/src/icons/index.ts +0 -26
  334. package/src/icons/inlineIconMarker.ts +0 -73
  335. package/src/icons/resolve.ts +0 -139
  336. package/src/imageEdit/ImageEditVersionManager.ts +0 -73
  337. package/src/imageEdit/export.ts +0 -410
  338. package/src/imageEdit/index.ts +0 -72
  339. package/src/imageEdit/persistence.ts +0 -113
  340. package/src/imageEdit/state.ts +0 -112
  341. package/src/imageEdit/versionPaths.ts +0 -44
  342. package/src/imageEdit/versions.ts +0 -152
  343. package/src/index.ts +0 -15
  344. package/src/internal/immutable.ts +0 -58
  345. package/src/jsonForm/chooseControl.ts +0 -88
  346. package/src/jsonForm/evaluateWhen.ts +0 -59
  347. package/src/jsonForm/index.ts +0 -32
  348. package/src/jsonForm/inferSchema.ts +0 -25
  349. package/src/jsonForm/pointer.ts +0 -154
  350. package/src/jsonForm/tokens.ts +0 -78
  351. package/src/jsonForm/types.ts +0 -167
  352. package/src/markdown/annotationCoercion.ts +0 -295
  353. package/src/markdown/attrTokens.ts +0 -243
  354. package/src/markdown/convert.ts +0 -1353
  355. package/src/markdown/htmlParse.ts +0 -212
  356. package/src/markdown/index.ts +0 -152
  357. package/src/markdown/parse.ts +0 -103
  358. package/src/markdown/sanitize.ts +0 -318
  359. package/src/markdown/stringify.ts +0 -207
  360. package/src/markdown/types.ts +0 -710
  361. package/src/markdown/utils.ts +0 -459
  362. package/src/narration/align.ts +0 -514
  363. package/src/narration/features.ts +0 -231
  364. package/src/narration/index.ts +0 -86
  365. package/src/narration/nuclei.ts +0 -118
  366. package/src/narration/pacing.ts +0 -211
  367. package/src/narration/script.ts +0 -239
  368. package/src/narration/session.ts +0 -100
  369. package/src/narration/sidecar.ts +0 -187
  370. package/src/narration/syllables.ts +0 -85
  371. package/src/narration/trace.ts +0 -50
  372. package/src/narration/types.ts +0 -299
  373. package/src/narration/vad.ts +0 -131
  374. package/src/ngeohash.d.ts +0 -11
  375. package/src/random/SeededRandom.ts +0 -127
  376. package/src/random/index.ts +0 -1
  377. package/src/recommend/index.ts +0 -16
  378. package/src/recommend/numberHighlight.ts +0 -25
  379. package/src/recommend/templates.ts +0 -393
  380. package/src/schemas/BlockTemplates.ts +0 -1046
  381. package/src/schemas/CustomTemplates.ts +0 -126
  382. package/src/schemas/Doc.ts +0 -1073
  383. package/src/schemas/ImageEditDoc.ts +0 -102
  384. package/src/schemas/LayoutStrategy.ts +0 -178
  385. package/src/schemas/Media.ts +0 -179
  386. package/src/schemas/MediaProvider.ts +0 -70
  387. package/src/schemas/PageStyle.ts +0 -213
  388. package/src/schemas/Theme.ts +0 -413
  389. package/src/schemas/Transitions.ts +0 -224
  390. package/src/schemas/Types.ts +0 -15
  391. package/src/schemas/Viewport.ts +0 -91
  392. package/src/schemas/colorUtils.ts +0 -219
  393. package/src/schemas/fontStacks.ts +0 -339
  394. package/src/schemas/index.ts +0 -31
  395. package/src/schemas/pageStyleDefaults.ts +0 -204
  396. package/src/schemas/themeCompile.ts +0 -244
  397. package/src/schemas/themeConstants.ts +0 -2
  398. package/src/schemas/themeLibrary.ts +0 -60
  399. package/src/schemas/themeValidator.ts +0 -609
  400. package/src/schemas/themes/bold.json +0 -77
  401. package/src/schemas/themes/cinematic.json +0 -143
  402. package/src/schemas/themes/documentary.json +0 -125
  403. package/src/schemas/themes/gezellig.json +0 -123
  404. package/src/schemas/themes/index.ts +0 -53
  405. package/src/schemas/themes/magazine.json +0 -126
  406. package/src/schemas/themes/minimalist.json +0 -74
  407. package/src/schemas/themes/morning-light.json +0 -117
  408. package/src/schemas/themes/standard-dark.json +0 -109
  409. package/src/schemas/themes/standard.json +0 -98
  410. package/src/schemas/themes/tech-dark.json +0 -143
  411. package/src/schemas/themes/warm-earth.json +0 -74
  412. package/src/spatial/Geohash.ts +0 -196
  413. package/src/spatial/Haversine.ts +0 -59
  414. package/src/spatial/index.ts +0 -2
  415. package/src/storage/ContentContainer.ts +0 -220
  416. package/src/storage/LocalForageAdapter.ts +0 -103
  417. package/src/storage/LocalStorageAdapter.ts +0 -57
  418. package/src/storage/MediaProviderFromContainer.ts +0 -92
  419. package/src/storage/MemoryStorageAdapter.ts +0 -37
  420. package/src/storage/ScopedContentContainer.ts +0 -143
  421. package/src/storage/Storage.ts +0 -28
  422. package/src/storage/index.ts +0 -9
  423. package/src/timing/index.ts +0 -17
  424. package/src/timing/narrationTiming.ts +0 -220
  425. package/src/timing/readingTime.ts +0 -94
  426. package/src/transform/applyTransform.ts +0 -122
  427. package/src/transform/blockAnalyzer.ts +0 -181
  428. package/src/transform/index.ts +0 -23
  429. package/src/transform/registry.ts +0 -217
  430. package/src/transform/styles/dataDriven.ts +0 -18
  431. package/src/transform/styles/documentary.ts +0 -18
  432. package/src/transform/styles/index.ts +0 -5
  433. package/src/transform/styles/magazine.ts +0 -19
  434. package/src/transform/styles/minimal.ts +0 -18
  435. package/src/transform/styles/narrative.ts +0 -19
  436. package/src/transform/templateSelector.ts +0 -389
  437. package/src/transform/timingAllocator.ts +0 -257
  438. package/src/transform/types.ts +0 -158
  439. package/src/versions/DocumentVersionManager.ts +0 -70
  440. package/src/versions/gitignore.ts +0 -34
  441. package/src/versions/index.ts +0 -56
  442. package/src/versions/operations.ts +0 -144
  443. package/src/versions/paths.ts +0 -51
  444. package/src/versions/snapshotStore.ts +0 -202
  445. package/src/versions/timestamp.ts +0 -48
  446. package/src/versions/types.ts +0 -93
@@ -1,1009 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import {
3
- parseMarkdown,
4
- stringifyMarkdown,
5
- parseHtmlToNodes,
6
- stringifyHtmlNodes,
7
- getChildren,
8
- walkMarkdownTree,
9
- findNodesByType,
10
- extractPlainText,
11
- countNodes,
12
- createDocument,
13
- parseFrontmatter,
14
- setFrontmatterValues,
15
- plainTextFromInlineHtml,
16
- } from '../markdown/index';
17
- import type {
18
- MarkdownDocument,
19
- MarkdownHeading,
20
- MarkdownParagraph,
21
- MarkdownList,
22
- MarkdownListItem,
23
- MarkdownCodeBlock,
24
- MarkdownTable,
25
- MarkdownBlockquote,
26
- MarkdownLink,
27
- MarkdownImage,
28
- MarkdownHtmlBlock,
29
- MarkdownMathBlock,
30
- MarkdownInlineMath,
31
- MarkdownStrikethrough,
32
- MarkdownFootnoteDefinition,
33
- MarkdownFootnoteReference,
34
- MarkdownLinkDefinition,
35
- MarkdownLinkReference,
36
- MarkdownImageReference,
37
- MarkdownText,
38
- MarkdownMention,
39
- } from '../markdown/index';
40
-
41
- // ============================================
42
- // Helper: strip positions for cleaner assertions
43
- // ============================================
44
-
45
- function stripPositions(obj: unknown): unknown {
46
- if (obj === null || obj === undefined) return obj;
47
- if (typeof obj !== 'object') return obj;
48
- if (Array.isArray(obj)) return obj.map(stripPositions);
49
-
50
- const result: Record<string, unknown> = {};
51
- for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {
52
- if (key === 'position') continue;
53
- result[key] = stripPositions(value);
54
- }
55
- return result;
56
- }
57
-
58
- /**
59
- * Parse, strip positions, and return the tree.
60
- */
61
- function parse(md: string) {
62
- return stripPositions(parseMarkdown(md)) as MarkdownDocument;
63
- }
64
-
65
- // ============================================
66
- // CommonMark Basics
67
- // ============================================
68
-
69
- describe('parseMarkdown / stringifyMarkdown', () => {
70
- describe('CommonMark basics', () => {
71
- it('parses headings', () => {
72
- const doc = parse('# H1\n\n## H2\n\n### H3');
73
- expect(doc.children).toHaveLength(3);
74
-
75
- const h1 = doc.children[0] as MarkdownHeading;
76
- expect(h1.type).toBe('heading');
77
- expect(h1.depth).toBe(1);
78
- expect(h1.children[0]).toEqual({ type: 'text', value: 'H1' });
79
-
80
- const h2 = doc.children[1] as MarkdownHeading;
81
- expect(h2.depth).toBe(2);
82
-
83
- const h3 = doc.children[2] as MarkdownHeading;
84
- expect(h3.depth).toBe(3);
85
- });
86
-
87
- it('parses paragraphs with inline formatting', () => {
88
- const doc = parse('Hello **bold** and *italic* text');
89
- const p = doc.children[0] as MarkdownParagraph;
90
- expect(p.type).toBe('paragraph');
91
- expect(p.children).toHaveLength(5);
92
- expect(p.children[0]).toEqual({ type: 'text', value: 'Hello ' });
93
- expect(p.children[1]).toEqual({
94
- type: 'strong',
95
- children: [{ type: 'text', value: 'bold' }],
96
- });
97
- expect(p.children[2]).toEqual({ type: 'text', value: ' and ' });
98
- expect(p.children[3]).toEqual({
99
- type: 'emphasis',
100
- children: [{ type: 'text', value: 'italic' }],
101
- });
102
- expect(p.children[4]).toEqual({ type: 'text', value: ' text' });
103
- });
104
-
105
- it('parses unordered lists', () => {
106
- const doc = parse('- Item 1\n- Item 2\n- Item 3');
107
- const list = doc.children[0] as MarkdownList;
108
- expect(list.type).toBe('list');
109
- expect(list.ordered).toBe(false);
110
- expect(list.children).toHaveLength(3);
111
-
112
- const item = list.children[0] as MarkdownListItem;
113
- expect(item.type).toBe('listItem');
114
- const itemP = item.children[0] as MarkdownParagraph;
115
- expect(itemP.children[0]).toEqual({ type: 'text', value: 'Item 1' });
116
- });
117
-
118
- it('parses ordered lists', () => {
119
- const doc = parse('1. First\n2. Second\n3. Third');
120
- const list = doc.children[0] as MarkdownList;
121
- expect(list.ordered).toBe(true);
122
- expect(list.start).toBe(1);
123
- expect(list.children).toHaveLength(3);
124
- });
125
-
126
- it('parses code blocks', () => {
127
- const doc = parse('```typescript\nconst x = 1;\n```');
128
- const code = doc.children[0] as MarkdownCodeBlock;
129
- expect(code.type).toBe('code');
130
- expect(code.lang).toBe('typescript');
131
- expect(code.value).toBe('const x = 1;');
132
- });
133
-
134
- it('parses blockquotes', () => {
135
- const doc = parse('> This is a quote\n>\n> With two paragraphs');
136
- const bq = doc.children[0] as MarkdownBlockquote;
137
- expect(bq.type).toBe('blockquote');
138
- expect(bq.children).toHaveLength(2);
139
- });
140
-
141
- it('parses inline code', () => {
142
- const doc = parse('Use `console.log()` for debugging');
143
- const p = doc.children[0] as MarkdownParagraph;
144
- expect(p.children[1]).toEqual({ type: 'inlineCode', value: 'console.log()' });
145
- });
146
-
147
- it('parses links', () => {
148
- const doc = parse('[Click here](https://example.com "Title")');
149
- const p = doc.children[0] as MarkdownParagraph;
150
- const link = p.children[0] as MarkdownLink;
151
- expect(link.type).toBe('link');
152
- expect(link.url).toBe('https://example.com');
153
- expect(link.title).toBe('Title');
154
- expect(link.children[0]).toEqual({ type: 'text', value: 'Click here' });
155
- });
156
-
157
- it('parses mentions from @[Name](scheme:id)', () => {
158
- const doc = parse('Hey @[Leo](person:leo), take a look.');
159
- const p = doc.children[0] as MarkdownParagraph;
160
- const text0 = p.children[0] as MarkdownText;
161
- expect(text0).toEqual({ type: 'text', value: 'Hey ' });
162
- const mention = p.children[1] as MarkdownMention;
163
- expect(mention).toEqual({
164
- type: 'mention',
165
- targetKind: 'person',
166
- targetId: 'leo',
167
- displayName: 'Leo',
168
- });
169
- const text2 = p.children[2] as MarkdownText;
170
- expect(text2.value).toBe(', take a look.');
171
- });
172
-
173
- it('round-trips a mention back to markdown', () => {
174
- // remark-stringify escapes `:` in link URLs that follow an `@` (to
175
- // disambiguate from autolink syntax). The escape is idempotent —
176
- // re-parsing `\:` produces the unescaped url, so the round-trip
177
- // preserves the mention semantically even if the raw text changes
178
- // on the first pass.
179
- const input = 'Hey @[Leo](person:leo), ping @[Tess](person:tess) too.\n';
180
- const once = stringifyMarkdown(parseMarkdown(input));
181
- const twice = stringifyMarkdown(parseMarkdown(once));
182
- expect(twice).toBe(once);
183
- // Semantics are preserved: re-parsing yields mentions.
184
- const doc = parseMarkdown(once) as MarkdownDocument;
185
- const p = doc.children[0] as MarkdownParagraph;
186
- const m1 = p.children.find((c) => c.type === 'mention') as MarkdownMention;
187
- expect(m1.targetKind).toBe('person');
188
- expect(m1.targetId).toBe('leo');
189
- expect(m1.displayName).toBe('Leo');
190
- });
191
-
192
- it('does not collapse @ + link when the url has no scheme', () => {
193
- const doc = parse('Cost @[100]($100)');
194
- const p = doc.children[0] as MarkdownParagraph;
195
- // "$100" doesn't match scheme:id because $ isn't a scheme character
196
- // → stays as text("Cost @") + link
197
- expect((p.children[1] as MarkdownLink).type).toBe('link');
198
- });
199
-
200
- it('parses images', () => {
201
- const doc = parse('![Alt text](image.png "Image title")');
202
- const p = doc.children[0] as MarkdownParagraph;
203
- const img = p.children[0] as MarkdownImage;
204
- expect(img.type).toBe('image');
205
- expect(img.url).toBe('image.png');
206
- expect(img.alt).toBe('Alt text');
207
- expect(img.title).toBe('Image title');
208
- });
209
-
210
- it('parses thematic breaks', () => {
211
- const doc = parse('Before\n\n---\n\nAfter');
212
- expect(doc.children).toHaveLength(3);
213
- expect(doc.children[1].type).toBe('thematicBreak');
214
- });
215
-
216
- it('parses hard line breaks', () => {
217
- const doc = parse('Line one \nLine two');
218
- const p = doc.children[0] as MarkdownParagraph;
219
- expect(p.children).toHaveLength(3);
220
- expect(p.children[1].type).toBe('break');
221
- });
222
- });
223
-
224
- // ============================================
225
- // GFM Extensions
226
- // ============================================
227
-
228
- describe('GFM extensions', () => {
229
- it('parses tables', () => {
230
- const md = '| Name | Age |\n| --- | --- |\n| Alice | 30 |\n| Bob | 25 |';
231
- const doc = parse(md);
232
- const table = doc.children[0] as MarkdownTable;
233
- expect(table.type).toBe('table');
234
- expect(table.children).toHaveLength(3); // header + 2 data rows
235
-
236
- // Header row
237
- const headerRow = table.children[0];
238
- expect(headerRow.children[0].isHeader).toBe(true);
239
- expect(headerRow.children[0].children[0]).toEqual({ type: 'text', value: 'Name' });
240
-
241
- // Data row
242
- const dataRow = table.children[1];
243
- expect(dataRow.children[0].isHeader).toBeUndefined();
244
- });
245
-
246
- it('parses strikethrough', () => {
247
- const doc = parse('This is ~~deleted~~ text');
248
- const p = doc.children[0] as MarkdownParagraph;
249
- const del = p.children[1] as MarkdownStrikethrough;
250
- expect(del.type).toBe('delete');
251
- expect(del.children[0]).toEqual({ type: 'text', value: 'deleted' });
252
- });
253
-
254
- it('parses task lists', () => {
255
- const doc = parse('- [x] Done\n- [ ] Todo\n- Regular');
256
- const list = doc.children[0] as MarkdownList;
257
- expect(list.children[0].checked).toBe(true);
258
- expect(list.children[1].checked).toBe(false);
259
- // Regular item has no checked property
260
- expect(list.children[2].checked).toBeUndefined();
261
- });
262
-
263
- it('parses footnotes', () => {
264
- const md = 'Text with a footnote[^1].\n\n[^1]: This is the footnote content.';
265
- const doc = parse(md);
266
-
267
- // Find footnote reference in the paragraph
268
- const p = doc.children[0] as MarkdownParagraph;
269
- const ref = p.children.find(
270
- (c) => c.type === 'footnoteReference',
271
- ) as MarkdownFootnoteReference;
272
- expect(ref).toBeDefined();
273
- expect(ref.identifier).toBe('1');
274
-
275
- // Find footnote definition
276
- const fnDef = doc.children.find(
277
- (c) => c.type === 'footnoteDefinition',
278
- ) as MarkdownFootnoteDefinition;
279
- expect(fnDef).toBeDefined();
280
- expect(fnDef.identifier).toBe('1');
281
- });
282
- });
283
-
284
- // ============================================
285
- // Math Extensions
286
- // ============================================
287
-
288
- describe('Math extensions', () => {
289
- it('parses inline math', () => {
290
- const doc = parse('The equation $E = mc^2$ is famous');
291
- const p = doc.children[0] as MarkdownParagraph;
292
- const math = p.children.find((c) => c.type === 'inlineMath') as MarkdownInlineMath;
293
- expect(math).toBeDefined();
294
- expect(math.value).toBe('E = mc^2');
295
- });
296
-
297
- it('parses display math blocks', () => {
298
- const doc = parse('$$\nx = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}\n$$');
299
- const math = doc.children[0] as MarkdownMathBlock;
300
- expect(math.type).toBe('math');
301
- expect(math.value).toContain('\\frac{-b');
302
- });
303
- });
304
-
305
- // ============================================
306
- // Link/Image References
307
- // ============================================
308
-
309
- describe('Reference links', () => {
310
- it('parses link reference definitions', () => {
311
- const md = '[example]: https://example.com "Example"\n\nSee [example].';
312
- const doc = parse(md);
313
-
314
- const def = doc.children.find((c) => c.type === 'definition') as MarkdownLinkDefinition;
315
- expect(def).toBeDefined();
316
- expect(def.identifier).toBe('example');
317
- expect(def.url).toBe('https://example.com');
318
- expect(def.title).toBe('Example');
319
- });
320
-
321
- it('parses link references', () => {
322
- const md = '[Click here][ref]\n\n[ref]: https://example.com';
323
- const doc = parse(md);
324
- const p = doc.children[0] as MarkdownParagraph;
325
- const ref = p.children[0] as MarkdownLinkReference;
326
- expect(ref.type).toBe('linkReference');
327
- expect(ref.identifier).toBe('ref');
328
- expect(ref.referenceType).toBe('full');
329
- });
330
-
331
- it('parses image references', () => {
332
- const md = '![Alt text][img]\n\n[img]: image.png';
333
- const doc = parse(md);
334
- const p = doc.children[0] as MarkdownParagraph;
335
- const ref = p.children[0] as MarkdownImageReference;
336
- expect(ref.type).toBe('imageReference');
337
- expect(ref.identifier).toBe('img');
338
- });
339
- });
340
-
341
- // ============================================
342
- // HTML Handling
343
- // ============================================
344
-
345
- describe('HTML handling', () => {
346
- it('parses block-level HTML', () => {
347
- const doc = parse('<div class="container">\n <p>Hello</p>\n</div>');
348
- const html = doc.children[0] as MarkdownHtmlBlock;
349
- expect(html.type).toBe('htmlBlock');
350
- expect(html.rawHtml).toContain('<div');
351
- expect(html.htmlChildren.length).toBeGreaterThan(0);
352
- });
353
-
354
- it('parses inline HTML', () => {
355
- const doc = parse('Text with <em>emphasis</em> inline');
356
- const p = doc.children[0] as MarkdownParagraph;
357
- const htmlNodes = p.children.filter((c) => c.type === 'htmlInline');
358
- expect(htmlNodes.length).toBeGreaterThan(0);
359
- });
360
-
361
- it('preserves rawHtml for round-tripping', () => {
362
- const input = '<div class="test">content</div>';
363
- const doc = parse(input);
364
- const html = doc.children[0] as MarkdownHtmlBlock;
365
- expect(html.rawHtml).toBe(input);
366
- });
367
- });
368
-
369
- // ============================================
370
- // Nested Structures
371
- // ============================================
372
-
373
- describe('Nested structures', () => {
374
- it('handles blockquote containing list', () => {
375
- const md = '> - Item 1\n> - Item 2';
376
- const doc = parse(md);
377
- const bq = doc.children[0] as MarkdownBlockquote;
378
- expect(bq.type).toBe('blockquote');
379
- const list = bq.children[0] as MarkdownList;
380
- expect(list.type).toBe('list');
381
- expect(list.children).toHaveLength(2);
382
- });
383
-
384
- it('handles nested lists', () => {
385
- const md = '- Outer\n - Inner 1\n - Inner 2';
386
- const doc = parse(md);
387
- const outerList = doc.children[0] as MarkdownList;
388
- const firstItem = outerList.children[0];
389
- // First item should have a paragraph and a nested list
390
- expect(firstItem.children.length).toBeGreaterThanOrEqual(2);
391
- const nestedList = firstItem.children.find((c) => c.type === 'list') as MarkdownList;
392
- expect(nestedList).toBeDefined();
393
- expect(nestedList.children).toHaveLength(2);
394
- });
395
-
396
- it('handles emphasis inside links', () => {
397
- const md = '[**Bold link**](https://example.com)';
398
- const doc = parse(md);
399
- const p = doc.children[0] as MarkdownParagraph;
400
- const link = p.children[0] as MarkdownLink;
401
- expect(link.type).toBe('link');
402
- expect(link.children[0].type).toBe('strong');
403
- });
404
- });
405
-
406
- // ============================================
407
- // Round-Trip Tests
408
- // ============================================
409
-
410
- describe('Round-trip (parse → stringify → parse)', () => {
411
- function roundTrip(md: string): void {
412
- const doc1 = parseMarkdown(md);
413
- const output = stringifyMarkdown(doc1);
414
- const doc2 = parseMarkdown(output);
415
-
416
- // Strip positions before comparing (positions will differ between parse runs)
417
- expect(stripPositions(doc2)).toEqual(stripPositions(doc1));
418
- }
419
-
420
- it('round-trips headings', () => {
421
- roundTrip('# Heading 1\n\n## Heading 2\n\n### Heading 3\n');
422
- });
423
-
424
- it('round-trips paragraphs with inline formatting', () => {
425
- roundTrip('Hello **bold** and *italic* text\n');
426
- });
427
-
428
- it('round-trips unordered lists', () => {
429
- roundTrip('- Item 1\n- Item 2\n- Item 3\n');
430
- });
431
-
432
- it('round-trips ordered lists', () => {
433
- roundTrip('1. First\n2. Second\n3. Third\n');
434
- });
435
-
436
- it('round-trips code blocks', () => {
437
- roundTrip('```js\nconst x = 1;\n```\n');
438
- });
439
-
440
- it('round-trips blockquotes', () => {
441
- roundTrip('> A quote\n>\n> Second paragraph\n');
442
- });
443
-
444
- it('round-trips links and images', () => {
445
- roundTrip('[Link](https://example.com)\n');
446
- roundTrip('![Alt](image.png)\n');
447
- });
448
-
449
- it('round-trips thematic breaks', () => {
450
- roundTrip('---\n');
451
- });
452
-
453
- it('round-trips tables', () => {
454
- roundTrip('| A | B |\n| - | - |\n| 1 | 2 |\n');
455
- });
456
-
457
- it('round-trips task lists', () => {
458
- roundTrip('- [x] Done\n- [ ] Todo\n');
459
- });
460
-
461
- it('round-trips inline math', () => {
462
- roundTrip('The formula $E = mc^2$ is famous.\n');
463
- });
464
-
465
- it('round-trips display math', () => {
466
- roundTrip('$$\nx^2 + y^2 = z^2\n$$\n');
467
- });
468
-
469
- it('round-trips strikethrough', () => {
470
- roundTrip('This is ~~deleted~~ text.\n');
471
- });
472
- });
473
-
474
- // ============================================
475
- // Edge Cases
476
- // ============================================
477
-
478
- describe('Edge cases', () => {
479
- it('handles empty document', () => {
480
- const doc = parse('');
481
- expect(doc.type).toBe('document');
482
- expect(doc.children).toHaveLength(0);
483
- });
484
-
485
- it('handles single text paragraph', () => {
486
- const doc = parse('Hello');
487
- expect(doc.children).toHaveLength(1);
488
- const p = doc.children[0] as MarkdownParagraph;
489
- expect(p.type).toBe('paragraph');
490
- expect(p.children[0]).toEqual({ type: 'text', value: 'Hello' });
491
- });
492
-
493
- it('handles deeply nested blockquotes', () => {
494
- const doc = parse('> > > Deep');
495
- expect(doc.children[0].type).toBe('blockquote');
496
- const bq1 = doc.children[0] as MarkdownBlockquote;
497
- const bq2 = bq1.children[0] as MarkdownBlockquote;
498
- const bq3 = bq2.children[0] as MarkdownBlockquote;
499
- expect(bq3.type).toBe('blockquote');
500
- });
501
-
502
- it('preserves source positions when parsing', () => {
503
- const doc = parseMarkdown('# Hello\n\nWorld');
504
- expect(doc.position).toBeDefined();
505
- expect(doc.children[0].position).toBeDefined();
506
- expect(doc.children[0].position!.start.line).toBe(1);
507
- expect(doc.children[1].position!.start.line).toBe(3);
508
- });
509
-
510
- it('handles parseHtml: false option', () => {
511
- const doc = parseMarkdown('<div>content</div>', { parseHtml: false });
512
- const html = doc.children[0] as MarkdownHtmlBlock;
513
- expect(html.rawHtml).toBe('<div>content</div>');
514
- expect(html.htmlChildren).toEqual([]);
515
- });
516
- });
517
- });
518
-
519
- // ============================================
520
- // HTML Sub-DOM Tests
521
- // ============================================
522
-
523
- describe('HTML sub-DOM (parseHtmlToNodes / stringifyHtmlNodes)', () => {
524
- it('parses a simple element', () => {
525
- const nodes = parseHtmlToNodes('<b>bold</b>');
526
- expect(nodes).toHaveLength(1);
527
- expect(nodes[0].type).toBe('htmlElement');
528
- const el = nodes[0] as import('../markdown/types').HtmlElement;
529
- expect(el.tagName).toBe('b');
530
- expect(el.children).toHaveLength(1);
531
- expect(el.children[0]).toEqual({ type: 'htmlText', value: 'bold' });
532
- });
533
-
534
- it('parses attributes', () => {
535
- const nodes = parseHtmlToNodes('<div class="foo" id="bar">content</div>');
536
- const el = nodes[0] as import('../markdown/types').HtmlElement;
537
- expect(el.attributes.class).toBe('foo');
538
- expect(el.attributes.id).toBe('bar');
539
- });
540
-
541
- it('handles self-closing elements', () => {
542
- const nodes = parseHtmlToNodes('<br>');
543
- const el = nodes[0] as import('../markdown/types').HtmlElement;
544
- expect(el.tagName).toBe('br');
545
- expect(el.selfClosing).toBe(true);
546
- });
547
-
548
- it('handles nested elements', () => {
549
- const nodes = parseHtmlToNodes('<div><span>inner</span></div>');
550
- const outer = nodes[0] as import('../markdown/types').HtmlElement;
551
- expect(outer.tagName).toBe('div');
552
- const inner = outer.children[0] as import('../markdown/types').HtmlElement;
553
- expect(inner.tagName).toBe('span');
554
- expect(inner.children[0]).toEqual({ type: 'htmlText', value: 'inner' });
555
- });
556
-
557
- it('handles empty input', () => {
558
- expect(parseHtmlToNodes('')).toEqual([]);
559
- expect(parseHtmlToNodes(' ')).toEqual([]);
560
- });
561
-
562
- it('stringifies nodes back to HTML', () => {
563
- const nodes = parseHtmlToNodes('<b>bold</b>');
564
- const html = stringifyHtmlNodes(nodes);
565
- expect(html).toBe('<b>bold</b>');
566
- });
567
-
568
- it('stringifies void elements', () => {
569
- const nodes = parseHtmlToNodes('<br>');
570
- const html = stringifyHtmlNodes(nodes);
571
- expect(html).toBe('<br>');
572
- });
573
- });
574
-
575
- // ============================================
576
- // Tree Utility Tests
577
- // ============================================
578
-
579
- describe('Tree utilities', () => {
580
- const doc: MarkdownDocument = {
581
- type: 'document',
582
- children: [
583
- {
584
- type: 'heading',
585
- depth: 1,
586
- children: [{ type: 'text', value: 'Title' }],
587
- },
588
- {
589
- type: 'paragraph',
590
- children: [
591
- { type: 'text', value: 'Hello ' },
592
- {
593
- type: 'link',
594
- url: 'https://example.com',
595
- children: [{ type: 'text', value: 'world' }],
596
- },
597
- ],
598
- },
599
- ],
600
- };
601
-
602
- it('getChildren returns children for parent nodes', () => {
603
- expect(getChildren(doc)).toEqual(doc.children);
604
- });
605
-
606
- it('getChildren returns empty array for leaf nodes', () => {
607
- expect(getChildren({ type: 'text', value: 'hi' })).toEqual([]);
608
- });
609
-
610
- it('walkMarkdownTree visits all nodes', () => {
611
- const types: string[] = [];
612
- walkMarkdownTree(doc, (node) => {
613
- types.push(node.type);
614
- });
615
- expect(types).toEqual(['document', 'heading', 'text', 'paragraph', 'text', 'link', 'text']);
616
- });
617
-
618
- it('walkMarkdownTree supports pruning', () => {
619
- const types: string[] = [];
620
- walkMarkdownTree(doc, (node) => {
621
- types.push(node.type);
622
- if (node.type === 'paragraph') return true; // skip children
623
- });
624
- expect(types).toEqual(['document', 'heading', 'text', 'paragraph']);
625
- });
626
-
627
- it('findNodesByType finds matching nodes', () => {
628
- const headings = findNodesByType<MarkdownHeading>(doc, 'heading');
629
- expect(headings).toHaveLength(1);
630
- expect(headings[0].depth).toBe(1);
631
-
632
- const texts = findNodesByType(doc, 'text');
633
- expect(texts).toHaveLength(3);
634
- });
635
-
636
- it('extractPlainText extracts all text', () => {
637
- expect(extractPlainText(doc)).toBe('TitleHello world');
638
- });
639
-
640
- it('extractPlainText preserves list item boundaries', () => {
641
- const list: MarkdownList = {
642
- type: 'list',
643
- ordered: false,
644
- children: [
645
- {
646
- type: 'listItem',
647
- children: [{ type: 'paragraph', children: [{ type: 'text', value: 'Apple' }] }],
648
- },
649
- {
650
- type: 'listItem',
651
- children: [{ type: 'paragraph', children: [{ type: 'text', value: 'Banana' }] }],
652
- },
653
- {
654
- type: 'listItem',
655
- children: [{ type: 'paragraph', children: [{ type: 'text', value: 'Cherry' }] }],
656
- },
657
- ],
658
- };
659
- expect(extractPlainText(list)).toBe('Apple\nBanana\nCherry');
660
- });
661
-
662
- it('countNodes counts all nodes', () => {
663
- expect(countNodes(doc)).toBe(7); // document + heading + text + paragraph + text + link + text
664
- });
665
-
666
- it('createDocument creates a minimal document', () => {
667
- const d = createDocument({ type: 'paragraph', children: [{ type: 'text', value: 'Hello' }] });
668
- expect(d.type).toBe('document');
669
- expect(d.children).toHaveLength(1);
670
- });
671
- });
672
-
673
- // ============================================
674
- // AST Stability Test
675
- // ============================================
676
-
677
- describe('AST stability', () => {
678
- it('parse(stringify(parse(input))) === parse(input)', () => {
679
- const input = `# Hello World
680
-
681
- This is a **bold** and *italic* paragraph with \`code\`.
682
-
683
- - Item 1
684
- - Item 2
685
- - Nested
686
-
687
- > A blockquote
688
-
689
- \`\`\`js
690
- const x = 1;
691
- \`\`\`
692
-
693
- | A | B |
694
- | - | - |
695
- | 1 | 2 |
696
-
697
- ---
698
-
699
- [Link](https://example.com)
700
-
701
- ![Image](image.png)
702
- `;
703
-
704
- const doc1 = parseMarkdown(input);
705
- const output = stringifyMarkdown(doc1);
706
- const doc2 = parseMarkdown(output);
707
- const output2 = stringifyMarkdown(doc2);
708
- const doc3 = parseMarkdown(output2);
709
-
710
- // After one round-trip, the AST should be stable
711
- expect(stripPositions(doc3)).toEqual(stripPositions(doc2));
712
- });
713
- });
714
-
715
- // ============================================
716
- // Template Annotation on Headings
717
- // ============================================
718
-
719
- describe('heading template annotation', () => {
720
- it('parses {[templateName]} from heading text', () => {
721
- const doc = parseMarkdown('### Report Data {[chart]}');
722
- const heading = doc.children[0] as MarkdownHeading;
723
-
724
- expect(heading.type).toBe('heading');
725
- expect(heading.depth).toBe(3);
726
- expect(heading.templateAnnotation).toEqual({ template: 'chart' });
727
- // The annotation text should be stripped from children
728
- expect(heading.children).toHaveLength(1);
729
- expect(heading.children[0].type).toBe('text');
730
- expect((heading.children[0] as MarkdownText).value).toBe('Report Data');
731
- });
732
-
733
- it('parses template name with key=value params', () => {
734
- const doc = parseMarkdown('## Data {[statHighlight colorScheme=blue size=large]}');
735
- const heading = doc.children[0] as MarkdownHeading;
736
-
737
- expect(heading.templateAnnotation).toEqual({
738
- template: 'statHighlight',
739
- params: { colorScheme: 'blue', size: 'large' },
740
- });
741
- expect((heading.children[0] as MarkdownText).value).toBe('Data');
742
- });
743
-
744
- it('returns no annotation for plain headings', () => {
745
- const doc = parseMarkdown('# Just a title');
746
- const heading = doc.children[0] as MarkdownHeading;
747
-
748
- expect(heading.templateAnnotation).toBeUndefined();
749
- expect((heading.children[0] as MarkdownText).value).toBe('Just a title');
750
- });
751
-
752
- it('does not match incomplete bracket syntax', () => {
753
- const doc = parseMarkdown('## Title {chart}');
754
- const heading = doc.children[0] as MarkdownHeading;
755
-
756
- // Regular curly braces should not trigger annotation parsing
757
- expect(heading.templateAnnotation).toBeUndefined();
758
- });
759
-
760
- it('does not match {[...]} in the middle of heading text', () => {
761
- // The annotation must be trailing
762
- const doc = parseMarkdown('## The {[chart]} section');
763
- const heading = doc.children[0] as MarkdownHeading;
764
-
765
- // remark may split this into multiple text nodes or keep as one;
766
- // either way, no trailing annotation should be extracted
767
- expect(heading.templateAnnotation).toBeUndefined();
768
- });
769
-
770
- it('round-trips annotation through parse → stringify → parse', () => {
771
- const input = '### My Section {[factCard colorScheme=warm]}';
772
- const doc1 = parseMarkdown(input);
773
- const output = stringifyMarkdown(doc1);
774
- const doc2 = parseMarkdown(output);
775
-
776
- const h1 = doc1.children[0] as MarkdownHeading;
777
- const h2 = doc2.children[0] as MarkdownHeading;
778
-
779
- expect(h2.templateAnnotation).toEqual(h1.templateAnnotation);
780
- expect(stripPositions(h2.children)).toEqual(stripPositions(h1.children));
781
- });
782
-
783
- it('handles heading with only annotation (no display text)', () => {
784
- const doc = parseMarkdown('## {[chart]}');
785
- const heading = doc.children[0] as MarkdownHeading;
786
-
787
- expect(heading.templateAnnotation).toEqual({ template: 'chart' });
788
- // Children should be empty after stripping the annotation
789
- expect(heading.children).toHaveLength(0);
790
- });
791
-
792
- it('handles heading with bold text before annotation', () => {
793
- const doc = parseMarkdown('## **Bold Title** {[quoteBlock]}');
794
- const heading = doc.children[0] as MarkdownHeading;
795
-
796
- expect(heading.templateAnnotation).toEqual({ template: 'quoteBlock' });
797
- // The bold node should remain, trailing text stripped
798
- const types = heading.children.map((c) => c.type);
799
- expect(types).toContain('strong');
800
- });
801
-
802
- it('preserves annotation through stringify', () => {
803
- const input = '## Section {[chart]}';
804
- const doc = parseMarkdown(input);
805
- const output = stringifyMarkdown(doc);
806
-
807
- // Output should contain the annotation
808
- expect(output).toContain('{[chart]}');
809
- // The heading text should be there too
810
- expect(output).toContain('Section');
811
- });
812
- });
813
-
814
- // ============================================
815
- // YAML Frontmatter
816
- // ============================================
817
-
818
- describe('parseFrontmatter', () => {
819
- it('parses simple key-value pairs', () => {
820
- const result = parseFrontmatter('title: My Doc\nauthor: Jane');
821
- expect(result).toEqual({ title: 'My Doc', author: 'Jane' });
822
- });
823
-
824
- it('parses booleans and numbers', () => {
825
- const result = parseFrontmatter('draft: true\ncount: 42\nratio: 3.14');
826
- expect(result).toEqual({ draft: true, count: 42, ratio: 3.14 });
827
- });
828
-
829
- it('strips surrounding quotes', () => {
830
- const result = parseFrontmatter('title: "Hello World"\nname: \'Jane\'');
831
- expect(result).toEqual({ title: 'Hello World', name: 'Jane' });
832
- });
833
-
834
- it('keeps quoted booleans and numbers as strings and decodes escapes', () => {
835
- const result = parseFrontmatter(String.raw`boolean: "true"
836
- number: "1e3"
837
- path: "C:\\temp\\\"quoted\""
838
- single: 'it''s'`);
839
- expect(result).toEqual({
840
- boolean: 'true',
841
- number: '1e3',
842
- path: 'C:\\temp\\"quoted"',
843
- single: "it's",
844
- });
845
- });
846
-
847
- it('skips comment lines and blank lines', () => {
848
- const result = parseFrontmatter('# comment\n\ntitle: Test');
849
- expect(result).toEqual({ title: 'Test' });
850
- });
851
-
852
- it('returns null for empty input', () => {
853
- expect(parseFrontmatter('')).toBeNull();
854
- expect(parseFrontmatter(' \n ')).toBeNull();
855
- });
856
-
857
- it('parses a `|-` literal block scalar, dedenting the body', () => {
858
- const result = parseFrontmatter('data: |-\n line one\n line two\ntitle: After');
859
- expect(result).toEqual({ data: 'line one\nline two', title: 'After' });
860
- });
861
-
862
- it('parses a `|` literal block scalar (same joined value here)', () => {
863
- const result = parseFrontmatter('data: |\n a\n b');
864
- expect(result).toEqual({ data: 'a\nb' });
865
- });
866
-
867
- it('ends the block scalar at a line indented to the key or less', () => {
868
- const result = parseFrontmatter('config: |-\n {\n "k": 1\n }\nnext: x');
869
- expect(result).toEqual({ config: '{\n "k": 1\n}', next: 'x' });
870
- });
871
-
872
- it('parses multi-line pretty JSON as a block scalar back to a JSON string', () => {
873
- const json = JSON.stringify({ hero: { lb: 'Hero' } }, null, 2);
874
- const body = json
875
- .split('\n')
876
- .map((l) => ` ${l}`)
877
- .join('\n');
878
- const result = parseFrontmatter(`squisq-custom-templates: |-\n${body}`);
879
- expect(typeof result!['squisq-custom-templates']).toBe('string');
880
- expect(JSON.parse(result!['squisq-custom-templates'] as string)).toEqual({
881
- hero: { lb: 'Hero' },
882
- });
883
- });
884
-
885
- it('leaves single-line values untouched alongside block scalars', () => {
886
- const result = parseFrontmatter('title: Plain\ninline: {"a":1}');
887
- expect(result).toEqual({ title: 'Plain', inline: '{"a":1}' });
888
- });
889
- });
890
-
891
- describe('multi-line frontmatter round-trips', () => {
892
- it('round-trips a multi-line string value through stringify → parse', () => {
893
- const value = JSON.stringify({ a: 1, b: [2, 3] }, null, 2);
894
- const doc = createDocument();
895
- doc.frontmatter = { payload: value, title: 'Doc' };
896
- const md = stringifyMarkdown(doc);
897
- expect(md).toContain('payload: |-');
898
- const reparsed = parseMarkdown(md);
899
- expect(reparsed.frontmatter!.payload).toBe(value);
900
- expect(reparsed.frontmatter!.title).toBe('Doc');
901
- });
902
-
903
- it('setFrontmatterValues emits a block scalar for a multi-line value', () => {
904
- const value = 'one\ntwo\nthree';
905
- const out = setFrontmatterValues('# Body\n', { notes: value });
906
- expect(out).toContain('notes: |-');
907
- expect(out).toContain(' one');
908
- const doc = parseMarkdown(out);
909
- expect(doc.frontmatter!.notes).toBe(value);
910
- });
911
-
912
- it('keeps single-line frontmatter output unchanged', () => {
913
- const doc = createDocument();
914
- doc.frontmatter = { 'document-render-as': 'portrait' };
915
- const md = stringifyMarkdown(doc);
916
- expect(md).toContain('document-render-as: portrait');
917
- expect(md).not.toContain('|-');
918
- });
919
-
920
- it('losslessly round-trips ambiguous and escaped single-line strings', () => {
921
- const doc = createDocument();
922
- doc.frontmatter = {
923
- booleanLike: 'true',
924
- numericLike: '1e3',
925
- padded: ' keep me ',
926
- quoted: '"literal quotes"',
927
- path: 'C:\\temp\\"quoted"',
928
- };
929
- const md = stringifyMarkdown(doc);
930
- expect(md).toContain('booleanLike: "true"');
931
- expect(md).toContain('numericLike: "1e3"');
932
- expect(parseMarkdown(md).frontmatter).toEqual(doc.frontmatter);
933
- });
934
-
935
- it('uses the same escaping rules when updating source frontmatter', () => {
936
- const out = setFrontmatterValues('# Body\n', {
937
- booleanLike: 'false',
938
- padded: ' value ',
939
- path: 'C:\\temp\\"quoted"',
940
- });
941
- expect(parseMarkdown(out).frontmatter).toEqual({
942
- booleanLike: 'false',
943
- padded: ' value ',
944
- path: 'C:\\temp\\"quoted"',
945
- });
946
- });
947
-
948
- it('writes boolean values as unquoted YAML booleans', () => {
949
- const out = setFrontmatterValues('# Body\n', { enabled: true, disabled: false });
950
- expect(out).toContain('enabled: true');
951
- expect(out).toContain('disabled: false');
952
- expect(out).not.toContain('enabled: "true"');
953
- expect(out).not.toContain('disabled: "false"');
954
- expect(parseMarkdown(out).frontmatter).toEqual({ enabled: true, disabled: false });
955
- });
956
- });
957
-
958
- describe('frontmatter in parseMarkdown', () => {
959
- it('extracts frontmatter from markdown with YAML header', () => {
960
- const md = '---\ndocument-render-as: landscape\ntitle: Test\n---\n\n# Hello';
961
- const doc = parseMarkdown(md);
962
- expect(doc.frontmatter).toEqual({ 'document-render-as': 'landscape', title: 'Test' });
963
- // The heading should still be there
964
- expect(doc.children.length).toBeGreaterThanOrEqual(1);
965
- expect(doc.children[0].type).toBe('heading');
966
- });
967
-
968
- it('has no frontmatter when YAML header is absent', () => {
969
- const doc = parseMarkdown('# Just a heading');
970
- expect(doc.frontmatter).toBeUndefined();
971
- });
972
-
973
- it('round-trips frontmatter through stringify', () => {
974
- const md = '---\ndocument-render-as: portrait\n---\n\n# Test';
975
- const doc = parseMarkdown(md);
976
- const output = stringifyMarkdown(doc);
977
- expect(output).toContain('---');
978
- expect(output).toContain('document-render-as: portrait');
979
- expect(output).toContain('# Test');
980
- });
981
-
982
- it('can disable frontmatter parsing', () => {
983
- const md = '---\ntitle: Disabled\n---\n\n# Hello';
984
- const doc = parseMarkdown(md, { frontmatter: false });
985
- expect(doc.frontmatter).toBeUndefined();
986
- });
987
- });
988
-
989
- describe('plainTextFromInlineHtml', () => {
990
- it('strips inline tags, keeping text', () => {
991
- expect(plainTextFromInlineHtml('<strong>bold</strong> and <em>italic</em>')).toBe(
992
- 'bold and italic',
993
- );
994
- });
995
-
996
- it('decodes entities', () => {
997
- expect(plainTextFromInlineHtml('a &amp; b &lt;c&gt;')).toBe('a & b <c>');
998
- });
999
-
1000
- it('turns <br> and block tags into line breaks', () => {
1001
- expect(plainTextFromInlineHtml('one<br>two')).toBe('one\ntwo');
1002
- expect(plainTextFromInlineHtml('<p>one</p><p>two</p>')).toBe('one\ntwo');
1003
- expect(plainTextFromInlineHtml('<h2>Title</h2><p>body</p>')).toBe('Title\nbody');
1004
- });
1005
-
1006
- it('returns empty string for empty input', () => {
1007
- expect(plainTextFromInlineHtml('')).toBe('');
1008
- });
1009
- });