@lpdfio/lpdf 0.29.0 → 0.31.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.
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/dist/L.d.ts +7 -2
- package/dist/L.js +6 -0
- package/dist/_shared.d.ts +42 -3
- package/dist/_shared.js +52 -3
- package/dist/attrs.d.ts +733 -65
- package/dist/browser.js +126 -47
- package/dist/canvas.d.ts +13 -12
- package/dist/constants.d.ts +27 -0
- package/dist/constants.js +25 -1
- package/dist/engine.d.ts +19 -28
- package/dist/engine.js +129 -27
- package/dist/index.d.ts +6 -5
- package/dist/index.js +7 -1
- package/dist/kit.d.ts +49 -33
- package/dist/kit.js +7 -1
- package/dist/layout.d.ts +62 -19
- package/dist/layout.js +26 -0
- package/dist/markdown.d.ts +76 -0
- package/dist/markdown.js +63 -0
- package/dist/wasm/lpdf-web.js +191 -36
- package/dist/wasm/lpdf.js +197 -36
- package/dist/wasm/lpdf_bg.wasm +0 -0
- package/package.json +4 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { MarkdownAttr, MarkdownStylesAttr, MarkdownH1Attr, MarkdownH2Attr, MarkdownH3Attr, MarkdownH4Attr, MarkdownH5Attr, MarkdownH6Attr, MarkdownPAttr, MarkdownCodeAttr, MarkdownQuoteAttr, MarkdownLiAttr, MarkdownAAttr, MarkdownStrongAttr, MarkdownEmAttr, MarkdownDelAttr, MarkdownTableAttr, MarkdownThAttr, MarkdownTdAttr } from './attrs';
|
|
2
|
+
import { type AttrValue } from './_shared';
|
|
3
|
+
/** A rule of a markdown's styles: the element it is named after, with the attributes it sets. */
|
|
4
|
+
export interface LpdfMarkdownRuleNode {
|
|
5
|
+
type: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'code' | 'quote' | 'li' | 'a' | 'strong' | 'em' | 'del' | 'table' | 'th' | 'td';
|
|
6
|
+
attrs: Record<string, AttrValue>;
|
|
7
|
+
}
|
|
8
|
+
/** The rules that say how the parts of a markdown look, with a file of them in `src` when it has one. */
|
|
9
|
+
export interface LpdfMarkdownStylesNode {
|
|
10
|
+
type: 'markdown-styles';
|
|
11
|
+
attrs: Record<string, AttrValue>;
|
|
12
|
+
nodes: LpdfMarkdownRuleNode[];
|
|
13
|
+
}
|
|
14
|
+
/** The Markdown itself, as strings. */
|
|
15
|
+
export interface LpdfMarkdownContentNode {
|
|
16
|
+
type: 'markdown-content';
|
|
17
|
+
attrs: Record<string, AttrValue>;
|
|
18
|
+
nodes: string[];
|
|
19
|
+
}
|
|
20
|
+
/** A markdown, which takes the place of a layout in a section and holds only Markdown. */
|
|
21
|
+
export interface LpdfMarkdownNode {
|
|
22
|
+
type: 'markdown';
|
|
23
|
+
attrs: Record<string, AttrValue>;
|
|
24
|
+
nodes: (LpdfMarkdownStylesNode | LpdfMarkdownContentNode)[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Markdown as the content of a section, where a layout would go. It holds only Markdown: the `LMarkdown.styles`
|
|
28
|
+
* that say how each part looks, which are optional, and one `LMarkdown.content` with the text. What Markdown
|
|
29
|
+
* can't say, such as the page, a header, a footer or a cover, stays in the section around it: layers paint a
|
|
30
|
+
* header and a footer in the margin it leaves.
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* L.markdown({ margin: '54pt', gap: 'm' }, [
|
|
34
|
+
* LMarkdown.styles(NoAttr, [LMarkdown.h1({ color: 'muted' })]),
|
|
35
|
+
* LMarkdown.content(NoAttr, [body]),
|
|
36
|
+
* ])
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare function markdown(attrs: MarkdownAttr | null, nodes?: (LpdfMarkdownStylesNode | LpdfMarkdownContentNode)[]): LpdfMarkdownNode;
|
|
40
|
+
/**
|
|
41
|
+
* The rules that say how the parts of a markdown look. A rule is named after the Markdown it styles and takes the
|
|
42
|
+
* attributes of the element it becomes. A rule here overrides the same rule of the file `src` names, which
|
|
43
|
+
* overrides the defaults.
|
|
44
|
+
*/
|
|
45
|
+
declare function styles(attrs: MarkdownStylesAttr | null, nodes?: LpdfMarkdownRuleNode[]): LpdfMarkdownStylesNode;
|
|
46
|
+
/**
|
|
47
|
+
* The Markdown, as strings that make one text. The common indent of its lines is removed, so that indenting the
|
|
48
|
+
* code does not make a code block of it. It has no attributes: pass `NoAttr`.
|
|
49
|
+
*/
|
|
50
|
+
declare function content(attrs: null, nodes?: string[]): LpdfMarkdownContentNode;
|
|
51
|
+
/** The parts of a markdown: its styles, its content and the rules of its styles. */
|
|
52
|
+
export declare const LMarkdown: Readonly<{
|
|
53
|
+
styles: typeof styles;
|
|
54
|
+
content: typeof content;
|
|
55
|
+
h1: (attrs?: MarkdownH1Attr | null) => LpdfMarkdownRuleNode;
|
|
56
|
+
h2: (attrs?: MarkdownH2Attr | null) => LpdfMarkdownRuleNode;
|
|
57
|
+
h3: (attrs?: MarkdownH3Attr | null) => LpdfMarkdownRuleNode;
|
|
58
|
+
h4: (attrs?: MarkdownH4Attr | null) => LpdfMarkdownRuleNode;
|
|
59
|
+
h5: (attrs?: MarkdownH5Attr | null) => LpdfMarkdownRuleNode;
|
|
60
|
+
h6: (attrs?: MarkdownH6Attr | null) => LpdfMarkdownRuleNode;
|
|
61
|
+
p: (attrs?: MarkdownPAttr | null) => LpdfMarkdownRuleNode;
|
|
62
|
+
code: (attrs?: MarkdownCodeAttr | null) => LpdfMarkdownRuleNode;
|
|
63
|
+
quote: (attrs?: MarkdownQuoteAttr | null) => LpdfMarkdownRuleNode;
|
|
64
|
+
li: (attrs?: MarkdownLiAttr | null) => LpdfMarkdownRuleNode;
|
|
65
|
+
a: (attrs?: MarkdownAAttr | null) => LpdfMarkdownRuleNode;
|
|
66
|
+
strong: (attrs?: MarkdownStrongAttr | null) => LpdfMarkdownRuleNode;
|
|
67
|
+
em: (attrs?: MarkdownEmAttr | null) => LpdfMarkdownRuleNode;
|
|
68
|
+
del: (attrs?: MarkdownDelAttr | null) => LpdfMarkdownRuleNode;
|
|
69
|
+
table: (attrs?: MarkdownTableAttr | null) => LpdfMarkdownRuleNode;
|
|
70
|
+
th: (attrs?: MarkdownThAttr | null) => LpdfMarkdownRuleNode;
|
|
71
|
+
td: (attrs?: MarkdownTdAttr | null) => LpdfMarkdownRuleNode;
|
|
72
|
+
}>;
|
|
73
|
+
export declare const LpdfMarkdown: Readonly<{
|
|
74
|
+
markdown: typeof markdown;
|
|
75
|
+
}>;
|
|
76
|
+
export {};
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LpdfMarkdown = exports.LMarkdown = void 0;
|
|
4
|
+
const _shared_1 = require("./_shared");
|
|
5
|
+
// ── The markdown of a section ─────────────────────────────────────────────────
|
|
6
|
+
/**
|
|
7
|
+
* Markdown as the content of a section, where a layout would go. It holds only Markdown: the `LMarkdown.styles`
|
|
8
|
+
* that say how each part looks, which are optional, and one `LMarkdown.content` with the text. What Markdown
|
|
9
|
+
* can't say, such as the page, a header, a footer or a cover, stays in the section around it: layers paint a
|
|
10
|
+
* header and a footer in the margin it leaves.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* L.markdown({ margin: '54pt', gap: 'm' }, [
|
|
14
|
+
* LMarkdown.styles(NoAttr, [LMarkdown.h1({ color: 'muted' })]),
|
|
15
|
+
* LMarkdown.content(NoAttr, [body]),
|
|
16
|
+
* ])
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
function markdown(attrs, nodes = []) {
|
|
20
|
+
return { type: 'markdown', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
|
|
21
|
+
}
|
|
22
|
+
// ── LMarkdown: the parts of a markdown ────────────────────────────────────────
|
|
23
|
+
/**
|
|
24
|
+
* The rules that say how the parts of a markdown look. A rule is named after the Markdown it styles and takes the
|
|
25
|
+
* attributes of the element it becomes. A rule here overrides the same rule of the file `src` names, which
|
|
26
|
+
* overrides the defaults.
|
|
27
|
+
*/
|
|
28
|
+
function styles(attrs, nodes = []) {
|
|
29
|
+
return { type: 'markdown-styles', attrs: (0, _shared_1.buildAttrs)(attrs), nodes };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The Markdown, as strings that make one text. The common indent of its lines is removed, so that indenting the
|
|
33
|
+
* code does not make a code block of it. It has no attributes: pass `NoAttr`.
|
|
34
|
+
*/
|
|
35
|
+
function content(attrs, nodes = []) {
|
|
36
|
+
return { type: 'markdown-content', attrs: {}, nodes };
|
|
37
|
+
}
|
|
38
|
+
function rule(type) {
|
|
39
|
+
return (attrs = null) => ({ type, attrs: (0, _shared_1.buildAttrs)(attrs) });
|
|
40
|
+
}
|
|
41
|
+
/** The parts of a markdown: its styles, its content and the rules of its styles. */
|
|
42
|
+
exports.LMarkdown = Object.freeze({
|
|
43
|
+
styles,
|
|
44
|
+
content,
|
|
45
|
+
h1: rule('h1'),
|
|
46
|
+
h2: rule('h2'),
|
|
47
|
+
h3: rule('h3'),
|
|
48
|
+
h4: rule('h4'),
|
|
49
|
+
h5: rule('h5'),
|
|
50
|
+
h6: rule('h6'),
|
|
51
|
+
p: rule('p'),
|
|
52
|
+
code: rule('code'),
|
|
53
|
+
quote: rule('quote'),
|
|
54
|
+
li: rule('li'),
|
|
55
|
+
a: rule('a'),
|
|
56
|
+
strong: rule('strong'),
|
|
57
|
+
em: rule('em'),
|
|
58
|
+
del: rule('del'),
|
|
59
|
+
table: rule('table'),
|
|
60
|
+
th: rule('th'),
|
|
61
|
+
td: rule('td'),
|
|
62
|
+
});
|
|
63
|
+
exports.LpdfMarkdown = Object.freeze({ markdown });
|
package/dist/wasm/lpdf-web.js
CHANGED
|
@@ -12,10 +12,17 @@ export class LpdfEngine {
|
|
|
12
12
|
wasm.__wbg_lpdfengine_free(ptr, 0);
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Register the bytes of a file a document carries, for the `<file>` of its `<attachments>` whose `ref`, or with
|
|
16
|
+
* no ref whose name, is `name`. The PDF carries them as they are.
|
|
17
|
+
* @param {string} name
|
|
18
|
+
* @param {Uint8Array} bytes
|
|
16
19
|
*/
|
|
17
|
-
|
|
18
|
-
wasm.
|
|
20
|
+
load_file(name, bytes) {
|
|
21
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
22
|
+
const len0 = WASM_VECTOR_LEN;
|
|
23
|
+
const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
24
|
+
const len1 = WASM_VECTOR_LEN;
|
|
25
|
+
wasm.lpdfengine_load_file(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
19
26
|
}
|
|
20
27
|
/**
|
|
21
28
|
* Register raw font bytes (TTF/OTF) for a custom font name.
|
|
@@ -46,6 +53,20 @@ export class LpdfEngine {
|
|
|
46
53
|
const len1 = WASM_VECTOR_LEN;
|
|
47
54
|
wasm.lpdfengine_load_image(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
48
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Register the text of a file of Markdown rules, the root of which is a `<markdown-styles>`, for the
|
|
58
|
+
* `src` that names it. The engine reads no files: call this once for every `<markdown-styles src="…">`
|
|
59
|
+
* of the document before `render_pdf`, as `load_font` is called for a font.
|
|
60
|
+
* @param {string} src
|
|
61
|
+
* @param {string} xml
|
|
62
|
+
*/
|
|
63
|
+
load_markdown_styles(src, xml) {
|
|
64
|
+
const ptr0 = passStringToWasm0(src, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
65
|
+
const len0 = WASM_VECTOR_LEN;
|
|
66
|
+
const ptr1 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
67
|
+
const len1 = WASM_VECTOR_LEN;
|
|
68
|
+
wasm.lpdfengine_load_markdown_styles(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
69
|
+
}
|
|
49
70
|
/**
|
|
50
71
|
* @param {string} license_key
|
|
51
72
|
*/
|
|
@@ -84,22 +105,38 @@ export class LpdfEngine {
|
|
|
84
105
|
* `json_data` is an optional JSON string used to resolve `data-*`
|
|
85
106
|
* attributes in the template. Pass `None` (or `null` / `undefined` from
|
|
86
107
|
* JavaScript) to render the template with its inline fallback content.
|
|
108
|
+
*
|
|
109
|
+
* The rest is for a document that asks for encryption in its `<output>`, which sets the cipher and
|
|
110
|
+
* the permissions: the passwords, which the template never holds, and `entropy`, at least 32 random
|
|
111
|
+
* bytes from the host's secure generator for AES-256. A document that asks for encryption needs an
|
|
112
|
+
* owner password, or `skip_encryption` to render it unencrypted, as a preview does; passwords for a
|
|
113
|
+
* document that doesn't ask for it are an error, and so are passwords with `skip_encryption`.
|
|
87
114
|
* @param {string} xml
|
|
88
|
-
* @param {string | null}
|
|
115
|
+
* @param {string | null | undefined} json_data
|
|
116
|
+
* @param {string | null | undefined} user_password
|
|
117
|
+
* @param {string | null | undefined} owner_password
|
|
118
|
+
* @param {boolean} skip_encryption
|
|
119
|
+
* @param {Uint8Array} entropy
|
|
89
120
|
* @returns {Uint8Array}
|
|
90
121
|
*/
|
|
91
|
-
render_pdf(xml, json_data) {
|
|
122
|
+
render_pdf(xml, json_data, user_password, owner_password, skip_encryption, entropy) {
|
|
92
123
|
const ptr0 = passStringToWasm0(xml, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
93
124
|
const len0 = WASM_VECTOR_LEN;
|
|
94
125
|
var ptr1 = isLikeNone(json_data) ? 0 : passStringToWasm0(json_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
95
126
|
var len1 = WASM_VECTOR_LEN;
|
|
96
|
-
|
|
127
|
+
var ptr2 = isLikeNone(user_password) ? 0 : passStringToWasm0(user_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
128
|
+
var len2 = WASM_VECTOR_LEN;
|
|
129
|
+
var ptr3 = isLikeNone(owner_password) ? 0 : passStringToWasm0(owner_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
130
|
+
var len3 = WASM_VECTOR_LEN;
|
|
131
|
+
const ptr4 = passArray8ToWasm0(entropy, wasm.__wbindgen_malloc);
|
|
132
|
+
const len4 = WASM_VECTOR_LEN;
|
|
133
|
+
const ret = wasm.lpdfengine_render_pdf(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, skip_encryption, ptr4, len4);
|
|
97
134
|
if (ret[3]) {
|
|
98
135
|
throw takeFromExternrefTable0(ret[2]);
|
|
99
136
|
}
|
|
100
|
-
var
|
|
137
|
+
var v6 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
101
138
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
102
|
-
return
|
|
139
|
+
return v6;
|
|
103
140
|
}
|
|
104
141
|
/**
|
|
105
142
|
* @param {string} json
|
|
@@ -126,23 +163,37 @@ export class LpdfEngine {
|
|
|
126
163
|
* when an `LpdfDocument` Kit tree is passed to `renderPdf()`, avoiding an
|
|
127
164
|
* intermediate XML serialisation step. PHP, Python, and .NET adapters also
|
|
128
165
|
* use this entry point.
|
|
166
|
+
*
|
|
167
|
+
* The passwords, `skip_encryption` and `entropy` are those of `render_pdf`, for a document whose
|
|
168
|
+
* `output` asks for encryption.
|
|
129
169
|
* @param {string} json
|
|
170
|
+
* @param {string | null | undefined} user_password
|
|
171
|
+
* @param {string | null | undefined} owner_password
|
|
172
|
+
* @param {boolean} skip_encryption
|
|
173
|
+
* @param {Uint8Array} entropy
|
|
130
174
|
* @returns {Uint8Array}
|
|
131
175
|
*/
|
|
132
|
-
render_tree_pdf(json) {
|
|
176
|
+
render_tree_pdf(json, user_password, owner_password, skip_encryption, entropy) {
|
|
133
177
|
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
134
178
|
const len0 = WASM_VECTOR_LEN;
|
|
135
|
-
|
|
179
|
+
var ptr1 = isLikeNone(user_password) ? 0 : passStringToWasm0(user_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
180
|
+
var len1 = WASM_VECTOR_LEN;
|
|
181
|
+
var ptr2 = isLikeNone(owner_password) ? 0 : passStringToWasm0(owner_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
182
|
+
var len2 = WASM_VECTOR_LEN;
|
|
183
|
+
const ptr3 = passArray8ToWasm0(entropy, wasm.__wbindgen_malloc);
|
|
184
|
+
const len3 = WASM_VECTOR_LEN;
|
|
185
|
+
const ret = wasm.lpdfengine_render_tree_pdf(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, skip_encryption, ptr3, len3);
|
|
136
186
|
if (ret[3]) {
|
|
137
187
|
throw takeFromExternrefTable0(ret[2]);
|
|
138
188
|
}
|
|
139
|
-
var
|
|
189
|
+
var v5 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
140
190
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
141
|
-
return
|
|
191
|
+
return v5;
|
|
142
192
|
}
|
|
143
193
|
/**
|
|
144
|
-
* Set an optional ISO 8601 creation timestamp (e.g. `"2024-06-01T12:00:00"`
|
|
145
|
-
* When provided, written as `/CreationDate` in the PDF info dictionary
|
|
194
|
+
* Set an optional ISO 8601 creation timestamp (e.g. `"2024-06-01T12:00:00"`, `"2024-06-01T12:00:00.000Z"` or
|
|
195
|
+
* `"2024-06-01T12:00:00+01:00"`). When provided, written as `/CreationDate` in the PDF info dictionary, with
|
|
196
|
+
* the precision and the time zone it was given in; a value that is not a date makes the render an error.
|
|
146
197
|
* Omitting this keeps builds reproducible (no embedded timestamp).
|
|
147
198
|
* @param {string} iso
|
|
148
199
|
*/
|
|
@@ -151,28 +202,6 @@ export class LpdfEngine {
|
|
|
151
202
|
const len0 = WASM_VECTOR_LEN;
|
|
152
203
|
wasm.lpdfengine_set_created_on(this.__wbg_ptr, ptr0, len0);
|
|
153
204
|
}
|
|
154
|
-
/**
|
|
155
|
-
* Configure RC4-128 encryption applied to every subsequent `render_pdf` call.
|
|
156
|
-
*
|
|
157
|
-
* `permissions_json` is a JSON object with boolean fields matching the
|
|
158
|
-
* `Permissions` struct (`print`, `modify`, `copy`, `annotate`, `fill_forms`,
|
|
159
|
-
* `accessibility`, `assemble`, `print_hq`). Omitted fields default to `true`.
|
|
160
|
-
*
|
|
161
|
-
* To apply permissions without an open password, pass an empty `user_password`
|
|
162
|
-
* and a non-empty `owner_password`.
|
|
163
|
-
* @param {string} user_password
|
|
164
|
-
* @param {string} owner_password
|
|
165
|
-
* @param {string} permissions_json
|
|
166
|
-
*/
|
|
167
|
-
set_encryption(user_password, owner_password, permissions_json) {
|
|
168
|
-
const ptr0 = passStringToWasm0(user_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
169
|
-
const len0 = WASM_VECTOR_LEN;
|
|
170
|
-
const ptr1 = passStringToWasm0(owner_password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
171
|
-
const len1 = WASM_VECTOR_LEN;
|
|
172
|
-
const ptr2 = passStringToWasm0(permissions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
173
|
-
const len2 = WASM_VECTOR_LEN;
|
|
174
|
-
wasm.lpdfengine_set_encryption(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
175
|
-
}
|
|
176
205
|
/**
|
|
177
206
|
* Inject glyph advance-width tables for custom fonts.
|
|
178
207
|
*
|
|
@@ -344,6 +373,132 @@ export function kit_to_xml(json) {
|
|
|
344
373
|
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
345
374
|
}
|
|
346
375
|
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* The template `template` with an `<image>` declared for each path of the JSON array `srcs`, named as
|
|
379
|
+
* `markdown_file_images` says.
|
|
380
|
+
* @param {string} template
|
|
381
|
+
* @param {string} srcs
|
|
382
|
+
* @returns {string}
|
|
383
|
+
*/
|
|
384
|
+
export function markdown_declare_images(template, srcs) {
|
|
385
|
+
let deferred4_0;
|
|
386
|
+
let deferred4_1;
|
|
387
|
+
try {
|
|
388
|
+
const ptr0 = passStringToWasm0(template, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
389
|
+
const len0 = WASM_VECTOR_LEN;
|
|
390
|
+
const ptr1 = passStringToWasm0(srcs, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
391
|
+
const len1 = WASM_VECTOR_LEN;
|
|
392
|
+
const ret = wasm.markdown_declare_images(ptr0, len0, ptr1, len1);
|
|
393
|
+
var ptr3 = ret[0];
|
|
394
|
+
var len3 = ret[1];
|
|
395
|
+
if (ret[3]) {
|
|
396
|
+
ptr3 = 0; len3 = 0;
|
|
397
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
398
|
+
}
|
|
399
|
+
deferred4_0 = ptr3;
|
|
400
|
+
deferred4_1 = len3;
|
|
401
|
+
return getStringFromWasm0(ptr3, len3);
|
|
402
|
+
} finally {
|
|
403
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* The rules a `<markdown>` with no styles uses, as the file to start a style of one's own from.
|
|
409
|
+
* @returns {string}
|
|
410
|
+
*/
|
|
411
|
+
export function markdown_default_styles() {
|
|
412
|
+
let deferred1_0;
|
|
413
|
+
let deferred1_1;
|
|
414
|
+
try {
|
|
415
|
+
const ret = wasm.markdown_default_styles();
|
|
416
|
+
deferred1_0 = ret[0];
|
|
417
|
+
deferred1_1 = ret[1];
|
|
418
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
419
|
+
} finally {
|
|
420
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* The data a template gets for the `.md` file `markdown`, as JSON: the text as `markdown`, and the fields of its
|
|
426
|
+
* front matter, each a string.
|
|
427
|
+
* @param {string} markdown
|
|
428
|
+
* @returns {string}
|
|
429
|
+
*/
|
|
430
|
+
export function markdown_file_data(markdown) {
|
|
431
|
+
let deferred2_0;
|
|
432
|
+
let deferred2_1;
|
|
433
|
+
try {
|
|
434
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
435
|
+
const len0 = WASM_VECTOR_LEN;
|
|
436
|
+
const ret = wasm.markdown_file_data(ptr0, len0);
|
|
437
|
+
deferred2_0 = ret[0];
|
|
438
|
+
deferred2_1 = ret[1];
|
|
439
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
440
|
+
} finally {
|
|
441
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* The relative paths of the images of the `.md` file `markdown`, as a JSON array. The caller declares them with
|
|
447
|
+
* `markdown_declare_images` and loads each file, relative to the `.md`, under the name `markdown-image-N` where N
|
|
448
|
+
* counts from 1 in the order of the array.
|
|
449
|
+
* @param {string} markdown
|
|
450
|
+
* @returns {string}
|
|
451
|
+
*/
|
|
452
|
+
export function markdown_file_images(markdown) {
|
|
453
|
+
let deferred2_0;
|
|
454
|
+
let deferred2_1;
|
|
455
|
+
try {
|
|
456
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
457
|
+
const len0 = WASM_VECTOR_LEN;
|
|
458
|
+
const ret = wasm.markdown_file_images(ptr0, len0);
|
|
459
|
+
deferred2_0 = ret[0];
|
|
460
|
+
deferred2_1 = ret[1];
|
|
461
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
462
|
+
} finally {
|
|
463
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* The looks a `.md` file can start from besides the default one, as a JSON array of `name`, `label`, `description`
|
|
469
|
+
* and `styles`: the file of styles, to write beside the `.md` file and edit.
|
|
470
|
+
* @returns {string}
|
|
471
|
+
*/
|
|
472
|
+
export function markdown_style_presets() {
|
|
473
|
+
let deferred1_0;
|
|
474
|
+
let deferred1_1;
|
|
475
|
+
try {
|
|
476
|
+
const ret = wasm.markdown_style_presets();
|
|
477
|
+
deferred1_0 = ret[0];
|
|
478
|
+
deferred1_1 = ret[1];
|
|
479
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
480
|
+
} finally {
|
|
481
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* The template that wraps a `.md` file when it is rendered with no template of its own: A4, a margin and the
|
|
487
|
+
* page number. It reads the Markdown from the data `markdown`, the rest of which is the file's front matter.
|
|
488
|
+
* @returns {string}
|
|
489
|
+
*/
|
|
490
|
+
export function markdown_template() {
|
|
491
|
+
let deferred1_0;
|
|
492
|
+
let deferred1_1;
|
|
493
|
+
try {
|
|
494
|
+
const ret = wasm.markdown_template();
|
|
495
|
+
deferred1_0 = ret[0];
|
|
496
|
+
deferred1_1 = ret[1];
|
|
497
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
498
|
+
} finally {
|
|
499
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
347
502
|
function __wbg_get_imports() {
|
|
348
503
|
const import0 = {
|
|
349
504
|
__proto__: null,
|