@diegopluna/narvi 0.0.2 → 0.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 (313) hide show
  1. package/README.md +116 -44
  2. package/dist/base.css +96 -0
  3. package/dist/color.d.ts +1 -1
  4. package/dist/color.js +1 -1
  5. package/dist/components/activity/ActivityContent.svelte +3 -15
  6. package/dist/components/activity/ActivityStep.svelte +12 -12
  7. package/dist/components/activity/ActivityThought.svelte +4 -4
  8. package/dist/components/activity/ActivityTrigger.svelte +5 -6
  9. package/dist/components/app-shell/AppShellBar.svelte +89 -0
  10. package/dist/components/app-shell/AppShellBar.svelte.d.ts +20 -0
  11. package/dist/components/app-shell/AppShellHeader.svelte +17 -17
  12. package/dist/components/app-shell/AppShellHeader.svelte.d.ts +2 -2
  13. package/dist/components/app-shell/AppShellMain.svelte +4 -20
  14. package/dist/components/app-shell/AppShellPanel.svelte +21 -19
  15. package/dist/components/app-shell/AppShellPanes.svelte +58 -0
  16. package/dist/components/app-shell/AppShellPanes.svelte.d.ts +11 -0
  17. package/dist/components/app-shell/AppShellRail.svelte +85 -0
  18. package/dist/components/app-shell/AppShellRail.svelte.d.ts +11 -0
  19. package/dist/components/app-shell/AppShellRoot.svelte +50 -24
  20. package/dist/components/app-shell/AppShellRoot.svelte.d.ts +8 -6
  21. package/dist/components/app-shell/AppShellSheet.svelte +95 -0
  22. package/dist/components/app-shell/AppShellSheet.svelte.d.ts +17 -0
  23. package/dist/components/app-shell/AppShellSidebar.svelte +41 -65
  24. package/dist/components/app-shell/AppShellSidebar.svelte.d.ts +1 -5
  25. package/dist/components/app-shell/AppShellToggle.svelte +62 -23
  26. package/dist/components/app-shell/AppShellToggle.svelte.d.ts +2 -0
  27. package/dist/components/app-shell/context.d.ts +6 -0
  28. package/dist/components/app-shell/index.d.ts +9 -1
  29. package/dist/components/app-shell/index.js +5 -1
  30. package/dist/components/approval/Approval.svelte +99 -23
  31. package/dist/components/approval/Approval.svelte.d.ts +7 -0
  32. package/dist/components/avatar/AvatarFallback.svelte +1 -2
  33. package/dist/components/avatar/AvatarRoot.svelte +2 -2
  34. package/dist/components/badge/Badge.svelte +5 -5
  35. package/dist/components/button/Button.svelte +227 -51
  36. package/dist/components/button/Button.svelte.d.ts +38 -2
  37. package/dist/components/card/Card.svelte +19 -33
  38. package/dist/components/change-stats/ChangeStats.svelte +1 -2
  39. package/dist/components/changes-summary/ChangesSummary.svelte +14 -15
  40. package/dist/components/checkbox/Checkbox.svelte +31 -25
  41. package/dist/components/checkbox/Checkbox.svelte.d.ts +5 -0
  42. package/dist/components/code/Code.svelte +1 -2
  43. package/dist/components/collapsible/CollapsibleContent.svelte +38 -0
  44. package/dist/components/collapsible/CollapsibleContent.svelte.d.ts +11 -0
  45. package/dist/components/collapsible/CollapsibleRoot.svelte +44 -0
  46. package/dist/components/collapsible/CollapsibleRoot.svelte.d.ts +11 -0
  47. package/dist/components/collapsible/CollapsibleTrigger.svelte +83 -0
  48. package/dist/components/collapsible/CollapsibleTrigger.svelte.d.ts +13 -0
  49. package/dist/components/collapsible/context.d.ts +5 -0
  50. package/dist/components/collapsible/context.js +11 -0
  51. package/dist/components/collapsible/index.d.ts +7 -0
  52. package/dist/components/collapsible/index.js +4 -0
  53. package/dist/components/command/CommandItem.svelte +1 -1
  54. package/dist/components/command/styles.d.ts +3 -2
  55. package/dist/components/command/styles.js +15 -12
  56. package/dist/components/composer/ComposerAttachButton.svelte +1 -1
  57. package/dist/components/composer/ComposerAttachment.svelte +13 -18
  58. package/dist/components/composer/ComposerModelPicker.svelte +24 -28
  59. package/dist/components/composer/ComposerRoot.svelte +15 -13
  60. package/dist/components/composer/ComposerSubmit.svelte +12 -20
  61. package/dist/components/composer/ComposerTextarea.svelte +1 -1
  62. package/dist/components/composer/ComposerToggle.svelte +16 -18
  63. package/dist/components/composer/ComposerTray.svelte +78 -0
  64. package/dist/components/composer/ComposerTray.svelte.d.ts +15 -0
  65. package/dist/components/composer/index.d.ts +3 -1
  66. package/dist/components/composer/index.js +3 -2
  67. package/dist/components/conversation/ConversationContent.svelte +3 -2
  68. package/dist/components/conversation/ConversationEmpty.svelte +1 -1
  69. package/dist/components/conversation/ConversationScrollButton.svelte +9 -11
  70. package/dist/components/dialog/ConfirmDialog.svelte +1 -1
  71. package/dist/components/dialog/DialogContent.svelte +5 -1
  72. package/dist/components/dialog/styles.d.ts +2 -26
  73. package/dist/components/dialog/styles.js +12 -49
  74. package/dist/components/divider/Divider.svelte +3 -3
  75. package/dist/components/empty-state/EmptyState.svelte +4 -5
  76. package/dist/components/field/Field.svelte +4 -4
  77. package/dist/components/frame/Frame.svelte +6 -7
  78. package/dist/components/frame/Frame.svelte.d.ts +1 -1
  79. package/dist/components/grid/Grid.svelte +111 -0
  80. package/dist/components/grid/Grid.svelte.d.ts +27 -0
  81. package/dist/components/heading/Heading.svelte +2 -2
  82. package/dist/components/hover-card/HoverCardContent.svelte +50 -0
  83. package/dist/components/hover-card/HoverCardContent.svelte.d.ts +10 -0
  84. package/dist/components/hover-card/HoverCardRoot.svelte +22 -0
  85. package/dist/components/hover-card/HoverCardRoot.svelte.d.ts +5 -0
  86. package/dist/components/hover-card/index.d.ts +7 -0
  87. package/dist/components/hover-card/index.js +7 -0
  88. package/dist/components/kbd/Kbd.svelte +12 -7
  89. package/dist/components/link/Link.svelte +9 -7
  90. package/dist/components/link/Link.svelte.d.ts +4 -1
  91. package/dist/components/markdown/Markdown.svelte +714 -0
  92. package/dist/components/markdown/Markdown.svelte.d.ts +80 -0
  93. package/dist/components/markdown/MarkdownBlock.svelte +231 -0
  94. package/dist/components/markdown/MarkdownBlock.svelte.d.ts +11 -0
  95. package/dist/components/markdown/MarkdownBlocks.svelte +115 -0
  96. package/dist/components/markdown/MarkdownBlocks.svelte.d.ts +15 -0
  97. package/dist/components/markdown/MarkdownCode.svelte +583 -0
  98. package/dist/components/markdown/MarkdownCode.svelte.d.ts +23 -0
  99. package/dist/components/markdown/MarkdownDiagram.svelte +310 -0
  100. package/dist/components/markdown/MarkdownDiagram.svelte.d.ts +6 -0
  101. package/dist/components/markdown/MarkdownFile.svelte +134 -0
  102. package/dist/components/markdown/MarkdownFile.svelte.d.ts +19 -0
  103. package/dist/components/markdown/MarkdownFootnotes.svelte +61 -0
  104. package/dist/components/markdown/MarkdownFootnotes.svelte.d.ts +8 -0
  105. package/dist/components/markdown/MarkdownFresh.svelte +69 -0
  106. package/dist/components/markdown/MarkdownFresh.svelte.d.ts +6 -0
  107. package/dist/components/markdown/MarkdownHtml.svelte +72 -0
  108. package/dist/components/markdown/MarkdownHtml.svelte.d.ts +7 -0
  109. package/dist/components/markdown/MarkdownImage.svelte +150 -0
  110. package/dist/components/markdown/MarkdownImage.svelte.d.ts +8 -0
  111. package/dist/components/markdown/MarkdownInlines.svelte +225 -0
  112. package/dist/components/markdown/MarkdownInlines.svelte.d.ts +7 -0
  113. package/dist/components/markdown/MarkdownLink.svelte +120 -0
  114. package/dist/components/markdown/MarkdownLink.svelte.d.ts +25 -0
  115. package/dist/components/markdown/MarkdownMath.svelte +138 -0
  116. package/dist/components/markdown/MarkdownMath.svelte.d.ts +7 -0
  117. package/dist/components/markdown/MarkdownTable.svelte +265 -0
  118. package/dist/components/markdown/MarkdownTable.svelte.d.ts +17 -0
  119. package/dist/components/markdown/caret.d.ts +14 -0
  120. package/dist/components/markdown/caret.js +67 -0
  121. package/dist/components/markdown/context.d.ts +93 -0
  122. package/dist/components/markdown/context.js +128 -0
  123. package/dist/components/markdown/copy.d.ts +13 -0
  124. package/dist/components/markdown/copy.js +74 -0
  125. package/dist/components/markdown/hidden.d.ts +12 -0
  126. package/dist/components/markdown/hidden.js +31 -0
  127. package/dist/components/markdown/kept.d.ts +32 -0
  128. package/dist/components/markdown/kept.js +71 -0
  129. package/dist/components/markdown/labels.d.ts +46 -0
  130. package/dist/components/markdown/labels.js +35 -0
  131. package/dist/components/markdown/save.d.ts +11 -0
  132. package/dist/components/markdown/save.js +58 -0
  133. package/dist/components/markdown/scrollable.d.ts +24 -0
  134. package/dist/components/markdown/scrollable.js +152 -0
  135. package/dist/components/markdown/static.d.ts +37 -0
  136. package/dist/components/markdown/static.js +233 -0
  137. package/dist/components/markdown/styles.d.ts +328 -0
  138. package/dist/components/markdown/styles.js +302 -0
  139. package/dist/components/menu/MenuRadioItem.svelte +3 -3
  140. package/dist/components/menu/index.d.ts +23 -0
  141. package/dist/components/menu/index.js +3 -1
  142. package/dist/components/message/MessageAction.svelte +24 -5
  143. package/dist/components/message/MessageAction.svelte.d.ts +9 -0
  144. package/dist/components/message/MessageActions.svelte +2 -3
  145. package/dist/components/message/MessageContent.svelte +2 -3
  146. package/dist/components/message/MessageCopy.svelte +66 -8
  147. package/dist/components/message/MessageCopy.svelte.d.ts +17 -1
  148. package/dist/components/message/MessageHeader.svelte +3 -3
  149. package/dist/components/message/MessagePending.svelte +1 -1
  150. package/dist/components/message/MessageRoot.svelte +3 -4
  151. package/dist/components/message/MessageTime.svelte +3 -4
  152. package/dist/components/notice/Notice.svelte +14 -10
  153. package/dist/components/plan/Plan.svelte +25 -21
  154. package/dist/components/progress/Progress.svelte +34 -38
  155. package/dist/components/questionnaire/Questionnaire.svelte +19 -22
  156. package/dist/components/queued-message/QueuedMessage.svelte +14 -7
  157. package/dist/components/rail/RailItem.svelte +43 -40
  158. package/dist/components/rail/RailItem.svelte.d.ts +3 -1
  159. package/dist/components/rail/RailRoot.svelte +18 -4
  160. package/dist/components/rail/RailRoot.svelte.d.ts +1 -1
  161. package/dist/components/rail/RailSeparator.svelte +17 -0
  162. package/dist/components/rail/RailSeparator.svelte.d.ts +18 -0
  163. package/dist/components/rail/index.d.ts +2 -1
  164. package/dist/components/rail/index.js +2 -1
  165. package/dist/components/reasoning/ReasoningContent.svelte +4 -8
  166. package/dist/components/reasoning/ReasoningTrigger.svelte +4 -5
  167. package/dist/components/resize-handle/ResizeHandle.svelte +4 -7
  168. package/dist/components/reveal/Reveal.svelte +89 -0
  169. package/dist/components/reveal/Reveal.svelte.d.ts +17 -0
  170. package/dist/components/reveal/revealed.d.ts +38 -0
  171. package/dist/components/reveal/revealed.js +79 -0
  172. package/dist/components/segmented/SegmentedControl.svelte +11 -16
  173. package/dist/components/select/Select.svelte +1 -1
  174. package/dist/components/separator/Separator.svelte +1 -1
  175. package/dist/components/settings-row/SettingsRow.svelte +5 -5
  176. package/dist/components/sheet/SheetContent.svelte +63 -0
  177. package/dist/components/sheet/SheetContent.svelte.d.ts +18 -0
  178. package/dist/components/sheet/index.d.ts +12 -0
  179. package/dist/components/sheet/index.js +12 -0
  180. package/dist/components/sheet/styles.d.ts +51 -0
  181. package/dist/components/sheet/styles.js +65 -0
  182. package/dist/components/shimmer/Shimmer.svelte +41 -26
  183. package/dist/components/sidebar/SidebarContent.svelte +1 -1
  184. package/dist/components/sidebar/SidebarFolder.svelte +142 -0
  185. package/dist/components/sidebar/SidebarFolder.svelte.d.ts +19 -0
  186. package/dist/components/sidebar/SidebarFooter.svelte +1 -1
  187. package/dist/components/sidebar/SidebarGroup.svelte +41 -35
  188. package/dist/components/sidebar/SidebarGroup.svelte.d.ts +3 -3
  189. package/dist/components/sidebar/SidebarHeader.svelte +12 -6
  190. package/dist/components/sidebar/SidebarHeader.svelte.d.ts +4 -1
  191. package/dist/components/sidebar/SidebarItem.svelte +34 -38
  192. package/dist/components/sidebar/SidebarRoot.svelte +62 -0
  193. package/dist/components/sidebar/SidebarRoot.svelte.d.ts +14 -0
  194. package/dist/components/sidebar/index.d.ts +5 -1
  195. package/dist/components/sidebar/index.js +3 -1
  196. package/dist/components/skeleton/Skeleton.svelte +26 -15
  197. package/dist/components/slider/Slider.svelte +200 -0
  198. package/dist/components/slider/Slider.svelte.d.ts +55 -0
  199. package/dist/components/spinner/Spinner.svelte +4 -11
  200. package/dist/components/stack/Stack.svelte +37 -44
  201. package/dist/components/stack/Stack.svelte.d.ts +12 -6
  202. package/dist/components/status-indicator/StatusIndicator.svelte +1 -1
  203. package/dist/components/suggestions/SuggestionsItem.svelte +11 -13
  204. package/dist/components/switch/Switch.svelte +16 -25
  205. package/dist/components/tab-strip/TabStrip.svelte +340 -0
  206. package/dist/components/tab-strip/TabStrip.svelte.d.ts +31 -0
  207. package/dist/components/tabs/Tabs.svelte +15 -14
  208. package/dist/components/tabs/Tabs.svelte.d.ts +4 -0
  209. package/dist/components/text/Text.svelte +64 -14
  210. package/dist/components/text/Text.svelte.d.ts +13 -3
  211. package/dist/components/toast/Toaster.svelte +12 -10
  212. package/dist/components/toggle/Toggle.svelte +40 -0
  213. package/dist/components/toggle/Toggle.svelte.d.ts +15 -0
  214. package/dist/components/toggle-group/ToggleGroupItem.svelte +37 -0
  215. package/dist/components/toggle-group/ToggleGroupItem.svelte.d.ts +12 -0
  216. package/dist/components/toggle-group/ToggleGroupRoot.svelte +95 -0
  217. package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +33 -0
  218. package/dist/components/toggle-group/context.d.ts +6 -0
  219. package/dist/components/toggle-group/context.js +11 -0
  220. package/dist/components/toggle-group/index.d.ts +5 -0
  221. package/dist/components/toggle-group/index.js +3 -0
  222. package/dist/components/tool/ToolContent.svelte +3 -8
  223. package/dist/components/tool/ToolSection.svelte +4 -5
  224. package/dist/components/tool/ToolTrigger.svelte +14 -15
  225. package/dist/components/tooltip/TooltipContent.svelte +9 -6
  226. package/dist/components/work-fold/WorkFold.svelte +17 -34
  227. package/dist/components/work-fold/WorkFold.svelte.d.ts +1 -1
  228. package/dist/index.d.ts +38 -10
  229. package/dist/index.js +38 -12
  230. package/dist/internal/Chevron.svelte +2 -3
  231. package/dist/internal/Code.svelte +3 -4
  232. package/dist/internal/Collapse.svelte +6 -5
  233. package/dist/internal/Collapse.svelte.d.ts +2 -1
  234. package/dist/internal/Glyph.svelte +16 -0
  235. package/dist/internal/Glyph.svelte.d.ts +6 -0
  236. package/dist/internal/Tile.svelte +17 -37
  237. package/dist/internal/control.d.ts +4 -4
  238. package/dist/internal/control.js +21 -18
  239. package/dist/internal/layer.d.ts +3 -5
  240. package/dist/internal/layer.js +14 -18
  241. package/dist/internal/layout.d.ts +13 -0
  242. package/dist/internal/layout.js +453 -0
  243. package/dist/internal/markers.stylex.d.ts +8 -0
  244. package/dist/internal/markers.stylex.js +4 -0
  245. package/dist/internal/plugin-order.d.ts +8 -0
  246. package/dist/internal/plugin-order.js +16 -0
  247. package/dist/internal/responsive.d.ts +45 -0
  248. package/dist/internal/responsive.js +42 -0
  249. package/dist/internal/roving.js +5 -2
  250. package/dist/internal/shared.d.ts +8 -1
  251. package/dist/internal/shared.js +21 -5
  252. package/dist/internal/sx.d.ts +31 -4
  253. package/dist/internal/sx.js +17 -0
  254. package/dist/internal/toggle.d.ts +73 -0
  255. package/dist/internal/toggle.js +83 -0
  256. package/dist/internal/visible.d.ts +32 -0
  257. package/dist/internal/visible.js +44 -0
  258. package/dist/markdown/ast.d.ts +209 -0
  259. package/dist/markdown/ast.js +10 -0
  260. package/dist/markdown/blocks.d.ts +177 -0
  261. package/dist/markdown/blocks.js +1489 -0
  262. package/dist/markdown/code-info.d.ts +10 -0
  263. package/dist/markdown/code-info.js +16 -0
  264. package/dist/markdown/common.d.ts +25 -0
  265. package/dist/markdown/common.js +107 -0
  266. package/dist/markdown/diagrams.d.ts +2 -0
  267. package/dist/markdown/diagrams.js +18 -0
  268. package/dist/markdown/file-paths.d.ts +29 -0
  269. package/dist/markdown/file-paths.js +80 -0
  270. package/dist/markdown/files.d.ts +16 -0
  271. package/dist/markdown/files.js +133 -0
  272. package/dist/markdown/highlight.d.ts +30 -0
  273. package/dist/markdown/highlight.js +127 -0
  274. package/dist/markdown/html.d.ts +23 -0
  275. package/dist/markdown/html.js +289 -0
  276. package/dist/markdown/images.d.ts +15 -0
  277. package/dist/markdown/images.js +45 -0
  278. package/dist/markdown/index.d.ts +12 -0
  279. package/dist/markdown/index.js +5 -0
  280. package/dist/markdown/inlines.d.ts +48 -0
  281. package/dist/markdown/inlines.js +1714 -0
  282. package/dist/markdown/math.d.ts +2 -0
  283. package/dist/markdown/math.js +22 -0
  284. package/dist/markdown/parse.d.ts +81 -0
  285. package/dist/markdown/parse.js +204 -0
  286. package/dist/markdown/plugin.d.ts +178 -0
  287. package/dist/markdown/plugin.js +160 -0
  288. package/dist/markdown/sanitize.d.ts +78 -0
  289. package/dist/markdown/sanitize.js +522 -0
  290. package/dist/markdown/share.d.ts +12 -0
  291. package/dist/markdown/share.js +59 -0
  292. package/dist/markdown/table.d.ts +13 -0
  293. package/dist/markdown/table.js +60 -0
  294. package/dist/media.stylex.d.ts +52 -0
  295. package/dist/media.stylex.js +53 -0
  296. package/dist/preset.d.ts +40 -16
  297. package/dist/preset.js +169 -51
  298. package/dist/tokens.stylex.d.ts +70 -37
  299. package/dist/tokens.stylex.js +127 -62
  300. package/dist/typography.d.ts +48 -0
  301. package/dist/typography.js +55 -0
  302. package/dist/vite.d.ts +9 -1
  303. package/dist/vite.js +37 -4
  304. package/package.json +58 -6
  305. package/skills/building-ui/SKILL.md +242 -0
  306. package/skills/building-ui/references/components.md +207 -0
  307. package/skills/markdown/SKILL.md +452 -0
  308. package/skills/markdown/references/plugins.md +103 -0
  309. package/skills/setup/SKILL.md +191 -0
  310. package/skills/styling/SKILL.md +269 -0
  311. package/skills/theming/SKILL.md +184 -0
  312. package/dist/internal/loop.d.ts +0 -35
  313. package/dist/internal/loop.js +0 -72
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Raw HTML in Markdown, through an allowlist.
3
+ *
4
+ * HTML is read into a tree of allowed elements and attributes. Nothing is ever passed to the
5
+ * page as a string: what is not on the list is dropped, and the text inside an unknown element
6
+ * stays as text. Scripts, styles and the like are dropped with their contents. Addresses in
7
+ * `href` and `src` go through the same link policy as Markdown links.
8
+ */
9
+ import type { Block, Image, Inline } from './ast.js';
10
+ export type HtmlElement = {
11
+ type: 'element';
12
+ tag: string;
13
+ attrs: Record<string, string>;
14
+ children: HtmlNode[];
15
+ };
16
+ export type HtmlText = {
17
+ type: 'text';
18
+ value: string;
19
+ };
20
+ /** A Markdown block that sits inside raw HTML, such as the body of a `<details>`. */
21
+ export type HtmlMarkdown = {
22
+ type: 'markdown';
23
+ block: Block;
24
+ };
25
+ export type HtmlNode = HtmlElement | HtmlText | HtmlMarkdown;
26
+ /** HTML blocks and the Markdown blocks they wrap, as one tree. `id` is the first block's. */
27
+ export type HtmlGroup = {
28
+ type: 'htmlGroup';
29
+ id: number;
30
+ nodes: HtmlNode[];
31
+ };
32
+ export type RenderBlock = Block | HtmlGroup;
33
+ /** Inline nodes with raw HTML tags paired into elements. */
34
+ export type HtmlInlineElement = {
35
+ type: 'htmlElement';
36
+ tag: string;
37
+ attrs: Record<string, string>;
38
+ children: RenderInline[];
39
+ };
40
+ export type RenderInline = Inline | HtmlInlineElement;
41
+ export type UrlPolicy = {
42
+ href: (url: string) => string | null;
43
+ src: (url: string) => string | null;
44
+ };
45
+ /** Elements that hold no children. */
46
+ export declare const VOID: Set<string>;
47
+ /** Reads an HTML fragment into a tree of allowed elements. */
48
+ export declare function sanitizeHtml(html: string, policy: UrlPolicy): HtmlNode[];
49
+ /**
50
+ * Joins HTML blocks with the Markdown they wrap. In CommonMark an HTML block ends at a blank
51
+ * line, so
52
+ *
53
+ * <details>
54
+ * <summary>More</summary>
55
+ *
56
+ * Some **Markdown**.
57
+ *
58
+ * </details>
59
+ *
60
+ * is three blocks: HTML, a paragraph, HTML. Here the paragraph goes inside the `<details>`
61
+ * that the first block left open, as a browser would place it. Blocks outside any open
62
+ * element are returned as they are, and a list with no HTML in it is returned unchanged.
63
+ */
64
+ export declare function groupBlockHtml(blocks: Block[], policy: UrlPolicy): RenderBlock[];
65
+ /**
66
+ * Pairs the raw HTML tags among a block's inline nodes into elements: `<kbd>`, text, `</kbd>`
67
+ * becomes one `htmlElement` holding the text. Tags that are not allowed are dropped, and
68
+ * their contents stay where they are.
69
+ */
70
+ export declare function groupInlineHtml(inlines: Inline[], policy: UrlPolicy): RenderInline[];
71
+ /**
72
+ * An HTML `<img>` or `<video>` as the image node a Markdown image would be, so both are drawn
73
+ * by the same component, and a plugin that decides which images load decides these too.
74
+ */
75
+ export declare function imageOf(element: {
76
+ tag?: string;
77
+ attrs: Record<string, string>;
78
+ }): Image;
@@ -0,0 +1,522 @@
1
+ import { decodeEntity } from './common.js';
2
+ const GLOBAL_ATTRS = ['title', 'lang', 'dir'];
3
+ /** How deep raw HTML may nest. Deeper elements are flattened into the one above them. */
4
+ const MAX_HTML_DEPTH = 128;
5
+ /** Allowed elements, and the attributes each may keep beside the global ones. */
6
+ const ALLOWED = {
7
+ a: ['href'],
8
+ abbr: [],
9
+ b: [],
10
+ bdi: [],
11
+ blockquote: ['cite'],
12
+ br: [],
13
+ caption: [],
14
+ cite: [],
15
+ code: [],
16
+ col: ['span'],
17
+ colgroup: ['span'],
18
+ dd: [],
19
+ del: [],
20
+ details: ['open'],
21
+ dfn: [],
22
+ div: ['align'],
23
+ dl: [],
24
+ dt: [],
25
+ em: [],
26
+ figcaption: [],
27
+ figure: [],
28
+ h1: ['align'],
29
+ h2: ['align'],
30
+ h3: ['align'],
31
+ h4: ['align'],
32
+ h5: ['align'],
33
+ h6: ['align'],
34
+ hr: [],
35
+ i: [],
36
+ img: ['src', 'alt', 'width', 'height', 'align'],
37
+ // Drawn by the image component, as an image is: see `mediaOf`
38
+ video: ['src', 'width', 'height'],
39
+ ins: [],
40
+ kbd: [],
41
+ li: ['value'],
42
+ mark: [],
43
+ ol: ['start', 'type', 'reversed'],
44
+ p: ['align'],
45
+ pre: [],
46
+ q: ['cite'],
47
+ rp: [],
48
+ rt: [],
49
+ ruby: [],
50
+ s: [],
51
+ samp: [],
52
+ small: [],
53
+ span: [],
54
+ strike: [],
55
+ strong: [],
56
+ sub: [],
57
+ summary: [],
58
+ sup: [],
59
+ table: ['align'],
60
+ tbody: [],
61
+ td: ['colspan', 'rowspan', 'align'],
62
+ tfoot: [],
63
+ th: ['colspan', 'rowspan', 'align'],
64
+ thead: [],
65
+ time: ['datetime'],
66
+ tr: [],
67
+ tt: [],
68
+ u: [],
69
+ ul: [],
70
+ var: [],
71
+ wbr: []
72
+ };
73
+ /** Elements that hold no children. */
74
+ export const VOID = new Set([
75
+ 'br',
76
+ 'col',
77
+ 'hr',
78
+ 'img',
79
+ 'wbr',
80
+ 'input',
81
+ 'source',
82
+ 'area',
83
+ 'base',
84
+ 'link',
85
+ 'meta',
86
+ 'embed',
87
+ 'track',
88
+ 'param'
89
+ ]);
90
+ /** Elements dropped with everything inside them. */
91
+ const DROP = new Set([
92
+ 'script',
93
+ 'style',
94
+ 'textarea',
95
+ 'title',
96
+ 'xmp',
97
+ 'iframe',
98
+ 'noembed',
99
+ 'noframes',
100
+ 'plaintext',
101
+ 'noscript',
102
+ 'template',
103
+ 'object',
104
+ 'svg',
105
+ 'math',
106
+ 'select',
107
+ 'button',
108
+ 'form',
109
+ 'head'
110
+ ]);
111
+ /**
112
+ * Every element name HTML has or had. One of these that is not allowed is left out quietly,
113
+ * with its contents kept; a name that is not here at all is shown as the text it was written as.
114
+ */
115
+ const HTML_TAGS = new Set(('a abbr acronym address applet area article aside audio b base basefont bdi bdo bgsound big ' +
116
+ 'blink blockquote body br button canvas caption center cite code col colgroup data datalist ' +
117
+ 'dd del details dfn dialog dir div dl dt em embed fieldset figcaption figure font footer form ' +
118
+ 'frame frameset h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe image img input ins ' +
119
+ 'isindex kbd label legend li link main map mark marquee math menu meta meter nav nobr ' +
120
+ 'noembed noframes noscript object ol optgroup option output p param picture plaintext pre ' +
121
+ 'progress q rp rt ruby s samp script search section select slot small source span strike ' +
122
+ 'strong style sub summary sup svg table tbody td template textarea tfoot th thead time ' +
123
+ 'title tr track tt u ul var video wbr xmp').split(' '));
124
+ const reAttr = /([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/g;
125
+ const reEntity = /&(?:#x[a-f0-9]{1,6}|#[0-9]{1,7}|[a-z][a-z0-9]{1,31});/gi;
126
+ function decode(s) {
127
+ return s.replace(reEntity, decodeEntity);
128
+ }
129
+ /** Splits HTML into text, opening tags and closing tags. Comments and declarations are dropped. */
130
+ function tokenize(html) {
131
+ const tokens = [];
132
+ let i = 0;
133
+ while (i < html.length) {
134
+ const lt = html.indexOf('<', i);
135
+ if (lt < 0) {
136
+ tokens.push({ kind: 'text', value: decode(html.slice(i)) });
137
+ break;
138
+ }
139
+ if (lt > i)
140
+ tokens.push({ kind: 'text', value: decode(html.slice(i, lt)) });
141
+ if (html.startsWith('<!--', lt)) {
142
+ const end = html.indexOf('-->', lt + 4);
143
+ i = end < 0 ? html.length : end + 3;
144
+ continue;
145
+ }
146
+ if (html.startsWith('<![CDATA[', lt)) {
147
+ const end = html.indexOf(']]>', lt);
148
+ i = end < 0 ? html.length : end + 3;
149
+ continue;
150
+ }
151
+ if (html[lt + 1] === '!' || html[lt + 1] === '?') {
152
+ const end = html.indexOf('>', lt);
153
+ i = end < 0 ? html.length : end + 1;
154
+ continue;
155
+ }
156
+ const m = /^<(\/?)([A-Za-z][A-Za-z0-9-]*)((?:\s+[^\s"'<>/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?)*)\s*(\/?)>/.exec(html.slice(lt));
157
+ if (!m) {
158
+ tokens.push({ kind: 'text', value: '<' });
159
+ i = lt + 1;
160
+ continue;
161
+ }
162
+ const tag = m[2].toLowerCase();
163
+ // `<Button>`, `<T>` and `<my-element>` are not HTML: in a reply about code they are
164
+ // something the writer meant to be read, so they stay as text
165
+ // (`<BR>` and `<DIV>` are HTML in capitals, and nobody names a component `<Br>`)
166
+ const mixed = /[a-z]/.test(m[2]) && /[A-Z]/.test(m[2]);
167
+ if ((mixed && tag !== 'br' && tag !== 'hr' && tag !== 'wbr') || !HTML_TAGS.has(tag)) {
168
+ tokens.push({ kind: 'text', value: m[0] });
169
+ i = lt + m[0].length;
170
+ continue;
171
+ }
172
+ if (m[1]) {
173
+ tokens.push({ kind: 'close', tag });
174
+ }
175
+ else {
176
+ const attrs = {};
177
+ reAttr.lastIndex = 0;
178
+ let a;
179
+ while ((a = reAttr.exec(m[3]))) {
180
+ const name = a[1].toLowerCase();
181
+ if (!(name in attrs))
182
+ attrs[name] = decode(a[2] ?? a[3] ?? a[4] ?? '');
183
+ }
184
+ tokens.push({ kind: 'open', tag, attrs, selfClosing: m[4] === '/', raw: m[0] });
185
+ }
186
+ i = lt + m[0].length;
187
+ }
188
+ return tokens;
189
+ }
190
+ /** Keeps the attributes an element may have, with addresses checked. */
191
+ function cleanAttrs(tag, attrs, policy) {
192
+ // Looked up as its own entry: `constructor` and `toString` are not elements
193
+ if (!Object.hasOwn(ALLOWED, tag))
194
+ return null;
195
+ const allowed = ALLOWED[tag];
196
+ const out = {};
197
+ for (const [name, value] of Object.entries(attrs)) {
198
+ if (!GLOBAL_ATTRS.includes(name) && !allowed.includes(name))
199
+ continue;
200
+ // A size is a number of pixels or a percentage, of a sane length
201
+ if ((name === 'width' || name === 'height') && !/^\d{1,4}%?$/.test(value.trim()))
202
+ continue;
203
+ if ((name === 'colspan' || name === 'rowspan' || name === 'span') &&
204
+ !/^\d{1,3}$/.test(value.trim()))
205
+ continue;
206
+ if (name === 'href' || name === 'cite') {
207
+ const href = policy.href(value);
208
+ if (href !== null)
209
+ out[name] = href;
210
+ }
211
+ else if (name === 'src') {
212
+ // An image is drawn by the same component as a Markdown image, which decides
213
+ // whether it may load, so its address is kept as written. Nothing else has a `src`.
214
+ if (tag === 'img' || tag === 'video')
215
+ out[name] = value;
216
+ else {
217
+ const src = policy.src(value);
218
+ if (src !== null)
219
+ out[name] = src;
220
+ }
221
+ }
222
+ else {
223
+ out[name] = value;
224
+ }
225
+ }
226
+ // An image with no address it may load has nothing to show
227
+ if ((tag === 'img' || tag === 'video') && !('src' in out))
228
+ return null;
229
+ return out;
230
+ }
231
+ /** Builds a tree of allowed elements from HTML that may arrive in several pieces. */
232
+ class HtmlBuilder {
233
+ policy;
234
+ root = { type: 'element', tag: '#root', attrs: {}, children: [] };
235
+ // The open elements, innermost last. A disallowed element is kept here as null, so its end
236
+ // tag finds it, but its children go to the nearest allowed ancestor.
237
+ stack = [
238
+ { tag: '#root', element: this.root }
239
+ ];
240
+ dropping = null;
241
+ dropDepth = 0;
242
+ constructor(policy) {
243
+ this.policy = policy;
244
+ }
245
+ /** Whether an element is still open, so what comes next belongs inside it. */
246
+ get open() {
247
+ // An element that is not allowed has nothing to put later blocks inside
248
+ return this.stack.some((entry, i) => i > 0 && entry.element !== null);
249
+ }
250
+ parent() {
251
+ for (let i = this.stack.length - 1; i >= 0; i--) {
252
+ const element = this.stack[i].element;
253
+ if (element)
254
+ return element;
255
+ }
256
+ return this.root;
257
+ }
258
+ /** Puts a node inside the innermost open element. */
259
+ add(node) {
260
+ if (this.dropping)
261
+ return;
262
+ const parent = this.parent();
263
+ // A paragraph cannot hold blocks: a browser reading the server's HTML would close it
264
+ // early, and the page would no longer match. A `<p align="center">` around Markdown,
265
+ // common in READMEs, becomes a `<div>`.
266
+ if (node.type === 'markdown' && parent.tag === 'p')
267
+ parent.tag = 'div';
268
+ parent.children.push(node);
269
+ }
270
+ feed(html) {
271
+ const tokens = tokenize(html);
272
+ // Where each tag's last end tag is, found once: asking again for every dropped tag
273
+ // made a thousand unclosed `<title>`s take a thousand passes
274
+ const lastClose = new Map();
275
+ for (let t = 0; t < tokens.length; t++) {
276
+ const token = tokens[t];
277
+ if (token.kind === 'close')
278
+ lastClose.set(token.tag, t);
279
+ }
280
+ for (let t = 0; t < tokens.length; t++) {
281
+ const token = tokens[t];
282
+ if (this.dropping) {
283
+ if (token.kind === 'open' && token.tag === this.dropping && !token.selfClosing)
284
+ this.dropDepth++;
285
+ if (token.kind === 'close' && token.tag === this.dropping && --this.dropDepth === 0)
286
+ this.dropping = null;
287
+ continue;
288
+ }
289
+ if (token.kind === 'text') {
290
+ if (token.value === '')
291
+ continue;
292
+ const p = this.parent();
293
+ const last = p.children[p.children.length - 1];
294
+ if (last && last.type === 'text')
295
+ last.value += token.value;
296
+ else
297
+ p.children.push({ type: 'text', value: token.value });
298
+ }
299
+ else if (token.kind === 'open') {
300
+ if (token.tag === 'video') {
301
+ // A video is one thing, like an image: its address is its own, or its first
302
+ // `<source>`'s, and what is inside it (sources, tracks, words for browsers
303
+ // that cannot play it) is left out
304
+ const end = tokens.findIndex((later, at) => at > t && later.kind === 'close' && later.tag === 'video');
305
+ let src = token.attrs.src;
306
+ for (let k = t + 1; src === undefined && k < end; k++) {
307
+ const inner = tokens[k];
308
+ if (inner.kind === 'open' && inner.tag === 'source')
309
+ src = inner.attrs.src;
310
+ }
311
+ const attrs = src === undefined ? null : cleanAttrs('video', { ...token.attrs, src }, this.policy);
312
+ if (attrs)
313
+ this.parent().children.push({ type: 'element', tag: 'video', attrs, children: [] });
314
+ if (end > t && !token.selfClosing) {
315
+ this.dropping = 'video';
316
+ this.dropDepth = 1;
317
+ }
318
+ continue;
319
+ }
320
+ if (DROP.has(token.tag)) {
321
+ if (!token.selfClosing && !VOID.has(token.tag)) {
322
+ // Dropped with what is inside it, up to its end tag. Without one in this
323
+ // block, nothing says where it ends: a `<title>` in a sentence would take
324
+ // the rest of the reply with it. It is then shown as the text it is.
325
+ const closed = (lastClose.get(token.tag) ?? -1) > t;
326
+ if (closed) {
327
+ this.dropping = token.tag;
328
+ this.dropDepth = 1;
329
+ }
330
+ else {
331
+ const p = this.parent();
332
+ const last = p.children[p.children.length - 1];
333
+ if (last && last.type === 'text')
334
+ last.value += token.raw;
335
+ else
336
+ p.children.push({ type: 'text', value: token.raw });
337
+ }
338
+ }
339
+ continue;
340
+ }
341
+ // A browser puts rows in a `<tbody>`; do the same, so server and client agree
342
+ if (token.tag === 'tr' && this.parent().tag === 'table') {
343
+ const tbody = { type: 'element', tag: 'tbody', attrs: {}, children: [] };
344
+ this.parent().children.push(tbody);
345
+ this.stack.push({ tag: 'tbody', element: tbody });
346
+ }
347
+ const attrs = cleanAttrs(token.tag, token.attrs, this.policy);
348
+ const element = attrs
349
+ ? { type: 'element', tag: token.tag, attrs, children: [] }
350
+ : null;
351
+ if (element)
352
+ this.parent().children.push(element);
353
+ // Past the limit an element still shows, but what follows is not put inside it: the
354
+ // tree stays shallow enough to draw, and an end tag has little to search
355
+ if (!VOID.has(token.tag) && !token.selfClosing && this.stack.length < MAX_HTML_DEPTH)
356
+ this.stack.push({ tag: token.tag, element });
357
+ }
358
+ else {
359
+ // Close the nearest open element with this name, and anything left open inside it
360
+ for (let i = this.stack.length - 1; i > 0; i--) {
361
+ if (this.stack[i].tag === token.tag) {
362
+ this.stack.length = i;
363
+ break;
364
+ }
365
+ }
366
+ }
367
+ }
368
+ }
369
+ }
370
+ /** Reads an HTML fragment into a tree of allowed elements. */
371
+ export function sanitizeHtml(html, policy) {
372
+ const builder = new HtmlBuilder(policy);
373
+ builder.feed(html);
374
+ return builder.root.children;
375
+ }
376
+ /**
377
+ * Joins HTML blocks with the Markdown they wrap. In CommonMark an HTML block ends at a blank
378
+ * line, so
379
+ *
380
+ * <details>
381
+ * <summary>More</summary>
382
+ *
383
+ * Some **Markdown**.
384
+ *
385
+ * </details>
386
+ *
387
+ * is three blocks: HTML, a paragraph, HTML. Here the paragraph goes inside the `<details>`
388
+ * that the first block left open, as a browser would place it. Blocks outside any open
389
+ * element are returned as they are, and a list with no HTML in it is returned unchanged.
390
+ */
391
+ export function groupBlockHtml(blocks, policy) {
392
+ if (!blocks.some((block) => block.type === 'html'))
393
+ return blocks;
394
+ const out = [];
395
+ let builder = null;
396
+ let id = 0;
397
+ const flush = () => {
398
+ if (builder && builder.root.children.length > 0) {
399
+ out.push({ type: 'htmlGroup', id, nodes: builder.root.children });
400
+ }
401
+ builder = null;
402
+ };
403
+ for (const block of blocks) {
404
+ if (block.type === 'html') {
405
+ if (!builder) {
406
+ builder = new HtmlBuilder(policy);
407
+ id = block.id;
408
+ }
409
+ builder.feed(block.value);
410
+ }
411
+ else if (builder?.open) {
412
+ builder.add({ type: 'markdown', block });
413
+ }
414
+ else {
415
+ flush();
416
+ out.push(block);
417
+ }
418
+ }
419
+ flush();
420
+ return out;
421
+ }
422
+ /**
423
+ * Pairs the raw HTML tags among a block's inline nodes into elements: `<kbd>`, text, `</kbd>`
424
+ * becomes one `htmlElement` holding the text. Tags that are not allowed are dropped, and
425
+ * their contents stay where they are.
426
+ */
427
+ export function groupInlineHtml(inlines, policy) {
428
+ if (!inlines.some((n) => n.type === 'inlineHtml'))
429
+ return inlines;
430
+ const root = { type: 'htmlElement', tag: '#root', attrs: {}, children: [] };
431
+ const stack = [
432
+ { tag: '#root', element: root }
433
+ ];
434
+ const parent = () => {
435
+ for (let i = stack.length - 1; i >= 0; i--)
436
+ if (stack[i].element)
437
+ return stack[i].element;
438
+ return root;
439
+ };
440
+ // Inside a `<video>` that is closed further on, nothing is kept: see the block builder
441
+ let inVideo = false;
442
+ for (const [index, node] of inlines.entries()) {
443
+ if (node.type !== 'inlineHtml') {
444
+ if (!inVideo)
445
+ parent().children.push(node);
446
+ continue;
447
+ }
448
+ for (const token of tokenize(node.value)) {
449
+ if (inVideo) {
450
+ if (token.kind === 'close' && token.tag === 'video')
451
+ inVideo = false;
452
+ continue;
453
+ }
454
+ if (token.kind === 'text') {
455
+ if (token.value)
456
+ parent().children.push({ type: 'text', value: token.value });
457
+ }
458
+ else if (token.kind === 'open') {
459
+ if (token.tag === 'video') {
460
+ // Its address is its own, or its first `<source>`'s, up to its end tag
461
+ let closed = false;
462
+ let src = token.attrs.src;
463
+ for (let at = index; at < inlines.length && !closed; at++) {
464
+ const later = inlines[at];
465
+ if (later.type !== 'inlineHtml')
466
+ continue;
467
+ for (const inner of tokenize(later.value)) {
468
+ if (inner.kind === 'close' && inner.tag === 'video')
469
+ closed = true;
470
+ else if (inner.kind === 'open' && inner.tag === 'source' && at > index)
471
+ src ??= inner.attrs.src;
472
+ }
473
+ }
474
+ const attrs = src === undefined ? null : cleanAttrs('video', { ...token.attrs, src }, policy);
475
+ if (attrs)
476
+ parent().children.push({ type: 'htmlElement', tag: 'video', attrs, children: [] });
477
+ inVideo = closed && !token.selfClosing;
478
+ continue;
479
+ }
480
+ if (DROP.has(token.tag))
481
+ continue;
482
+ const attrs = cleanAttrs(token.tag, token.attrs, policy);
483
+ const element = attrs
484
+ ? { type: 'htmlElement', tag: token.tag, attrs, children: [] }
485
+ : null;
486
+ if (element)
487
+ parent().children.push(element);
488
+ if (!VOID.has(token.tag) && !token.selfClosing && stack.length < MAX_HTML_DEPTH)
489
+ stack.push({ tag: token.tag, element });
490
+ }
491
+ else {
492
+ for (let i = stack.length - 1; i > 0; i--) {
493
+ if (stack[i].tag === token.tag) {
494
+ stack.length = i;
495
+ break;
496
+ }
497
+ }
498
+ }
499
+ }
500
+ }
501
+ return root.children;
502
+ }
503
+ const imageNodes = new WeakMap();
504
+ /**
505
+ * An HTML `<img>` or `<video>` as the image node a Markdown image would be, so both are drawn
506
+ * by the same component, and a plugin that decides which images load decides these too.
507
+ */
508
+ export function imageOf(element) {
509
+ let image = imageNodes.get(element);
510
+ if (!image) {
511
+ const { src = '', alt = '', title, width, height } = element.attrs;
512
+ image = { type: 'image', url: src, alt, title: title ?? null, children: [] };
513
+ if (width)
514
+ image.width = width;
515
+ if (height)
516
+ image.height = height;
517
+ if (element.tag === 'video')
518
+ image.video = true;
519
+ imageNodes.set(element, image);
520
+ }
521
+ return image;
522
+ }
@@ -0,0 +1,12 @@
1
+ import type { Document } from './ast.js';
2
+ /**
3
+ * Keeps what did not change between two snapshots of a document the same objects.
4
+ *
5
+ * A finished block is the same object from one snapshot to the next already. The unfinished
6
+ * end is read again each time, and comes back as new objects all the way down, though most of
7
+ * it says what it said before: a long paragraph that grew by a word is new text at its end and
8
+ * the same hundred parts before that. Here each new node that says what the old one in its
9
+ * place said gives way to the old one, so whoever draws the document can tell what changed by
10
+ * looking at which objects are new, and leave the rest alone.
11
+ */
12
+ export declare function shareDocument(before: Document | null, after: Document): Document;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Keeps what did not change between two snapshots of a document the same objects.
3
+ *
4
+ * A finished block is the same object from one snapshot to the next already. The unfinished
5
+ * end is read again each time, and comes back as new objects all the way down, though most of
6
+ * it says what it said before: a long paragraph that grew by a word is new text at its end and
7
+ * the same hundred parts before that. Here each new node that says what the old one in its
8
+ * place said gives way to the old one, so whoever draws the document can tell what changed by
9
+ * looking at which objects are new, and leave the rest alone.
10
+ */
11
+ export function shareDocument(before, after) {
12
+ return before ? shareNode(before, after) : after;
13
+ }
14
+ function shareNode(before, after) {
15
+ if (before === after)
16
+ return before;
17
+ if (typeof after !== 'object' || after === null || typeof before !== 'object' || before === null)
18
+ return after;
19
+ if (Array.isArray(after)) {
20
+ if (!Array.isArray(before))
21
+ return after;
22
+ let same = before.length === after.length;
23
+ for (let i = 0; i < after.length; i++) {
24
+ const item = after[i];
25
+ const shared = i < before.length ? shareNode(before[i], item) : item;
26
+ // The old object says the same, so putting it here changes nothing the array says
27
+ if (shared !== item)
28
+ after[i] = shared;
29
+ if (shared !== before[i])
30
+ same = false;
31
+ }
32
+ return same ? before : after;
33
+ }
34
+ if (Array.isArray(before))
35
+ return after;
36
+ const a = before;
37
+ const b = after;
38
+ let same = true;
39
+ for (const key in b) {
40
+ const value = b[key];
41
+ if (typeof value === 'object' && value !== null) {
42
+ const shared = shareNode(a[key], value);
43
+ if (shared !== value)
44
+ b[key] = shared;
45
+ if (shared !== a[key])
46
+ same = false;
47
+ }
48
+ else if (value !== a[key] || !(key in a)) {
49
+ same = false;
50
+ }
51
+ }
52
+ if (!same)
53
+ return after;
54
+ // And the old one says nothing more than the new
55
+ for (const key in a)
56
+ if (!(key in b))
57
+ return after;
58
+ return before;
59
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A table, written out again: as Markdown, or as CSV for a spreadsheet.
3
+ */
4
+ import type { Inline, Table } from './ast.js';
5
+ /** The text of inline nodes, without their formatting. A formula is its TeX. */
6
+ export declare function inlineText(nodes: Inline[]): string;
7
+ /** The table as Markdown, with its cells as they were written. */
8
+ export declare function tableToMarkdown(table: Table): string;
9
+ /**
10
+ * The table as CSV (RFC 4180): cells as plain text, quoted where they hold a quote, the
11
+ * separator or a line ending, and kept from being read as formulas. `separator` is a comma by default; a tab makes TSV.
12
+ */
13
+ export declare function tableToCsv(table: Table, separator?: string): string;