@bendyline/squisq 2.0.1 → 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 (438) 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-ylqWKDc_.d.ts → Doc-BubIpWsp.d.ts} +160 -3
  5. package/dist/{ImageEditDoc-D828IXJ1.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-2ZWIXGAC.js +214 -0
  9. package/dist/{chunk-2PWOO4ZE.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-X6DUONGT.js → chunk-7ARJZYQY.js} +280 -128
  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-W4O2TX5I.js → chunk-C33GTPUZ.js} +579 -4
  22. package/dist/{chunk-MMPBOUK7.js → chunk-CB45YGAM.js} +7 -2
  23. package/dist/{chunk-CY2R2VPR.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-TFJVXUHH.js → chunk-I2O6W7DX.js} +1513 -79
  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-PXLVXTLW.js → chunk-RS5AP3J4.js} +72 -15
  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 +166 -12
  40. package/dist/doc/index.js +36 -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 +13 -12
  48. package/dist/index.js +118 -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-wSLA2A1g.d.ts +223 -0
  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 +31 -6
  61. package/dist/schemas/index.js +43 -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-RjVgLpUi.d.ts → themeLibrary-DU9mUmVl.d.ts} +1 -1
  67. package/dist/timing/index.js +3 -4
  68. package/dist/transform/index.d.ts +9 -10
  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-2PWOO4ZE.js.map +0 -1
  76. package/dist/chunk-2UQOHYE2.js.map +0 -1
  77. package/dist/chunk-3E5F2XMR.js.map +0 -1
  78. package/dist/chunk-4X3JQXNM.js.map +0 -1
  79. package/dist/chunk-5DKBFXPY.js.map +0 -1
  80. package/dist/chunk-5J4HKRJF.js.map +0 -1
  81. package/dist/chunk-5UYI3RJB.js.map +0 -1
  82. package/dist/chunk-66QO7XFB.js.map +0 -1
  83. package/dist/chunk-AMIR72JP.js +0 -380
  84. package/dist/chunk-AMIR72JP.js.map +0 -1
  85. package/dist/chunk-CY2R2VPR.js.map +0 -1
  86. package/dist/chunk-DBS6RIFL.js.map +0 -1
  87. package/dist/chunk-DNJKBAI7.js +0 -1
  88. package/dist/chunk-DNJKBAI7.js.map +0 -1
  89. package/dist/chunk-ET53IIEP.js +0 -1
  90. package/dist/chunk-ET53IIEP.js.map +0 -1
  91. package/dist/chunk-FVJUUTEM.js +0 -74
  92. package/dist/chunk-FVJUUTEM.js.map +0 -1
  93. package/dist/chunk-FVTQSNR7.js.map +0 -1
  94. package/dist/chunk-GZY66SDN.js.map +0 -1
  95. package/dist/chunk-JOQYPRDZ.js.map +0 -1
  96. package/dist/chunk-MMPBOUK7.js.map +0 -1
  97. package/dist/chunk-PGGGKYWG.js +0 -1
  98. package/dist/chunk-PGGGKYWG.js.map +0 -1
  99. package/dist/chunk-PXLVXTLW.js.map +0 -1
  100. package/dist/chunk-Q7LROV2H.js.map +0 -1
  101. package/dist/chunk-QE7TWGVT.js.map +0 -1
  102. package/dist/chunk-R2GC6RLD.js +0 -344
  103. package/dist/chunk-R2GC6RLD.js.map +0 -1
  104. package/dist/chunk-R2YZTCLO.js.map +0 -1
  105. package/dist/chunk-S7A5D7ZJ.js +0 -174
  106. package/dist/chunk-S7A5D7ZJ.js.map +0 -1
  107. package/dist/chunk-TFJVXUHH.js.map +0 -1
  108. package/dist/chunk-TUWMK62B.js.map +0 -1
  109. package/dist/chunk-V543AI2F.js +0 -1
  110. package/dist/chunk-V543AI2F.js.map +0 -1
  111. package/dist/chunk-VR7UPJ7C.js.map +0 -1
  112. package/dist/chunk-W4O2TX5I.js.map +0 -1
  113. package/dist/chunk-X6DUONGT.js.map +0 -1
  114. package/dist/chunk-ZLQKNOZQ.js +0 -1
  115. package/dist/chunk-ZLQKNOZQ.js.map +0 -1
  116. package/dist/doc/index.js.map +0 -1
  117. package/dist/generate/index.js.map +0 -1
  118. package/dist/icons/index.js.map +0 -1
  119. package/dist/icons/inlineIconMarker.js.map +0 -1
  120. package/dist/imageEdit/index.js.map +0 -1
  121. package/dist/index.js.map +0 -1
  122. package/dist/jsonForm/index.js.map +0 -1
  123. package/dist/markdown/index.js.map +0 -1
  124. package/dist/narration/index.js.map +0 -1
  125. package/dist/random/index.js.map +0 -1
  126. package/dist/recommend/index.js.map +0 -1
  127. package/dist/schemas/index.js.map +0 -1
  128. package/dist/spatial/index.js.map +0 -1
  129. package/dist/storage/index.js.map +0 -1
  130. package/dist/timing/index.js.map +0 -1
  131. package/dist/transform/index.js.map +0 -1
  132. package/dist/versions/index.js.map +0 -1
  133. package/src/__tests__/animationUtils.test.ts +0 -117
  134. package/src/__tests__/annotationCoercion.test.ts +0 -243
  135. package/src/__tests__/applyNarrationTiming.test.ts +0 -190
  136. package/src/__tests__/applyRenderStyle.test.ts +0 -146
  137. package/src/__tests__/asciiDiagramBattle.test.ts +0 -246
  138. package/src/__tests__/asciiDiagramDetect.test.ts +0 -162
  139. package/src/__tests__/asciiDiagramMapping.test.ts +0 -38
  140. package/src/__tests__/asciiDiagramParse.test.ts +0 -233
  141. package/src/__tests__/asciiDiagramPipeline.test.ts +0 -273
  142. package/src/__tests__/asciiDiagramRender.test.ts +0 -162
  143. package/src/__tests__/asciiDiagramRepair.test.ts +0 -84
  144. package/src/__tests__/asciiTimelineDetect.test.ts +0 -157
  145. package/src/__tests__/asciiTimelineParse.test.ts +0 -205
  146. package/src/__tests__/asciiTimelinePipeline.test.ts +0 -349
  147. package/src/__tests__/asciiTimelineRender.test.ts +0 -376
  148. package/src/__tests__/atmosphereLayers.test.ts +0 -108
  149. package/src/__tests__/attrTokens.test.ts +0 -167
  150. package/src/__tests__/colorUtils.test.ts +0 -112
  151. package/src/__tests__/contentContainer.test.ts +0 -325
  152. package/src/__tests__/contentExtractor.test.ts +0 -243
  153. package/src/__tests__/coverBlock.test.ts +0 -310
  154. package/src/__tests__/customTemplateSample.test.ts +0 -144
  155. package/src/__tests__/customTemplatesFrontmatter.test.ts +0 -221
  156. package/src/__tests__/customThemesFrontmatter.test.ts +0 -146
  157. package/src/__tests__/dataTable.test.ts +0 -145
  158. package/src/__tests__/diagramBlock.test.ts +0 -122
  159. package/src/__tests__/diagramLayout.test.ts +0 -134
  160. package/src/__tests__/diagramText.test.ts +0 -26
  161. package/src/__tests__/docToMarkdownMedia.test.ts +0 -83
  162. package/src/__tests__/drawing.test.ts +0 -109
  163. package/src/__tests__/drawingBlock.test.ts +0 -124
  164. package/src/__tests__/drawingLayout.test.ts +0 -171
  165. package/src/__tests__/fixtures/asciiDiagramBattle.ts +0 -512
  166. package/src/__tests__/fixtures/asciiDiagrams.ts +0 -287
  167. package/src/__tests__/fixtures/asciiTimelines.ts +0 -35
  168. package/src/__tests__/fixtures/treeviewFixtures.ts +0 -243
  169. package/src/__tests__/geohash.test.ts +0 -110
  170. package/src/__tests__/getLayers.test.ts +0 -243
  171. package/src/__tests__/getLayersFallback.test.ts +0 -103
  172. package/src/__tests__/haversine.test.ts +0 -63
  173. package/src/__tests__/iconResolve.test.ts +0 -122
  174. package/src/__tests__/imageEditExportSvg.test.ts +0 -70
  175. package/src/__tests__/imageEditState.test.ts +0 -74
  176. package/src/__tests__/imageEditVersions.test.ts +0 -243
  177. package/src/__tests__/inferDocumentTitle.test.ts +0 -50
  178. package/src/__tests__/inlineIconMarker.test.ts +0 -36
  179. package/src/__tests__/inputDescriptors.test.ts +0 -162
  180. package/src/__tests__/jsonForm.chooseControl.test.ts +0 -86
  181. package/src/__tests__/jsonForm.evaluateWhen.test.ts +0 -59
  182. package/src/__tests__/jsonForm.inferSchema.test.ts +0 -25
  183. package/src/__tests__/jsonForm.pointer.test.ts +0 -149
  184. package/src/__tests__/jsonForm.tokens.test.ts +0 -84
  185. package/src/__tests__/layoutBlock.test.ts +0 -83
  186. package/src/__tests__/layoutLayout.test.ts +0 -169
  187. package/src/__tests__/localForageAdapter.test.ts +0 -155
  188. package/src/__tests__/majorApiTypes.test.ts +0 -18
  189. package/src/__tests__/markdown.test.ts +0 -1009
  190. package/src/__tests__/markdownIcons.test.ts +0 -104
  191. package/src/__tests__/markdownSanitize.test.ts +0 -81
  192. package/src/__tests__/markdownToDoc.test.ts +0 -957
  193. package/src/__tests__/matchFontFamily.test.ts +0 -114
  194. package/src/__tests__/materializeBlockLayers.test.ts +0 -135
  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__/pandocAttrParse.test.ts +0 -187
  209. package/src/__tests__/recommendTemplates.test.ts +0 -183
  210. package/src/__tests__/resolveDocTheme.test.ts +0 -69
  211. package/src/__tests__/rootExports.test.ts +0 -61
  212. package/src/__tests__/scopedContentContainer.test.ts +0 -109
  213. package/src/__tests__/seededRandom.test.ts +0 -142
  214. package/src/__tests__/shapeGeometry.test.ts +0 -138
  215. package/src/__tests__/shapeVocabulary.test.ts +0 -133
  216. package/src/__tests__/storage.test.ts +0 -60
  217. package/src/__tests__/structuredData.test.ts +0 -249
  218. package/src/__tests__/surface.test.ts +0 -68
  219. package/src/__tests__/templateAnnotationParse.test.ts +0 -160
  220. package/src/__tests__/templateInputs.test.ts +0 -69
  221. package/src/__tests__/templateMetadata.test.ts +0 -32
  222. package/src/__tests__/templates.test.ts +0 -710
  223. package/src/__tests__/themeCompile.test.ts +0 -225
  224. package/src/__tests__/themeValidator.test.ts +0 -131
  225. package/src/__tests__/timing.test.ts +0 -167
  226. package/src/__tests__/transformProvenance.test.ts +0 -160
  227. package/src/__tests__/transformV2.test.ts +0 -163
  228. package/src/__tests__/transitionNormalize.test.ts +0 -61
  229. package/src/__tests__/treeviewBattle.test.ts +0 -76
  230. package/src/__tests__/treeviewDetect.test.ts +0 -168
  231. package/src/__tests__/treeviewParse.test.ts +0 -118
  232. package/src/__tests__/treeviewPipeline.test.ts +0 -183
  233. package/src/__tests__/treeviewRender.test.ts +0 -91
  234. package/src/__tests__/validateDoc.test.ts +0 -260
  235. package/src/__tests__/versions.test.ts +0 -459
  236. package/src/doc/annotationBlocks.ts +0 -117
  237. package/src/doc/applyNarrationTiming.ts +0 -244
  238. package/src/doc/asciiDiagram/chars.ts +0 -210
  239. package/src/doc/asciiDiagram/detect.ts +0 -175
  240. package/src/doc/asciiDiagram/index.ts +0 -38
  241. package/src/doc/asciiDiagram/mapping.ts +0 -225
  242. package/src/doc/asciiDiagram/parse.ts +0 -1095
  243. package/src/doc/asciiDiagram/render.ts +0 -963
  244. package/src/doc/asciiDiagram/repair.ts +0 -400
  245. package/src/doc/asciiDiagram/types.ts +0 -65
  246. package/src/doc/asciiTimeline/detect.ts +0 -138
  247. package/src/doc/asciiTimeline/index.ts +0 -26
  248. package/src/doc/asciiTimeline/mapping.ts +0 -43
  249. package/src/doc/asciiTimeline/parse.ts +0 -870
  250. package/src/doc/asciiTimeline/render.ts +0 -427
  251. package/src/doc/asciiTimeline/types.ts +0 -73
  252. package/src/doc/asciiTimeline/wrappedFlow.ts +0 -427
  253. package/src/doc/audioMapping.ts +0 -442
  254. package/src/doc/customTemplatesFrontmatter.ts +0 -273
  255. package/src/doc/customThemesFrontmatter.ts +0 -95
  256. package/src/doc/docToMarkdown.ts +0 -284
  257. package/src/doc/index.ts +0 -127
  258. package/src/doc/markdownToDoc.ts +0 -1054
  259. package/src/doc/materializeBlockLayers.ts +0 -304
  260. package/src/doc/mediaAnnotations.ts +0 -120
  261. package/src/doc/resolveDocTheme.ts +0 -56
  262. package/src/doc/standaloneAnnotation.ts +0 -58
  263. package/src/doc/structuredData.ts +0 -301
  264. package/src/doc/templateInputs.ts +0 -423
  265. package/src/doc/templates/__tests__/customTemplate.test.ts +0 -170
  266. package/src/doc/templates/__tests__/customTemplateRegistry.test.ts +0 -124
  267. package/src/doc/templates/__tests__/listBlock.test.ts +0 -64
  268. package/src/doc/templates/accentImage.ts +0 -362
  269. package/src/doc/templates/captionUtils.ts +0 -56
  270. package/src/doc/templates/comparisonBar.ts +0 -173
  271. package/src/doc/templates/coverBlock.ts +0 -255
  272. package/src/doc/templates/customTemplate.ts +0 -51
  273. package/src/doc/templates/dataTable.ts +0 -102
  274. package/src/doc/templates/dateEvent.ts +0 -147
  275. package/src/doc/templates/definitionCard.ts +0 -140
  276. package/src/doc/templates/diagramBlock.ts +0 -403
  277. package/src/doc/templates/diagramLayout.ts +0 -159
  278. package/src/doc/templates/drawingBlock.ts +0 -325
  279. package/src/doc/templates/drawingLayout.ts +0 -539
  280. package/src/doc/templates/factCard.ts +0 -146
  281. package/src/doc/templates/fallbackBlock.ts +0 -123
  282. package/src/doc/templates/featureBlock.ts +0 -209
  283. package/src/doc/templates/fullBleedQuote.ts +0 -83
  284. package/src/doc/templates/imageWithCaption.ts +0 -186
  285. package/src/doc/templates/index.ts +0 -642
  286. package/src/doc/templates/inputDescriptors.ts +0 -451
  287. package/src/doc/templates/layoutBlock.ts +0 -43
  288. package/src/doc/templates/layoutLayout.ts +0 -243
  289. package/src/doc/templates/listBlock.ts +0 -207
  290. package/src/doc/templates/mapBlock.ts +0 -138
  291. package/src/doc/templates/metadata.ts +0 -130
  292. package/src/doc/templates/persistentLayers.ts +0 -526
  293. package/src/doc/templates/photoGrid.ts +0 -190
  294. package/src/doc/templates/pullQuote.ts +0 -141
  295. package/src/doc/templates/quoteBlock.ts +0 -141
  296. package/src/doc/templates/registry.ts +0 -88
  297. package/src/doc/templates/sectionHeader.ts +0 -120
  298. package/src/doc/templates/statHighlight.ts +0 -146
  299. package/src/doc/templates/templateNames.ts +0 -22
  300. package/src/doc/templates/timelineBlock.ts +0 -613
  301. package/src/doc/templates/titleBlock.ts +0 -150
  302. package/src/doc/templates/tokens/__tests__/resolveTokens.test.ts +0 -487
  303. package/src/doc/templates/tokens/resolveTokens.ts +0 -453
  304. package/src/doc/templates/treeBlock.ts +0 -131
  305. package/src/doc/templates/twoColumn.ts +0 -263
  306. package/src/doc/templates/videoPullQuote.ts +0 -142
  307. package/src/doc/templates/videoWithCaption.ts +0 -135
  308. package/src/doc/treeview/chars.ts +0 -72
  309. package/src/doc/treeview/detect.ts +0 -145
  310. package/src/doc/treeview/index.ts +0 -30
  311. package/src/doc/treeview/mapping.ts +0 -95
  312. package/src/doc/treeview/parse.ts +0 -201
  313. package/src/doc/treeview/render.ts +0 -41
  314. package/src/doc/treeview/types.ts +0 -43
  315. package/src/doc/utils/animationUtils.ts +0 -399
  316. package/src/doc/utils/applyRenderStyle.ts +0 -106
  317. package/src/doc/utils/diagramText.ts +0 -78
  318. package/src/doc/utils/imageTreatment.ts +0 -70
  319. package/src/doc/utils/nearest.ts +0 -59
  320. package/src/doc/utils/shapeGeometry.ts +0 -614
  321. package/src/doc/utils/themeUtils.ts +0 -243
  322. package/src/doc/validate.ts +0 -575
  323. package/src/generate/contentExtractor.ts +0 -921
  324. package/src/generate/index.ts +0 -18
  325. package/src/generate/templateMapper.ts +0 -177
  326. package/src/icons/iconData.ts +0 -31
  327. package/src/icons/index.ts +0 -26
  328. package/src/icons/inlineIconMarker.ts +0 -73
  329. package/src/icons/resolve.ts +0 -139
  330. package/src/imageEdit/ImageEditVersionManager.ts +0 -73
  331. package/src/imageEdit/export.ts +0 -410
  332. package/src/imageEdit/index.ts +0 -72
  333. package/src/imageEdit/persistence.ts +0 -113
  334. package/src/imageEdit/state.ts +0 -112
  335. package/src/imageEdit/versionPaths.ts +0 -44
  336. package/src/imageEdit/versions.ts +0 -152
  337. package/src/index.ts +0 -15
  338. package/src/internal/immutable.ts +0 -58
  339. package/src/jsonForm/chooseControl.ts +0 -88
  340. package/src/jsonForm/evaluateWhen.ts +0 -59
  341. package/src/jsonForm/index.ts +0 -32
  342. package/src/jsonForm/inferSchema.ts +0 -25
  343. package/src/jsonForm/pointer.ts +0 -154
  344. package/src/jsonForm/tokens.ts +0 -78
  345. package/src/jsonForm/types.ts +0 -167
  346. package/src/markdown/annotationCoercion.ts +0 -295
  347. package/src/markdown/attrTokens.ts +0 -243
  348. package/src/markdown/convert.ts +0 -1353
  349. package/src/markdown/htmlParse.ts +0 -212
  350. package/src/markdown/index.ts +0 -152
  351. package/src/markdown/parse.ts +0 -103
  352. package/src/markdown/sanitize.ts +0 -318
  353. package/src/markdown/stringify.ts +0 -207
  354. package/src/markdown/types.ts +0 -710
  355. package/src/markdown/utils.ts +0 -459
  356. package/src/narration/align.ts +0 -514
  357. package/src/narration/features.ts +0 -231
  358. package/src/narration/index.ts +0 -86
  359. package/src/narration/nuclei.ts +0 -118
  360. package/src/narration/pacing.ts +0 -211
  361. package/src/narration/script.ts +0 -239
  362. package/src/narration/session.ts +0 -100
  363. package/src/narration/sidecar.ts +0 -187
  364. package/src/narration/syllables.ts +0 -85
  365. package/src/narration/trace.ts +0 -50
  366. package/src/narration/types.ts +0 -299
  367. package/src/narration/vad.ts +0 -131
  368. package/src/ngeohash.d.ts +0 -11
  369. package/src/random/SeededRandom.ts +0 -127
  370. package/src/random/index.ts +0 -1
  371. package/src/recommend/index.ts +0 -16
  372. package/src/recommend/numberHighlight.ts +0 -25
  373. package/src/recommend/templates.ts +0 -393
  374. package/src/schemas/BlockTemplates.ts +0 -1046
  375. package/src/schemas/CustomTemplates.ts +0 -126
  376. package/src/schemas/Doc.ts +0 -1052
  377. package/src/schemas/ImageEditDoc.ts +0 -102
  378. package/src/schemas/LayoutStrategy.ts +0 -178
  379. package/src/schemas/Media.ts +0 -179
  380. package/src/schemas/MediaProvider.ts +0 -70
  381. package/src/schemas/Theme.ts +0 -406
  382. package/src/schemas/Transitions.ts +0 -224
  383. package/src/schemas/Types.ts +0 -15
  384. package/src/schemas/Viewport.ts +0 -91
  385. package/src/schemas/colorUtils.ts +0 -219
  386. package/src/schemas/fontStacks.ts +0 -339
  387. package/src/schemas/index.ts +0 -29
  388. package/src/schemas/themeCompile.ts +0 -237
  389. package/src/schemas/themeConstants.ts +0 -2
  390. package/src/schemas/themeLibrary.ts +0 -60
  391. package/src/schemas/themeValidator.ts +0 -426
  392. package/src/schemas/themes/bold.json +0 -48
  393. package/src/schemas/themes/cinematic.json +0 -111
  394. package/src/schemas/themes/documentary.json +0 -96
  395. package/src/schemas/themes/gezellig.json +0 -93
  396. package/src/schemas/themes/index.ts +0 -53
  397. package/src/schemas/themes/magazine.json +0 -89
  398. package/src/schemas/themes/minimalist.json +0 -45
  399. package/src/schemas/themes/morning-light.json +0 -85
  400. package/src/schemas/themes/standard-dark.json +0 -85
  401. package/src/schemas/themes/standard.json +0 -74
  402. package/src/schemas/themes/tech-dark.json +0 -101
  403. package/src/schemas/themes/warm-earth.json +0 -50
  404. package/src/spatial/Geohash.ts +0 -196
  405. package/src/spatial/Haversine.ts +0 -59
  406. package/src/spatial/index.ts +0 -2
  407. package/src/storage/ContentContainer.ts +0 -220
  408. package/src/storage/LocalForageAdapter.ts +0 -103
  409. package/src/storage/LocalStorageAdapter.ts +0 -57
  410. package/src/storage/MediaProviderFromContainer.ts +0 -92
  411. package/src/storage/MemoryStorageAdapter.ts +0 -37
  412. package/src/storage/ScopedContentContainer.ts +0 -143
  413. package/src/storage/Storage.ts +0 -28
  414. package/src/storage/index.ts +0 -9
  415. package/src/timing/index.ts +0 -17
  416. package/src/timing/narrationTiming.ts +0 -220
  417. package/src/timing/readingTime.ts +0 -94
  418. package/src/transform/applyTransform.ts +0 -122
  419. package/src/transform/blockAnalyzer.ts +0 -181
  420. package/src/transform/index.ts +0 -23
  421. package/src/transform/registry.ts +0 -198
  422. package/src/transform/styles/dataDriven.ts +0 -17
  423. package/src/transform/styles/documentary.ts +0 -17
  424. package/src/transform/styles/index.ts +0 -5
  425. package/src/transform/styles/magazine.ts +0 -18
  426. package/src/transform/styles/minimal.ts +0 -17
  427. package/src/transform/styles/narrative.ts +0 -18
  428. package/src/transform/templateSelector.ts +0 -389
  429. package/src/transform/timingAllocator.ts +0 -257
  430. package/src/transform/types.ts +0 -151
  431. package/src/versions/DocumentVersionManager.ts +0 -70
  432. package/src/versions/gitignore.ts +0 -34
  433. package/src/versions/index.ts +0 -56
  434. package/src/versions/operations.ts +0 -144
  435. package/src/versions/paths.ts +0 -51
  436. package/src/versions/snapshotStore.ts +0 -202
  437. package/src/versions/timestamp.ts +0 -48
  438. 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
- });