@boxpdf/html-writer 0.1.19 → 0.1.21
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.
- package/README.md +45 -8
- package/dist/index.cjs +522 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +521 -86
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { ExtractedPage } from '@boxpdf/reader';
|
|
2
2
|
|
|
3
|
+
interface HtmlImageAsset {
|
|
4
|
+
name: string;
|
|
5
|
+
mimeType: "image/bmp" | "image/jpeg" | "image/svg+xml";
|
|
6
|
+
data: Uint8Array;
|
|
7
|
+
}
|
|
8
|
+
type HtmlImageOptions = "embedded" | "references" | "excluded";
|
|
9
|
+
|
|
3
10
|
interface SemanticDocumentStats {
|
|
4
11
|
pagesProcessed: number;
|
|
5
12
|
peakBufferedPages: number;
|
|
@@ -24,9 +31,22 @@ interface HtmlWriterOptions {
|
|
|
24
31
|
semanticLookaheadPages?: number;
|
|
25
32
|
/** Receives bounded-buffer and document-inference statistics after semantic output completes. */
|
|
26
33
|
onSemanticStats?: (stats: Readonly<SemanticDocumentStats>) => void;
|
|
34
|
+
/** Semantic defaults to excluded; visual defaults to embedded. */
|
|
35
|
+
imageOptions?: HtmlImageOptions;
|
|
36
|
+
/** Receives each named asset when imageOptions is references. */
|
|
37
|
+
onImage?: (image: Readonly<HtmlImageAsset>) => void | Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
interface MarkdownWriterOptions {
|
|
40
|
+
semanticLookaheadPages?: number;
|
|
41
|
+
onSemanticStats?: (stats: Readonly<SemanticDocumentStats>) => void;
|
|
42
|
+
/** Defaults to excluded. */
|
|
43
|
+
imageOptions?: HtmlImageOptions;
|
|
44
|
+
onImage?: (image: Readonly<HtmlImageAsset>) => void | Promise<void>;
|
|
27
45
|
}
|
|
28
46
|
declare function writeHtmlDocument(pages: AsyncIterable<ExtractedPage> | Iterable<ExtractedPage>, write: HtmlWrite, options?: HtmlWriterOptions): Promise<void>;
|
|
47
|
+
/** Streams reflowed Markdown from the same bounded semantic inference used by semantic HTML. */
|
|
48
|
+
declare function writeMarkdownDocument(pages: AsyncIterable<ExtractedPage> | Iterable<ExtractedPage>, write: HtmlWrite, options?: MarkdownWriterOptions): Promise<void>;
|
|
29
49
|
declare function writePage(page: ExtractedPage, write: HtmlWrite, options?: HtmlWriterOptions): Promise<void>;
|
|
30
50
|
declare function pageToHtml(page: ExtractedPage, options?: HtmlWriterOptions): Promise<string>;
|
|
31
51
|
|
|
32
|
-
export { type HtmlLayout, type HtmlProfile, type HtmlWrite, type HtmlWriterOptions, type SemanticDocumentStats, pageToHtml, writeHtmlDocument, writePage };
|
|
52
|
+
export { type HtmlImageAsset, type HtmlImageOptions, type HtmlLayout, type HtmlProfile, type HtmlWrite, type HtmlWriterOptions, type MarkdownWriterOptions, type SemanticDocumentStats, pageToHtml, writeHtmlDocument, writeMarkdownDocument, writePage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { ExtractedPage } from '@boxpdf/reader';
|
|
2
2
|
|
|
3
|
+
interface HtmlImageAsset {
|
|
4
|
+
name: string;
|
|
5
|
+
mimeType: "image/bmp" | "image/jpeg" | "image/svg+xml";
|
|
6
|
+
data: Uint8Array;
|
|
7
|
+
}
|
|
8
|
+
type HtmlImageOptions = "embedded" | "references" | "excluded";
|
|
9
|
+
|
|
3
10
|
interface SemanticDocumentStats {
|
|
4
11
|
pagesProcessed: number;
|
|
5
12
|
peakBufferedPages: number;
|
|
@@ -24,9 +31,22 @@ interface HtmlWriterOptions {
|
|
|
24
31
|
semanticLookaheadPages?: number;
|
|
25
32
|
/** Receives bounded-buffer and document-inference statistics after semantic output completes. */
|
|
26
33
|
onSemanticStats?: (stats: Readonly<SemanticDocumentStats>) => void;
|
|
34
|
+
/** Semantic defaults to excluded; visual defaults to embedded. */
|
|
35
|
+
imageOptions?: HtmlImageOptions;
|
|
36
|
+
/** Receives each named asset when imageOptions is references. */
|
|
37
|
+
onImage?: (image: Readonly<HtmlImageAsset>) => void | Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
interface MarkdownWriterOptions {
|
|
40
|
+
semanticLookaheadPages?: number;
|
|
41
|
+
onSemanticStats?: (stats: Readonly<SemanticDocumentStats>) => void;
|
|
42
|
+
/** Defaults to excluded. */
|
|
43
|
+
imageOptions?: HtmlImageOptions;
|
|
44
|
+
onImage?: (image: Readonly<HtmlImageAsset>) => void | Promise<void>;
|
|
27
45
|
}
|
|
28
46
|
declare function writeHtmlDocument(pages: AsyncIterable<ExtractedPage> | Iterable<ExtractedPage>, write: HtmlWrite, options?: HtmlWriterOptions): Promise<void>;
|
|
47
|
+
/** Streams reflowed Markdown from the same bounded semantic inference used by semantic HTML. */
|
|
48
|
+
declare function writeMarkdownDocument(pages: AsyncIterable<ExtractedPage> | Iterable<ExtractedPage>, write: HtmlWrite, options?: MarkdownWriterOptions): Promise<void>;
|
|
29
49
|
declare function writePage(page: ExtractedPage, write: HtmlWrite, options?: HtmlWriterOptions): Promise<void>;
|
|
30
50
|
declare function pageToHtml(page: ExtractedPage, options?: HtmlWriterOptions): Promise<string>;
|
|
31
51
|
|
|
32
|
-
export { type HtmlLayout, type HtmlProfile, type HtmlWrite, type HtmlWriterOptions, type SemanticDocumentStats, pageToHtml, writeHtmlDocument, writePage };
|
|
52
|
+
export { type HtmlImageAsset, type HtmlImageOptions, type HtmlLayout, type HtmlProfile, type HtmlWrite, type HtmlWriterOptions, type MarkdownWriterOptions, type SemanticDocumentStats, pageToHtml, writeHtmlDocument, writeMarkdownDocument, writePage };
|