@bendyline/squisq-formats 2.8.7 → 2.8.9

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 (39) hide show
  1. package/README.md +21 -0
  2. package/dist/chunk-4LIFEQKX.js +358 -0
  3. package/dist/{chunk-UXEANVBI.js → chunk-5HUHSLGA.js} +1 -84
  4. package/dist/{chunk-IYNDHW2C.js → chunk-6HUQFEP3.js} +75 -5
  5. package/dist/{chunk-BXWNU4T5.js → chunk-DTJQK7U7.js} +43 -0
  6. package/dist/{chunk-QU4EVC62.js → chunk-GFHUJ7L4.js} +1 -1
  7. package/dist/{chunk-TMOXUUTG.js → chunk-NQNIFIDP.js} +6 -4
  8. package/dist/{chunk-B6UQPW75.js → chunk-SZ3OIY6G.js} +697 -44
  9. package/dist/{chunk-KROH7FNT.js → chunk-VKLJUHC2.js} +6 -4
  10. package/dist/{chunk-C23JYVPG.js → chunk-WJTC5OD6.js} +2 -0
  11. package/dist/{chunk-ALDCFHZT.js → chunk-WVDAFJFS.js} +59 -21
  12. package/dist/chunk-YRFBWYAD.js +128 -0
  13. package/dist/{chunk-SVYTUYZM.js → chunk-ZJERBWTB.js} +6 -4
  14. package/dist/data/index.d.ts +27 -5
  15. package/dist/data/index.js +6 -2
  16. package/dist/diagrams/index.d.ts +19 -8
  17. package/dist/diagrams/index.js +7 -242
  18. package/dist/docx/index.d.ts +1 -1
  19. package/dist/docx/index.js +3 -3
  20. package/dist/epub/index.d.ts +1 -1
  21. package/dist/epub/index.js +3 -3
  22. package/dist/fontAwesome-C6FRDYTY.js +14 -0
  23. package/dist/html/index.d.ts +214 -2
  24. package/dist/html/index.js +25 -4
  25. package/dist/index.d.ts +4 -2
  26. package/dist/index.js +15 -10
  27. package/dist/{materialize-G4WC5UG3.js → materialize-ICXNO4S4.js} +4 -1
  28. package/dist/outside-in/index.d.ts +21 -2
  29. package/dist/outside-in/index.js +7 -3
  30. package/dist/outside-in/layout.d.ts +7 -1
  31. package/dist/outside-in/layout.js +3 -1
  32. package/dist/pdf/index.d.ts +1 -1
  33. package/dist/pdf/index.js +3 -3
  34. package/dist/plainHtmlIcons-KBSIJ5EN.js +62 -0
  35. package/dist/pptx/index.js +2 -2
  36. package/dist/readers-3P5A6A2A.js +17 -0
  37. package/dist/registry/index.js +1 -1
  38. package/package.json +2 -2
  39. /package/dist/{chunk-LBXBRFBZ.js → chunk-DDMPZZJF.js} +0 -0
@@ -1,248 +1,13 @@
1
- // src/diagrams/index.ts
2
1
  import {
3
- extractPlainText,
4
- isSvgIslandLang,
5
- parseSvgIsland,
6
- stringifyMarkdown
7
- } from "@bendyline/squisq/markdown";
8
- import {
9
- detectAsciiDiagram,
10
- detectAsciiTimeline,
11
- detectTree,
12
- isContainerTemplate,
13
- isEligibleAsciiFenceLang,
14
- isEligibleAsciiTimelineFenceLang,
15
- isEligibleTreeFenceLang,
16
- isExplicitDiagramLang,
17
- isExplicitTimelineLang,
18
- isExplicitTreeLang,
19
- resolveTemplateName
20
- } from "@bendyline/squisq/doc";
21
- var DEFAULT_KINDS = [
22
- "mermaid",
23
- "diagram",
24
- "timeline",
25
- "tree",
26
- "container"
27
- ];
28
- var EXPORT_DIAGRAM_KINDS = [...DEFAULT_KINDS, "svg"];
29
- var KIND_NAMES = {
30
- mermaid: "Diagram",
31
- diagram: "Diagram",
32
- timeline: "Timeline",
33
- tree: "Tree",
34
- container: "Diagram",
35
- svg: "Illustration"
36
- };
37
- function fenceDiagramKind(node) {
38
- const lang = node.lang ?? null;
39
- if ((lang ?? "").trim().toLowerCase() === "mermaid") return "mermaid";
40
- if (isSvgIslandLang(lang)) return parseSvgIsland(node.value).ok ? "svg" : null;
41
- if (isEligibleAsciiFenceLang(lang)) {
42
- const detection = detectAsciiDiagram(node.value, { explicit: isExplicitDiagramLang(lang) });
43
- if (detection.isDiagram) return "diagram";
44
- }
45
- if (isEligibleTreeFenceLang(lang)) {
46
- if (detectTree(node.value, { explicit: isExplicitTreeLang(lang) }).isTree) return "tree";
47
- }
48
- if (isEligibleAsciiTimelineFenceLang(lang)) {
49
- const detection = detectAsciiTimeline(node.value, { explicit: isExplicitTimelineLang(lang) });
50
- if (detection.isTimeline) return "timeline";
51
- }
52
- return null;
53
- }
54
- function containerTemplateOf(node) {
55
- if (node.type !== "heading") return null;
56
- const requested = node.templateAnnotation?.template;
57
- if (!requested || !isContainerTemplate(requested)) return null;
58
- return resolveTemplateName(requested);
59
- }
60
- function mermaidAlt(source) {
61
- const title = /^\s*accTitle\s*:\s*(.+?)\s*$/mu.exec(source)?.[1] ?? "";
62
- const description = /^\s*accDescr\s*:\s*(.+?)\s*$/mu.exec(source)?.[1] ?? "";
63
- return [title, description].filter(Boolean).join(". ");
64
- }
65
- function fenceAlt(kind, source) {
66
- if (kind === "mermaid") return mermaidAlt(source);
67
- if (kind === "svg") {
68
- const result = parseSvgIsland(source);
69
- return result.ok && result.island.title || "";
70
- }
71
- return "";
72
- }
73
- function fenceMarkdown(node) {
74
- return stringifyMarkdown({ type: "document", children: [node] }).trim();
75
- }
76
- function findInDocument(doc) {
77
- const found = [];
78
- const children = doc.children;
79
- const walk = (nodes) => {
80
- for (const node of nodes) {
81
- if (node.type === "code") {
82
- const fence = node;
83
- const kind = fenceDiagramKind(fence);
84
- if (kind) {
85
- found.push({
86
- fence,
87
- diagram: {
88
- kind,
89
- markdown: fenceMarkdown(fence),
90
- source: fence.value,
91
- template: "",
92
- alt: fenceAlt(kind, fence.value) || KIND_NAMES[kind]
93
- }
94
- });
95
- }
96
- continue;
97
- }
98
- const nested = node.children;
99
- if (Array.isArray(nested) && node.type !== "heading" && node.type !== "paragraph") {
100
- walk(nested);
101
- }
102
- }
103
- };
104
- for (let index = 0; index < children.length; index++) {
105
- const node = children[index];
106
- const template = containerTemplateOf(node);
107
- if (!template) {
108
- walk([node]);
109
- continue;
110
- }
111
- const depth = node.depth;
112
- let end = index + 1;
113
- while (end < children.length) {
114
- const next = children[end];
115
- if (next.type === "heading" && next.depth <= depth) break;
116
- end++;
117
- }
118
- const heading = extractPlainText(node).trim();
119
- found.push({
120
- containerIndex: index,
121
- containerEnd: end,
122
- diagram: {
123
- kind: "container",
124
- markdown: stringifyMarkdown({
125
- type: "document",
126
- children: children.slice(index, end)
127
- }).trim(),
128
- source: "",
129
- template,
130
- alt: heading || KIND_NAMES.container
131
- }
132
- });
133
- index = end - 1;
134
- }
135
- return found;
136
- }
137
- function imageUrls(nodes, into) {
138
- for (const node of nodes) {
139
- if (node.type === "image") into.add(node.url);
140
- const nested = node.children;
141
- if (Array.isArray(nested)) imageUrls(nested, into);
142
- }
143
- return into;
144
- }
145
- function findDiagrams(doc) {
146
- return findInDocument(doc).map((entry) => entry.diagram);
147
- }
148
- function imageParagraph(url, alt) {
149
- const image = { type: "image", url, alt, title: null };
150
- return { type: "paragraph", children: [image] };
151
- }
152
- function replaceFences(nodes, replacements) {
153
- let changed = false;
154
- const next = nodes.map((node) => {
155
- const replacement = replacements.get(node);
156
- if (replacement) {
157
- changed = true;
158
- return replacement;
159
- }
160
- const nested = node.children;
161
- if (Array.isArray(nested)) {
162
- const replaced = replaceFences(nested, replacements);
163
- if (replaced !== nested) {
164
- changed = true;
165
- return { ...node, children: replaced };
166
- }
167
- }
168
- return node;
169
- });
170
- return changed ? next : nodes;
171
- }
172
- async function rasterizeDiagrams(doc, render, options = {}) {
173
- const kinds = new Set(options.kinds ?? DEFAULT_KINDS);
174
- const prefix = options.urlPrefix ?? "diagram";
175
- const taken = imageUrls(doc.children, /* @__PURE__ */ new Set());
176
- let counter = 0;
177
- const nextUrl = () => {
178
- let url;
179
- do
180
- url = `${prefix}-${String(++counter)}.png`;
181
- while (taken.has(url));
182
- taken.add(url);
183
- return url;
184
- };
185
- const images = /* @__PURE__ */ new Map();
186
- const mermaid = /* @__PURE__ */ new Map();
187
- const svg = /* @__PURE__ */ new Map();
188
- const fenceReplacements = /* @__PURE__ */ new Map();
189
- const containerReplacements = [];
190
- for (const entry of findInDocument(doc)) {
191
- options.signal?.throwIfAborted();
192
- if (!kinds.has(entry.diagram.kind)) continue;
193
- let picture = null;
194
- try {
195
- picture = await render(entry.diagram);
196
- } catch (error) {
197
- options.onWarning?.(
198
- `A ${KIND_NAMES[entry.diagram.kind].toLowerCase()} could not be drawn and was kept as text: ${error instanceof Error ? error.message : String(error)}`
199
- );
200
- }
201
- if (!picture || picture.width <= 0 || picture.height <= 0) continue;
202
- const data = picture.data instanceof Uint8Array ? picture.data : new Uint8Array(picture.data);
203
- const url = nextUrl();
204
- images.set(url, {
205
- data,
206
- contentType: "image/png",
207
- width: picture.width,
208
- height: picture.height
209
- });
210
- if (entry.diagram.kind === "mermaid") mermaid.set(entry.diagram.source.trim(), picture);
211
- if (entry.diagram.kind === "svg") svg.set(entry.diagram.source.trim(), picture);
212
- const paragraph = imageParagraph(url, entry.diagram.alt);
213
- if (entry.fence) {
214
- fenceReplacements.set(entry.fence, paragraph);
215
- } else if (entry.containerIndex !== void 0 && entry.containerEnd !== void 0) {
216
- const heading = doc.children[entry.containerIndex];
217
- const { templateAnnotation: _template, ...plainHeading } = heading;
218
- containerReplacements.push({
219
- start: entry.containerIndex,
220
- end: entry.containerEnd,
221
- nodes: [plainHeading, paragraph]
222
- });
223
- }
224
- }
225
- let children = doc.children;
226
- if (containerReplacements.length > 0) {
227
- const rebuilt = [];
228
- let cursor = 0;
229
- for (const replacement of containerReplacements) {
230
- rebuilt.push(...children.slice(cursor, replacement.start), ...replacement.nodes);
231
- cursor = replacement.end;
232
- }
233
- rebuilt.push(...children.slice(cursor));
234
- children = rebuilt;
235
- }
236
- if (fenceReplacements.size > 0) children = replaceFences(children, fenceReplacements);
237
- return {
238
- markdownDoc: children === doc.children ? doc : { ...doc, children },
239
- images,
240
- mermaid,
241
- svg
242
- };
243
- }
2
+ EXPORT_DIAGRAM_KINDS,
3
+ cachingDiagramRasterizer,
4
+ fenceDiagramKind,
5
+ findDiagrams,
6
+ rasterizeDiagrams
7
+ } from "../chunk-4LIFEQKX.js";
244
8
  export {
245
9
  EXPORT_DIAGRAM_KINDS,
10
+ cachingDiagramRasterizer,
246
11
  fenceDiagramKind,
247
12
  findDiagrams,
248
13
  rasterizeDiagrams
@@ -84,7 +84,7 @@ interface DocxExportOptions {
84
84
  * @param options - Export options
85
85
  * @returns An ArrayBuffer containing the .docx file
86
86
  */
87
- declare function markdownDocToDocx(doc: MarkdownDocument, options?: DocxExportOptions): Promise<ArrayBuffer>;
87
+ declare function markdownDocToDocx(source: MarkdownDocument, options?: DocxExportOptions): Promise<ArrayBuffer>;
88
88
  /**
89
89
  * Convert a squisq Doc to a .docx Blob.
90
90
  *
@@ -4,7 +4,7 @@ import {
4
4
  docxToDoc,
5
5
  docxToMarkdownDoc,
6
6
  markdownDocToDocx
7
- } from "../chunk-KROH7FNT.js";
7
+ } from "../chunk-VKLJUHC2.js";
8
8
  import "../chunk-DHAK4PII.js";
9
9
  import "../chunk-VCZUXQUL.js";
10
10
  import "../chunk-BZ5SHMOY.js";
@@ -12,9 +12,9 @@ import "../chunk-ILCJ3WFD.js";
12
12
  import "../chunk-JU2RHXUB.js";
13
13
  import "../chunk-S5PCVMKU.js";
14
14
  import "../chunk-7AWFHP5U.js";
15
- import "../chunk-BXWNU4T5.js";
15
+ import "../chunk-DTJQK7U7.js";
16
16
  import "../chunk-IIQYS2YH.js";
17
- import "../chunk-LBXBRFBZ.js";
17
+ import "../chunk-DDMPZZJF.js";
18
18
  import "../chunk-JZR32FON.js";
19
19
  export {
20
20
  docToDocx,
@@ -66,7 +66,7 @@ interface EpubExportOptions {
66
66
  * Chapters are split at H1/H2 heading boundaries. All referenced images
67
67
  * (provided via `options.images`) are embedded in the archive.
68
68
  */
69
- declare function markdownDocToEpub(sourceDoc: MarkdownDocument, options?: EpubExportOptions): Promise<ArrayBuffer>;
69
+ declare function markdownDocToEpub(authoredDoc: MarkdownDocument, options?: EpubExportOptions): Promise<ArrayBuffer>;
70
70
  /**
71
71
  * Convert a squisq Doc to an EPUB 3 file.
72
72
  *
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  docToEpub,
3
3
  markdownDocToEpub
4
- } from "../chunk-SVYTUYZM.js";
4
+ } from "../chunk-ZJERBWTB.js";
5
5
  import "../chunk-WMIDXNGR.js";
6
6
  import "../chunk-VCZUXQUL.js";
7
7
  import "../chunk-BZ5SHMOY.js";
8
8
  import "../chunk-JU2RHXUB.js";
9
- import "../chunk-BXWNU4T5.js";
10
- import "../chunk-LBXBRFBZ.js";
9
+ import "../chunk-DTJQK7U7.js";
10
+ import "../chunk-DDMPZZJF.js";
11
11
  import "../chunk-JZR32FON.js";
12
12
  export {
13
13
  docToEpub,
@@ -0,0 +1,14 @@
1
+ import {
2
+ collectInlineIconFamilies,
3
+ fontAwesomeFace,
4
+ fontAwesomeFaces,
5
+ fontAwesomeGlyph,
6
+ obfuscateDocxFont
7
+ } from "./chunk-DDMPZZJF.js";
8
+ export {
9
+ collectInlineIconFamilies,
10
+ fontAwesomeFace,
11
+ fontAwesomeFaces,
12
+ fontAwesomeGlyph,
13
+ obfuscateDocxFont
14
+ };
@@ -2,6 +2,9 @@ import { Theme, ThemeRegistry, Doc } from '@bendyline/squisq/schemas';
2
2
  import { H as HtmlExportOptions } from '../import-ipP4Ghp8.js';
3
3
  export { a as HtmlImportOptions, c as collectImagePaths, g as generateExternalHtml, h as htmlToMarkdown, b as htmlToMarkdownDoc, d as htmlToMarkdownDocSync } from '../import-ipP4Ghp8.js';
4
4
  import { HtmlPolicy, MarkdownDocument } from '@bendyline/squisq/markdown';
5
+ import { DataSourceTable } from '@bendyline/squisq/doc';
6
+ import { ContentContainer } from '@bendyline/squisq/storage';
7
+ import { DiagramRasterizer } from '../diagrams/index.js';
5
8
 
6
9
  /**
7
10
  * Image Utilities for HTML Export
@@ -118,7 +121,7 @@ interface PlainHtmlExportOptions {
118
121
  htmlPolicy?: HtmlPolicy;
119
122
  /**
120
123
  * How a hosted video (a paragraph that is only a link to a YouTube, Vimeo,
121
- * Loom, Dailymotion or Wistia page, or that provider's `<iframe>` embed
124
+ * Loom or Wistia page, or that provider's `<iframe>` embed
122
125
  * code) renders:
123
126
  *
124
127
  * - `player` (default) — the provider's player iframe;
@@ -128,6 +131,19 @@ interface PlainHtmlExportOptions {
128
131
  * inherit the sandbox, so the player would load broken), or print.
129
132
  */
130
133
  videoEmbeds?: 'player' | 'poster';
134
+ /**
135
+ * Inline icons as SVG, keyed `family:name` (`solid:star`) — the `icons` that
136
+ * `prepareMarkdownDocForPlainHtml` returns. An icon found here is drawn as
137
+ * an inline `<svg>` in the text color and needs no Font Awesome stylesheet;
138
+ * any other icon keeps its Font Awesome markup (see {@link iconsCss}).
139
+ */
140
+ icons?: ReadonlyMap<string, PlainHtmlIcon>;
141
+ }
142
+ /** One icon's outline: an SVG path in a `0 0 width height` box whose height is 1em. */
143
+ interface PlainHtmlIcon {
144
+ width: number;
145
+ height: number;
146
+ path: string;
131
147
  }
132
148
  /**
133
149
  * Render a parsed markdown document as a complete, semantic HTML page.
@@ -138,6 +154,202 @@ interface PlainHtmlExportOptions {
138
154
  * renders consistently when opened standalone.
139
155
  */
140
156
  declare function markdownDocToPlainHtml(doc: MarkdownDocument, options?: PlainHtmlExportOptions): string;
157
+ /**
158
+ * The pieces of a plain HTML page that belong to the document itself, for a
159
+ * host that places the document inside a page of its own (see
160
+ * `applyHtmlPageTemplate`).
161
+ */
162
+ interface PlainHtmlParts {
163
+ /** The `title` option, unescaped. */
164
+ title: string;
165
+ /** The rendered document body, footnotes included. */
166
+ bodyHtml: string;
167
+ /**
168
+ * `<head>` markup for the CSS the body's own constructs need — feature
169
+ * sections, video embeds, SVG islands, icons — and nothing that styles the
170
+ * page around them: no theme typography, colors, fonts, or `body` rules.
171
+ */
172
+ featureHeadHtml: string;
173
+ }
174
+ /**
175
+ * Render a document's body and the functional CSS it depends on, without the
176
+ * page shell or theme stylesheet `markdownDocToPlainHtml` wraps around them.
177
+ * The theme (when one resolves) still informs body rendering, such as the
178
+ * color an SVG island's `currentColor` follows.
179
+ */
180
+ declare function markdownDocToPlainHtmlParts(doc: MarkdownDocument, options?: PlainHtmlExportOptions): PlainHtmlParts;
181
+
182
+ /**
183
+ * Preparing a document for a static HTML page.
184
+ *
185
+ * A plain HTML page (`markdownDocToPlainHtml`, or a page template filled from
186
+ * `markdownDocToPlainHtmlParts`) runs no script, so what the player draws at
187
+ * runtime has to be settled before the page is written:
188
+ *
189
+ * - `{[dataTable src=…]}` references (and charts fed by one) get the table
190
+ * they point at, bounded to a preview window with a "Showing N of M rows"
191
+ * note — the author's body link to the full file follows it;
192
+ * - Mermaid fences, ASCII diagrams and timelines, drawing / layout / diagram
193
+ * blocks, and charts become pictures, drawn by a host-supplied renderer
194
+ * (drawing needs a browser) and returned as `data:` URLs;
195
+ * - inline icons become inline SVG outlines, so the page needs no Font
196
+ * Awesome stylesheet or font.
197
+ *
198
+ * File trees stay preformatted text, which a page shows as well as a picture
199
+ * would and keeps selectable; SVG islands the renderer already draws.
200
+ */
201
+
202
+ interface PlainHtmlPreparationOptions {
203
+ /**
204
+ * Draws diagrams and charts as pictures. In a browser, pass
205
+ * `createDiagramPictureRenderer()` from
206
+ * `@bendyline/squisq-react/diagram-pictures`. Without one, diagrams stay as
207
+ * their source and charts as their table.
208
+ */
209
+ renderDiagram?: DiagramRasterizer;
210
+ /**
211
+ * The container holding the document's data sidecars. Without one, a data
212
+ * reference keeps only its link.
213
+ */
214
+ container?: ContentContainer | null;
215
+ /** Rows per data table; a block's own `previewRows` wins. Default 100. */
216
+ maxDataRows?: number;
217
+ /**
218
+ * A caller-owned memo of data-file reads, for a host that prepares the
219
+ * same document again and again (a live preview). The caller clears it
220
+ * when the files may have changed.
221
+ */
222
+ dataTableCache?: Map<string, Promise<DataSourceTable>>;
223
+ signal?: AbortSignal;
224
+ /** Receives a note for each table or picture that could not be produced. */
225
+ onWarning?: (message: string) => void;
226
+ }
227
+ interface PreparedPlainHtmlDocument {
228
+ /** The document to render, with data tables filled in and pictures in place. */
229
+ markdownDoc: MarkdownDocument;
230
+ /**
231
+ * The pictures as `data:` URLs, keyed by the image URL written into
232
+ * `markdownDoc`. Merge them into the renderer's `images` option.
233
+ */
234
+ images: Map<string, string>;
235
+ /** Outlines of the document's inline icons: the renderer's `icons` option. */
236
+ icons: Map<string, PlainHtmlIcon>;
237
+ }
238
+ /**
239
+ * Whether {@link prepareMarkdownDocForPlainHtml} would change anything for
240
+ * `doc` with these options — so a live preview renders a document with
241
+ * nothing to prepare at once, without waiting on the asynchronous step.
242
+ */
243
+ declare function needsPlainHtmlPreparation(doc: MarkdownDocument, options?: Pick<PlainHtmlPreparationOptions, 'renderDiagram' | 'container'>): boolean;
244
+ /**
245
+ * Settle everything in `doc` a script-free page cannot draw. Never throws for
246
+ * one table or picture: each degrades to its link or source with a warning.
247
+ */
248
+ declare function prepareMarkdownDocForPlainHtml(doc: MarkdownDocument, options?: PlainHtmlPreparationOptions): Promise<PreparedPlainHtmlDocument>;
249
+
250
+ /**
251
+ * HTML Page Templates
252
+ *
253
+ * Places a rendered document inside a page of the author's own — a site
254
+ * header, navigation, footer, and stylesheet — instead of the fixed shell
255
+ * `markdownDocToPlainHtml` emits. A template is an ordinary HTML file that
256
+ * marks where content goes with the HTML standard's `<slot>` element:
257
+ *
258
+ * - the one unnamed `<slot>` receives the document body;
259
+ * - `<slot name="title">` receives the document title, and
260
+ * `<slot name="KEY">` the caller's value for `KEY` (typically a
261
+ * frontmatter field), inserted as text;
262
+ * - a slot with no value is replaced by its children — the standard fallback
263
+ * content — so a template opened directly in a browser previews with its
264
+ * placeholders.
265
+ *
266
+ * `<slot/>` is accepted as an empty slot (the spelling Astro and JSX authors
267
+ * use), although HTML itself has no self-closing `<slot>`.
268
+ *
269
+ * `<title>` cannot contain elements, so slots written inside it are matched
270
+ * as text; a `<title>` without one is replaced by the document title.
271
+ * Existing description and Open Graph / Twitter title and description
272
+ * `<meta>` tags receive the document's values. Relative URLs in the template
273
+ * are rewritten so they still resolve from the generated page's location.
274
+ *
275
+ * The template is scanned, never re-serialized: everything outside the
276
+ * replaced ranges is emitted byte for byte, so its formatting, comments, and
277
+ * scripts survive unchanged.
278
+ */
279
+ /** Marks the start of the injected document body in a templated page. */
280
+ declare const HTML_PAGE_TEMPLATE_CONTENT_START = "<!-- squisq:content -->";
281
+ /** Marks the end of the injected document body in a templated page. */
282
+ declare const HTML_PAGE_TEMPLATE_CONTENT_END = "<!-- /squisq:content -->";
283
+ interface HtmlPageTemplateContent {
284
+ /** Rendered document body. Inserted as-is; the caller sanitizes it. */
285
+ bodyHtml: string;
286
+ /**
287
+ * Markup the body needs in `<head>`, such as
288
+ * `PlainHtmlParts.featureHeadHtml`. Inserted before the template's own
289
+ * stylesheets so the template's CSS cascades last.
290
+ */
291
+ headHtml?: string;
292
+ /** Document title, as text. */
293
+ title: string;
294
+ /**
295
+ * Text for named slots, keyed by slot name. `description` also fills
296
+ * description `<meta>` tags. `title` comes from {@link title}.
297
+ */
298
+ values?: Readonly<Record<string, string | undefined>>;
299
+ }
300
+ interface HtmlPageTemplateOptions {
301
+ /**
302
+ * Container-relative path of the template file: the location its relative
303
+ * URLs were written against.
304
+ */
305
+ templatePath?: string;
306
+ /**
307
+ * Container-relative path of the page being generated. With
308
+ * {@link templatePath}, relative URLs in the template are rewritten to
309
+ * resolve from here.
310
+ */
311
+ outputPath?: string;
312
+ }
313
+ interface HtmlPageTemplateIssue {
314
+ message: string;
315
+ /** 1-based line in the template. */
316
+ line: number;
317
+ }
318
+ interface HtmlPageTemplateInspection {
319
+ /** True when the HTML has a `<slot>` outside any `<template>`. */
320
+ isTemplate: boolean;
321
+ /** Unnamed slots outside `<template>`; a usable template has exactly one. */
322
+ defaultSlotCount: number;
323
+ /** Distinct named slots, in document order. */
324
+ namedSlots: string[];
325
+ /** Problems that make {@link applyHtmlPageTemplate} refuse the template. */
326
+ errors: HtmlPageTemplateIssue[];
327
+ }
328
+ /** Thrown by {@link applyHtmlPageTemplate} for a template it cannot use. */
329
+ declare class HtmlPageTemplateError extends Error {
330
+ readonly issues: readonly HtmlPageTemplateIssue[];
331
+ constructor(issues: readonly HtmlPageTemplateIssue[]);
332
+ }
333
+ /**
334
+ * True when `html` is a page template: it has a `<slot>` outside any
335
+ * `<template>`. Outside a shadow tree a slot does nothing, so an ordinary
336
+ * page has no reason to carry one.
337
+ */
338
+ declare function isHtmlPageTemplate(html: string): boolean;
339
+ /** Describe a template's slots and any problems that would prevent its use. */
340
+ declare function inspectHtmlPageTemplate(html: string): HtmlPageTemplateInspection;
341
+ /**
342
+ * Generate a page by filling `template`'s slots with `content`.
343
+ *
344
+ * @throws {HtmlPageTemplateError} when the template has no single unnamed
345
+ * slot, or its slots are unbalanced or nested.
346
+ */
347
+ declare function applyHtmlPageTemplate(template: string, content: HtmlPageTemplateContent, options?: HtmlPageTemplateOptions): string;
348
+ /**
349
+ * The document body a templated page carries between its content markers, or
350
+ * null when `html` has none. Lets an importer skip the template's chrome.
351
+ */
352
+ declare function extractHtmlPageTemplateContent(html: string): string | null;
141
353
 
142
354
  /**
143
355
  * Recursive plain-HTML bundle export.
@@ -349,4 +561,4 @@ declare function docToHtml(doc: Doc, options: HtmlExportOptions): string;
349
561
  */
350
562
  declare function docToHtmlZip(doc: Doc, options: HtmlZipExportOptions): Promise<Blob>;
351
563
 
352
- export { type HtmlBundleOptions, HtmlExportOptions, type HtmlZipExportOptions, type PlainHtmlBundleOptions, type PlainHtmlExportOptions, arrayBufferToBase64DataUrl, collectLinkRefs, docToHtml, docToHtmlZip, extractFilename, inferMimeType, markdownDocToPlainHtml, markdownDocsToHtmlBundle, markdownDocsToPlainHtmlBundle };
564
+ export { HTML_PAGE_TEMPLATE_CONTENT_END, HTML_PAGE_TEMPLATE_CONTENT_START, type HtmlBundleOptions, HtmlExportOptions, type HtmlPageTemplateContent, HtmlPageTemplateError, type HtmlPageTemplateInspection, type HtmlPageTemplateIssue, type HtmlPageTemplateOptions, type HtmlZipExportOptions, type PlainHtmlBundleOptions, type PlainHtmlExportOptions, type PlainHtmlIcon, type PlainHtmlParts, type PlainHtmlPreparationOptions, type PreparedPlainHtmlDocument, applyHtmlPageTemplate, arrayBufferToBase64DataUrl, collectLinkRefs, docToHtml, docToHtmlZip, extractFilename, extractHtmlPageTemplateContent, inferMimeType, inspectHtmlPageTemplate, isHtmlPageTemplate, markdownDocToPlainHtml, markdownDocToPlainHtmlParts, markdownDocsToHtmlBundle, markdownDocsToPlainHtmlBundle, needsPlainHtmlPreparation, prepareMarkdownDocForPlainHtml };
@@ -1,37 +1,58 @@
1
1
  import {
2
+ HTML_PAGE_TEMPLATE_CONTENT_END,
3
+ HTML_PAGE_TEMPLATE_CONTENT_START,
4
+ HtmlPageTemplateError,
5
+ applyHtmlPageTemplate,
2
6
  collectImagePaths,
3
7
  collectLinkRefs,
4
8
  docToHtml,
5
9
  docToHtmlZip,
10
+ extractHtmlPageTemplateContent,
6
11
  generateExternalHtml,
7
12
  htmlToMarkdown,
8
13
  htmlToMarkdownDoc,
9
14
  htmlToMarkdownDocSync,
15
+ inspectHtmlPageTemplate,
16
+ isHtmlPageTemplate,
10
17
  markdownDocToPlainHtml,
18
+ markdownDocToPlainHtmlParts,
11
19
  markdownDocsToHtmlBundle,
12
- markdownDocsToPlainHtmlBundle
13
- } from "../chunk-B6UQPW75.js";
20
+ markdownDocsToPlainHtmlBundle,
21
+ needsPlainHtmlPreparation,
22
+ prepareMarkdownDocForPlainHtml
23
+ } from "../chunk-SZ3OIY6G.js";
24
+ import "../chunk-4LIFEQKX.js";
14
25
  import {
15
26
  arrayBufferToBase64DataUrl,
16
27
  extractFilename,
17
28
  inferMimeType
18
29
  } from "../chunk-WMIDXNGR.js";
19
30
  import "../chunk-VCZUXQUL.js";
20
- import "../chunk-BXWNU4T5.js";
31
+ import "../chunk-DTJQK7U7.js";
21
32
  import "../chunk-JZR32FON.js";
22
33
  export {
34
+ HTML_PAGE_TEMPLATE_CONTENT_END,
35
+ HTML_PAGE_TEMPLATE_CONTENT_START,
36
+ HtmlPageTemplateError,
37
+ applyHtmlPageTemplate,
23
38
  arrayBufferToBase64DataUrl,
24
39
  collectImagePaths,
25
40
  collectLinkRefs,
26
41
  docToHtml,
27
42
  docToHtmlZip,
28
43
  extractFilename,
44
+ extractHtmlPageTemplateContent,
29
45
  generateExternalHtml,
30
46
  htmlToMarkdown,
31
47
  htmlToMarkdownDoc,
32
48
  htmlToMarkdownDocSync,
33
49
  inferMimeType,
50
+ inspectHtmlPageTemplate,
51
+ isHtmlPageTemplate,
34
52
  markdownDocToPlainHtml,
53
+ markdownDocToPlainHtmlParts,
35
54
  markdownDocsToHtmlBundle,
36
- markdownDocsToPlainHtmlBundle
55
+ markdownDocsToPlainHtmlBundle,
56
+ needsPlainHtmlPreparation,
57
+ prepareMarkdownDocForPlainHtml
37
58
  };
package/dist/index.d.ts CHANGED
@@ -8,10 +8,10 @@ export { EpubExportOptions, docToEpub, markdownDocToEpub } from './epub/index.js
8
8
  export { ExtractedFileTheme, InferSourceFormat, InferThemeOptions, InferredFileTheme, compileExtractedTheme, inferThemeFromFile } from './infer/index.js';
9
9
  export { B as BUILTIN_FORMAT_IDS, a as BuiltinFormatOptions, C as ConversionLimits, b as ConversionResult, c as ConvertOptions, d as ConvertSource, D as DEFAULT_CONVERSION_LIMITS, e as DbkFormatOptions, F as FormatDefinition, f as FormatId, g as FormatRegistry, M as MarkdownFormatOptions, N as NormalizedInput, P as PreparedConversion, h as PreparedExportOptions, r as resolveConversionLimits } from './types-CVv9eldp.js';
10
10
  export { ConversionError, ConversionErrorCode, ConversionErrorOptions, convert, createRegistry, defaultFormats, defaultRegistry, prepareConversion } from './registry/index.js';
11
- export { ImportedOutsideInDocument, OUTSIDE_IN_UPDATE_FROM_MARKDOWN_KEY, OutsideInMetadata, RenderOutsideInOptions, importOutsideInDocument, isOutsideInMarkdownEditingEnabled, readOutsideInMetadata, renderOutsideInDocument, withOutsideInMarkdownEditing, withOutsideInMetadata } from './outside-in/index.js';
11
+ export { ImportedOutsideInDocument, OUTSIDE_IN_UPDATE_FROM_MARKDOWN_KEY, OutsideInMetadata, RenderOutsideInOptions, importOutsideInDocument, isOutsideInMarkdownEditingEnabled, readOutsideInMetadata, readOutsideInOutputTemplate, renderOutsideInDocument, withOutsideInMarkdownEditing, withOutsideInMetadata } from './outside-in/index.js';
12
12
  export { Z as ZipSafetyError, a as ZipSafetyErrorCode, b as ZipSafetyErrorOptions, c as ZipSafetyLimits } from './zipLimits-BOKCB7qk.js';
13
13
  export { H as HtmlExportOptions, a as HtmlImportOptions, c as collectImagePaths, h as htmlToMarkdown, b as htmlToMarkdownDoc, d as htmlToMarkdownDocSync } from './import-ipP4Ghp8.js';
14
- export { OUTSIDE_IN_FORMAT_IDS, OutsideInFormatId, OutsideInLayout, chooseOutsideInMarkdownPath, isOutsideInTargetPath, resolveOutsideInLayout } from './outside-in/layout.js';
14
+ export { OUTSIDE_IN_FORMAT_IDS, OUTSIDE_IN_OUTPUT_TEMPLATE_KEY, OutsideInFormatId, OutsideInLayout, chooseOutsideInMarkdownPath, isOutsideInTargetPath, resolveOutsideInLayout } from './outside-in/layout.js';
15
15
  export { P as PptxExportOptions, a as PptxImportOptions, d as docToPptx, m as markdownDocToPptx, p as pptxToMarkdownDoc } from './import-Cn_V1_7e.js';
16
16
  export { X as XlsxExportOptions, a as XlsxImportOptions, b as XlsxTable, c as XlsxTableColumn, d as XlsxTablesOptions, e as docToXlsx, g as gridToTables, m as markdownDocToXlsx, x as xlsxToMarkdownDoc, f as xlsxToTables } from './export-C4bBD3Mx.js';
17
17
  import '@bendyline/squisq/schemas';
@@ -19,6 +19,8 @@ import '@bendyline/squisq/markdown';
19
19
  import './reader-B_m1aKZC.js';
20
20
  import '@bendyline/squisq/storage';
21
21
  import './layouts-CTdPlB-u.js';
22
+ import '@bendyline/squisq/doc';
23
+ import './diagrams/index.js';
22
24
  import './themeReader-DCtwC83Q.js';
23
25
  import '@bendyline/squisq/transform';
24
26
  import './container/index.js';