gutterpress 0.11.15 → 0.11.16-alpha.1
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 +6 -0
- package/dist/{README-8b33qbjw.md → README-vsnsc1b3.md} +14 -0
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.js +4 -6
- package/dist/{build-cbvapvgv.js → build-46bb205t.js} +4 -4
- package/dist/{cli-bhs0ssm2.js → cli-6tfc4ed6.js} +1 -1
- package/dist/{cli-mc3waxaw.js → cli-d55z7rtk.js} +3 -3
- package/dist/{cli-ar54jmc5.js → cli-p8xwsknv.js} +1 -1
- package/dist/{cli-s99rpea3.js → cli-sq0awkbf.js} +161 -7
- package/dist/cli.js +12 -12
- package/dist/{doctor-avq8vjva.js → doctor-tjatz81j.js} +2 -2
- package/dist/{engine-h8zdtxhp.js → engine-nv2xddnk.js} +1 -1
- package/dist/{engine-s18wy689.js → engine-szx34415.js} +2 -2
- package/dist/{ext-9tjaavrx.js → ext-ph0770mx.js} +4 -4
- package/dist/{index-ypxhxvwv.js → index-9ydc9q9q.js} +1 -1
- package/dist/{index-wj2dxga6.js → index-azdfgy3t.js} +245 -53
- package/dist/{index-w6tqhafk.js → index-eawjxgkn.js} +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -7
- package/dist/lib/markdown/assemble.d.ts +7 -0
- package/dist/lib/markdown/plugins.d.ts +1 -1
- package/dist/lib/markdown/renderer.d.ts +91 -0
- package/dist/lib/snippets.d.ts +34 -92
- package/dist/{new-cmmshb37.js → new-daeh9p9p.js} +4 -4
- package/dist/{plugin.js-aszz0zgh.tpl → plugin.js-z492w01r.tpl} +44 -0
- package/dist/{plugin.test.js-nw7c84s6.tpl → plugin.test.js-6n8ct5e3.tpl} +35 -1
- package/dist/{preflight-93xdp9jk.js → preflight-bfvw2qe5.js} +4 -4
- package/dist/{preview-dhjma9fn.js → preview-00298rvf.js} +4 -4
- package/dist/{publish-a28ajgqt.js → publish-jn9t18mr.js} +4 -4
- package/dist/render.js +156 -2
- package/dist/{validate-any9f0df.js → validate-cm1m5bbf.js} +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -528,6 +528,12 @@ the process's full filesystem and network privileges.
|
|
|
528
528
|
Use the entry's `export` field, or `ext add --export <name>`, for packages
|
|
529
529
|
that expose a named plugin function instead of a default export.
|
|
530
530
|
|
|
531
|
+
A plugin's declared markers (`export const markers`) are its components. Each
|
|
532
|
+
one's example snippet — `snippets/<marker>.md` by default, or the marker's own
|
|
533
|
+
`snippet:` path — is what the desktop editor inserts for it, and an optional
|
|
534
|
+
`validate(component)` function on the marker checks what authors put inside;
|
|
535
|
+
its problems appear in `gutterpress validate` and the desktop Problems panel.
|
|
536
|
+
|
|
531
537
|
See [User Guide: Chapter 5 — Plugins](https://github.com/dimm-city/gutterpress/blob/main/examples/gutterpress-user-guide/05-plugins.md) for the full list contract and for authoring custom plugins, and [Chapter 4 — Styling & Theming](https://github.com/dimm-city/gutterpress/blob/main/examples/gutterpress-user-guide/04-styling-theming.md) for looks.
|
|
532
538
|
|
|
533
539
|
## CI / scripting
|
|
@@ -110,6 +110,20 @@ Marker names are global across every plugin a book loads. Two plugins
|
|
|
110
110
|
declaring `@callout` is a hard load error naming both — which is a good
|
|
111
111
|
outcome, and another reason to prefix.
|
|
112
112
|
|
|
113
|
+
**Show authors the structure.** A marker's example content lives in
|
|
114
|
+
`snippets/<marker>.md` — `snippets/term-box.md` here. When an author picks
|
|
115
|
+
`@term-box` from the editor's `@` autocomplete or the snippet picker, that
|
|
116
|
+
file is what gets inserted. To keep the example somewhere else, set
|
|
117
|
+
`snippet: "path/inside/this/folder.md"` on the marker.
|
|
118
|
+
|
|
119
|
+
**Check the structure (optional).** Add `validate(component)` to a marker and
|
|
120
|
+
Gutterpress runs it on every use of the component whenever it checks a book
|
|
121
|
+
— the desktop Problems panel, `gutterpress validate`, and builds. It receives
|
|
122
|
+
a plain object (`attrs`, `variant`, `text`, and `blocks` such as
|
|
123
|
+
`{ type: "paragraph", text, line }`) and returns problem messages. No
|
|
124
|
+
markdown-it knowledge needed; `plugin.js` documents every field and
|
|
125
|
+
`test/plugin.test.js` shows how to test one with a hand-written component.
|
|
126
|
+
|
|
113
127
|
### 5. Leave the cascade to Gutterpress
|
|
114
128
|
|
|
115
129
|
Gutterpress wraps every extension's CSS in a cascade layer of its own
|
package/dist/api/index.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export { TARGETS, TARGET_IDS, publishTargetFor } from "../lib/targets.ts";
|
|
|
31
31
|
export type { PublishTarget, TargetOverlay } from "../lib/targets.ts";
|
|
32
32
|
export { listBuiltInTemplates, listCustomTemplates, saveProjectAsTemplate, importTemplateFromFolder, BUILT_IN_TEMPLATE_IDS, } from "../lib/project-templates.ts";
|
|
33
33
|
export type { TemplateInfo, SaveProjectAsTemplateOptions, } from "../lib/project-templates.ts";
|
|
34
|
-
export { extractVariables, substituteVariables, listSnippets,
|
|
35
|
-
export type { SnippetEntry, SnippetSource } from "../lib/snippets.ts";
|
|
34
|
+
export { extractVariables, substituteVariables, listSnippets, saveSnippet, deleteSnippet, listMergedSnippets, listMarkerComponents, SNIPPETS_DIR, } from "../lib/snippets.ts";
|
|
35
|
+
export type { MarkerComponent, SnippetEntry, SnippetSource } from "../lib/snippets.ts";
|
|
36
36
|
export { listProjectExtensions, describeExtension, addExtension, checkExtensionUpdates, updateExtensions, removeExtension, setExtensionEnabled, reorderExtensions, validateProjectExtensions, readExtensionCss, listBuiltInStyleSets, addBuiltInStyleSet, sameExtension, RECOMMENDED_EXTENSIONS, BUILT_IN_STYLE_SET_IDS, EXTENSIONS_DIR, PLUGINS_DIR, } from "../lib/extension-manager.ts";
|
|
37
37
|
export type { ProjectExtensionEntry, ExtensionValidationResult, RecommendedExtension, ExtensionSourceKind, BuiltInStyleSet, BuiltInStyleSetId, AddExtensionOptions, ExtensionUpdateCheck, ExtensionUpdateResult, CheckExtensionUpdatesOptions, UpdateExtensionsOptions, } from "../lib/extension-manager.ts";
|
|
38
38
|
export { BUNDLED_EXTENSIONS, isBundledExtension, isPathSpecifier, parseExtensionSpecifier, } from "../lib/extension-specifier.ts";
|
package/dist/api/index.js
CHANGED
|
@@ -69,6 +69,7 @@ import {
|
|
|
69
69
|
listCustomTemplates,
|
|
70
70
|
listGitHubBranches,
|
|
71
71
|
listGitHubRepositories,
|
|
72
|
+
listMarkerComponents,
|
|
72
73
|
listMergedSnippets,
|
|
73
74
|
listProjectExtensions,
|
|
74
75
|
listProjectStyles,
|
|
@@ -88,10 +89,8 @@ import {
|
|
|
88
89
|
publishTargetFor,
|
|
89
90
|
readExtensionCss,
|
|
90
91
|
readExtensionMeta,
|
|
91
|
-
readExtensionSnippet,
|
|
92
92
|
readManifestFields,
|
|
93
93
|
readPublishSettings,
|
|
94
|
-
readSnippet,
|
|
95
94
|
refreshRemoteCopies,
|
|
96
95
|
removeExtension,
|
|
97
96
|
reorderExtensions,
|
|
@@ -129,10 +128,10 @@ import {
|
|
|
129
128
|
testRemoteAccess,
|
|
130
129
|
updateExtensions,
|
|
131
130
|
validateProjectExtensions
|
|
132
|
-
} from "../index-
|
|
131
|
+
} from "../index-azdfgy3t.js";
|
|
133
132
|
import {
|
|
134
133
|
BuildError
|
|
135
|
-
} from "../index-
|
|
134
|
+
} from "../index-eawjxgkn.js";
|
|
136
135
|
import {
|
|
137
136
|
DEFAULT_PRINT_OPTS,
|
|
138
137
|
assertMilestone,
|
|
@@ -206,10 +205,8 @@ export {
|
|
|
206
205
|
removeExtension,
|
|
207
206
|
refreshRemoteCopies,
|
|
208
207
|
readyProbeExpr,
|
|
209
|
-
readSnippet,
|
|
210
208
|
readPublishSettings,
|
|
211
209
|
readManifestFields,
|
|
212
|
-
readExtensionSnippet,
|
|
213
210
|
readExtensionMeta,
|
|
214
211
|
readExtensionCss,
|
|
215
212
|
publishTargetFor,
|
|
@@ -230,6 +227,7 @@ export {
|
|
|
230
227
|
listProjectStyles,
|
|
231
228
|
listProjectExtensions,
|
|
232
229
|
listMergedSnippets,
|
|
230
|
+
listMarkerComponents,
|
|
233
231
|
listLocalBranches,
|
|
234
232
|
listGitHubRepositories,
|
|
235
233
|
listGitHubBranches,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runBuild,
|
|
3
3
|
splitOutPath
|
|
4
|
-
} from "./cli-
|
|
4
|
+
} from "./cli-sq0awkbf.js";
|
|
5
5
|
import {
|
|
6
6
|
log
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-6tfc4ed6.js";
|
|
8
8
|
import {
|
|
9
9
|
UsageError,
|
|
10
10
|
parseFormat,
|
|
11
11
|
parsePdfxFlavor,
|
|
12
12
|
rejectExtraPositionals,
|
|
13
13
|
rejectUnknownFlags
|
|
14
|
-
} from "./cli-
|
|
15
|
-
import"./cli-
|
|
14
|
+
} from "./cli-p8xwsknv.js";
|
|
15
|
+
import"./cli-d55z7rtk.js";
|
|
16
16
|
import {
|
|
17
17
|
BuildError
|
|
18
18
|
} from "./cli-46ycxe6r.js";
|
|
@@ -1148,10 +1148,10 @@ var chapter_01_default3 = "./chapter-01-6fn9pvd0.md";
|
|
|
1148
1148
|
var package_default = "./package-9rv69pxm.json";
|
|
1149
1149
|
|
|
1150
1150
|
// src/assets/extension-templates/plugin/README.md
|
|
1151
|
-
var README_default = "./README-
|
|
1151
|
+
var README_default = "./README-vsnsc1b3.md";
|
|
1152
1152
|
|
|
1153
1153
|
// src/assets/extension-templates/plugin/plugin.js.tpl
|
|
1154
|
-
var plugin_js_default = "./plugin.js-
|
|
1154
|
+
var plugin_js_default = "./plugin.js-z492w01r.tpl";
|
|
1155
1155
|
|
|
1156
1156
|
// src/assets/extension-templates/plugin/styles/plugin.css
|
|
1157
1157
|
var plugin_default = "./plugin-spbcem4j.css";
|
|
@@ -1166,7 +1166,7 @@ var fixture_default = "./fixture-2qnyqgb5.md";
|
|
|
1166
1166
|
var expected_default = "./expected-ycmacem8.html";
|
|
1167
1167
|
|
|
1168
1168
|
// src/assets/extension-templates/plugin/test/plugin.test.js.tpl
|
|
1169
|
-
var plugin_test_js_default = "./plugin.test.js-
|
|
1169
|
+
var plugin_test_js_default = "./plugin.test.js-6n8ct5e3.tpl";
|
|
1170
1170
|
|
|
1171
1171
|
// src/assets/extension-templates/theme/package.json
|
|
1172
1172
|
var package_default2 = "./package-aenwjew3.json";
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "gutterpress",
|
|
7
|
-
version: "0.11.
|
|
7
|
+
version: "0.11.16-alpha.1",
|
|
8
8
|
description: "Markdown-to-PDF converter for professional print layout using a native Chromium print engine and Ghostscript.",
|
|
9
9
|
author: "itlackey",
|
|
10
10
|
license: "MPL-2.0",
|
|
@@ -13,17 +13,17 @@ import {
|
|
|
13
13
|
stampCreator,
|
|
14
14
|
stripAnnotations,
|
|
15
15
|
warn
|
|
16
|
-
} from "./cli-
|
|
16
|
+
} from "./cli-6tfc4ed6.js";
|
|
17
17
|
import {
|
|
18
18
|
DEBOUNCE,
|
|
19
19
|
UsageError,
|
|
20
20
|
resolvePort
|
|
21
|
-
} from "./cli-
|
|
21
|
+
} from "./cli-p8xwsknv.js";
|
|
22
22
|
import {
|
|
23
23
|
MARGIN_BOX_IGNORED_PROPERTIES,
|
|
24
24
|
getAssetPath,
|
|
25
25
|
getAssetsDir
|
|
26
|
-
} from "./cli-
|
|
26
|
+
} from "./cli-d55z7rtk.js";
|
|
27
27
|
import {
|
|
28
28
|
BuildError
|
|
29
29
|
} from "./cli-46ycxe6r.js";
|
|
@@ -2970,6 +2970,133 @@ function warn2(env, line, type, message, marker) {
|
|
|
2970
2970
|
env.layoutWarnings = [];
|
|
2971
2971
|
env.layoutWarnings.push({ line, type, message, marker });
|
|
2972
2972
|
}
|
|
2973
|
+
var COMPONENT_SEVERITIES = ["error", "warning", "info"];
|
|
2974
|
+
function blockEnd(tokens, i) {
|
|
2975
|
+
if (tokens[i].nesting !== 1)
|
|
2976
|
+
return i;
|
|
2977
|
+
let depth = 0;
|
|
2978
|
+
for (let j = i;j < tokens.length; j++) {
|
|
2979
|
+
depth += tokens[j].nesting;
|
|
2980
|
+
if (depth === 0)
|
|
2981
|
+
return j;
|
|
2982
|
+
}
|
|
2983
|
+
return tokens.length - 1;
|
|
2984
|
+
}
|
|
2985
|
+
function inlineText(tokens, from, to) {
|
|
2986
|
+
const parts = [];
|
|
2987
|
+
for (let k = from;k <= to; k++)
|
|
2988
|
+
if (tokens[k].type === "inline")
|
|
2989
|
+
parts.push(tokens[k].content);
|
|
2990
|
+
return parts.join(`
|
|
2991
|
+
`);
|
|
2992
|
+
}
|
|
2993
|
+
function soleImage(inline) {
|
|
2994
|
+
const parts = (inline && inline.children || []).filter((c) => c.type !== "softbreak" && !(c.type === "text" && !c.content.trim()));
|
|
2995
|
+
return parts.length === 1 && parts[0].type === "image" ? parts[0] : null;
|
|
2996
|
+
}
|
|
2997
|
+
function toComponentBlocks(tokens, fallbackLine) {
|
|
2998
|
+
const blocks = [];
|
|
2999
|
+
for (let i = 0;i < tokens.length; i++) {
|
|
3000
|
+
const tok = tokens[i];
|
|
3001
|
+
const end = blockEnd(tokens, i);
|
|
3002
|
+
const line = tok.map ? tok.map[0] + 1 : tok.meta && tok.meta.line || fallbackLine;
|
|
3003
|
+
switch (tok.type) {
|
|
3004
|
+
case "heading_open":
|
|
3005
|
+
blocks.push({ type: "heading", level: Number(tok.tag.slice(1)), text: inlineText(tokens, i, end), line });
|
|
3006
|
+
break;
|
|
3007
|
+
case "paragraph_open": {
|
|
3008
|
+
const image = soleImage(tokens[i + 1]);
|
|
3009
|
+
blocks.push(image ? { type: "image", alt: image.content, src: image.attrGet("src") || "", line } : { type: "paragraph", text: inlineText(tokens, i, end), line });
|
|
3010
|
+
break;
|
|
3011
|
+
}
|
|
3012
|
+
case "bullet_list_open":
|
|
3013
|
+
case "ordered_list_open": {
|
|
3014
|
+
const items = [];
|
|
3015
|
+
for (let k = i + 1;k < end; k++) {
|
|
3016
|
+
if (tokens[k].type !== "list_item_open" || tokens[k].level !== tok.level + 1)
|
|
3017
|
+
continue;
|
|
3018
|
+
const itemEnd = blockEnd(tokens, k);
|
|
3019
|
+
const first = tokens.slice(k + 1, itemEnd).find((t) => t.type === "inline");
|
|
3020
|
+
items.push(first ? first.content : "");
|
|
3021
|
+
k = itemEnd;
|
|
3022
|
+
}
|
|
3023
|
+
blocks.push({ type: "list", ordered: tok.type === "ordered_list_open", items, line });
|
|
3024
|
+
break;
|
|
3025
|
+
}
|
|
3026
|
+
case "blockquote_open":
|
|
3027
|
+
blocks.push({ type: "quote", text: inlineText(tokens, i, end), line });
|
|
3028
|
+
break;
|
|
3029
|
+
case "fence":
|
|
3030
|
+
case "code_block":
|
|
3031
|
+
blocks.push({ type: "code", lang: (tok.info || "").trim().split(/\s+/)[0] || "", text: tok.content, line });
|
|
3032
|
+
break;
|
|
3033
|
+
case "table_open":
|
|
3034
|
+
blocks.push({ type: "table", line });
|
|
3035
|
+
break;
|
|
3036
|
+
case "hr":
|
|
3037
|
+
blocks.push({ type: "rule", line });
|
|
3038
|
+
break;
|
|
3039
|
+
case "html_block":
|
|
3040
|
+
blocks.push({ type: "html", text: tok.content, line });
|
|
3041
|
+
break;
|
|
3042
|
+
case "layout_component_open":
|
|
3043
|
+
blocks.push({ type: "component", name: tok.meta.component, line });
|
|
3044
|
+
break;
|
|
3045
|
+
default:
|
|
3046
|
+
blocks.push({ type: tok.type.replace(/_open$/, ""), line });
|
|
3047
|
+
}
|
|
3048
|
+
i = end;
|
|
3049
|
+
}
|
|
3050
|
+
return blocks;
|
|
3051
|
+
}
|
|
3052
|
+
function runComponentValidate(env, decl, meta, tokens, lines) {
|
|
3053
|
+
const name = meta.component;
|
|
3054
|
+
const line = meta.line || 0;
|
|
3055
|
+
const report = (at, type, message, severity) => {
|
|
3056
|
+
if (!env.layoutWarnings)
|
|
3057
|
+
env.layoutWarnings = [];
|
|
3058
|
+
env.layoutWarnings.push(severity ? { line: at, type, message, severity } : { line: at, type, message });
|
|
3059
|
+
};
|
|
3060
|
+
const failed = (why) => report(line, "component_validate_failed", `@${name}: plugin "${decl.validateOwner}"'s validate() ${why}`);
|
|
3061
|
+
let lastLine = line;
|
|
3062
|
+
for (const t of tokens)
|
|
3063
|
+
if (t.map && t.map[1] > lastLine)
|
|
3064
|
+
lastLine = t.map[1];
|
|
3065
|
+
const component = {
|
|
3066
|
+
name,
|
|
3067
|
+
variant: meta.variant || null,
|
|
3068
|
+
attrs: { ...meta.attrs },
|
|
3069
|
+
line,
|
|
3070
|
+
text: lines.slice(line, lastLine).join(`
|
|
3071
|
+
`),
|
|
3072
|
+
blocks: toComponentBlocks(tokens, line)
|
|
3073
|
+
};
|
|
3074
|
+
let result;
|
|
3075
|
+
try {
|
|
3076
|
+
result = decl.validate(component);
|
|
3077
|
+
} catch (error2) {
|
|
3078
|
+
failed(`threw: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
3079
|
+
return;
|
|
3080
|
+
}
|
|
3081
|
+
if (result === undefined || result === null)
|
|
3082
|
+
return;
|
|
3083
|
+
if (typeof result === "string")
|
|
3084
|
+
result = [result];
|
|
3085
|
+
if (!Array.isArray(result)) {
|
|
3086
|
+
failed("must return a message, an array of problems, or nothing (and must not be async).");
|
|
3087
|
+
return;
|
|
3088
|
+
}
|
|
3089
|
+
for (const entry of result) {
|
|
3090
|
+
const problem = typeof entry === "string" ? { message: entry } : entry;
|
|
3091
|
+
if (!problem || typeof problem.message !== "string" || !problem.message.trim()) {
|
|
3092
|
+
failed("returned a problem without a message.");
|
|
3093
|
+
continue;
|
|
3094
|
+
}
|
|
3095
|
+
const at = Number.isInteger(problem.line) && problem.line > 0 ? problem.line : line;
|
|
3096
|
+
const severity = COMPONENT_SEVERITIES.includes(problem.severity) ? problem.severity : undefined;
|
|
3097
|
+
report(at, "component_invalid", `@${name}: ${problem.message}`, severity);
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
2973
3100
|
function proseEscapeHint(kind) {
|
|
2974
3101
|
return ` If this line is prose that happens to begin with "@${kind}" — a wrapped sentence, for` + ` instance — escape it as \\@${kind} or write it as \`@${kind}\` in backticks, and it stays text.`;
|
|
2975
3102
|
}
|
|
@@ -3072,13 +3199,20 @@ function resolveContainerShape(name, pluginName, decl) {
|
|
|
3072
3199
|
}
|
|
3073
3200
|
autoCloseAtEof = decl.autoCloseAt.includes("eof");
|
|
3074
3201
|
}
|
|
3075
|
-
|
|
3202
|
+
if (decl.validate !== undefined && typeof decl.validate !== "function") {
|
|
3203
|
+
throw new Error(`Plugin "${pluginName}"'s marker "@${name}" has a \`validate\` that is not a function.`);
|
|
3204
|
+
}
|
|
3205
|
+
const check20 = decl.validate ? { validate: decl.validate, validateOwner: pluginName } : {};
|
|
3206
|
+
return { tag, classBase, variants, label, autoCloseAtEof, ...check20 };
|
|
3076
3207
|
}
|
|
3077
3208
|
function resolveMarkerDeclaration(name, rawDecl, rawRegistry, originOf) {
|
|
3078
3209
|
const pluginName = originOf.get(name);
|
|
3079
3210
|
if (typeof rawDecl !== "object" || rawDecl === null || Array.isArray(rawDecl)) {
|
|
3080
3211
|
throw new Error(`Plugin "${pluginName}"'s marker "@${name}" is not a plain object.`);
|
|
3081
3212
|
}
|
|
3213
|
+
if (rawDecl.snippet !== undefined && (typeof rawDecl.snippet !== "string" || !rawDecl.snippet.trim())) {
|
|
3214
|
+
throw new Error(`Plugin "${pluginName}"'s marker "@${name}" has a \`snippet\` that is not a non-empty path string.`);
|
|
3215
|
+
}
|
|
3082
3216
|
if (rawDecl.deprecated !== undefined) {
|
|
3083
3217
|
if (typeof rawDecl.deprecated !== "string" || !rawDecl.deprecated) {
|
|
3084
3218
|
throw new Error(`Plugin "${pluginName}"'s marker "@${name}" has a \`deprecated\` value that is not a non-empty string.`);
|
|
@@ -3293,8 +3427,8 @@ function plugin(md, pluginOptions = {}) {
|
|
|
3293
3427
|
}
|
|
3294
3428
|
function openDeclaredMarker(meta, decl) {
|
|
3295
3429
|
const t = new state.Token("layout_component_open", decl.tag, 1);
|
|
3296
|
-
t.meta = { line: meta.__line };
|
|
3297
3430
|
const variant = meta.name || decl.presetVariant || null;
|
|
3431
|
+
t.meta = { line: meta.__line, component: meta.kind, variant, attrs: meta.attrs || {}, labelled: false };
|
|
3298
3432
|
const variantClass = variant && decl.variants && decl.variants[variant] || "";
|
|
3299
3433
|
const baseClass = [decl.classBase, variantClass].filter(Boolean).join(" ");
|
|
3300
3434
|
addClasses(t, baseClass, meta.attrs && meta.attrs.class ? meta.attrs.class : "");
|
|
@@ -3308,6 +3442,7 @@ function plugin(md, pluginOptions = {}) {
|
|
|
3308
3442
|
labelToken.content = `<${decl.label.tag} class="${escapeAttr(decl.label.class)}">${escapeHtml(value)}</${decl.label.tag}>
|
|
3309
3443
|
`;
|
|
3310
3444
|
out.push(labelToken);
|
|
3445
|
+
t.meta.labelled = true;
|
|
3311
3446
|
}
|
|
3312
3447
|
}
|
|
3313
3448
|
}
|
|
@@ -3569,6 +3704,25 @@ function plugin(md, pluginOptions = {}) {
|
|
|
3569
3704
|
stack.closeAll();
|
|
3570
3705
|
state.tokens = out;
|
|
3571
3706
|
});
|
|
3707
|
+
if (declaredMarkers && [...declaredMarkers.values()].some((d) => d.validate)) {
|
|
3708
|
+
md.core.ruler.push("gp_component_validate", function(state) {
|
|
3709
|
+
let lines = null;
|
|
3710
|
+
const tokens = state.tokens;
|
|
3711
|
+
for (let i = 0;i < tokens.length; i++) {
|
|
3712
|
+
const tok = tokens[i];
|
|
3713
|
+
if (tok.type !== "layout_component_open")
|
|
3714
|
+
continue;
|
|
3715
|
+
const decl = declaredMarkers.get(tok.meta.component);
|
|
3716
|
+
if (!decl || !decl.validate)
|
|
3717
|
+
continue;
|
|
3718
|
+
if (!lines)
|
|
3719
|
+
lines = state.src.split(`
|
|
3720
|
+
`);
|
|
3721
|
+
const from = i + (tok.meta.labelled ? 2 : 1);
|
|
3722
|
+
runComponentValidate(state.env, decl, tok.meta, tokens.slice(from, blockEnd(tokens, i)), lines);
|
|
3723
|
+
}
|
|
3724
|
+
});
|
|
3725
|
+
}
|
|
3572
3726
|
md.renderer.rules.layout_page_break = (tokens, idx) => {
|
|
3573
3727
|
const cls = tokens[idx].attrGet("class") || "gp-page-break";
|
|
3574
3728
|
const rangeAttr = tokens[idx].attrGet("data-source-range");
|
|
@@ -5653,7 +5807,7 @@ var check24 = {
|
|
|
5653
5807
|
md.render(content, env);
|
|
5654
5808
|
for (const w of env.layoutWarnings ?? []) {
|
|
5655
5809
|
results.push(finding(check24.id, {
|
|
5656
|
-
severity: "warning",
|
|
5810
|
+
severity: w.severity ?? "warning",
|
|
5657
5811
|
message: w.message,
|
|
5658
5812
|
file,
|
|
5659
5813
|
...w.line > 0 ? { line: w.line } : {},
|
|
@@ -7985,7 +8139,7 @@ class PdfOutput {
|
|
|
7985
8139
|
const rawPdf = pdfxMode ? path8.join(stage, "raw.pdf") : path8.resolve(pdfFile);
|
|
7986
8140
|
await fsp2.mkdir(path8.dirname(path8.resolve(pdfFile)), { recursive: true });
|
|
7987
8141
|
log.info("Rendering HTML to PDF via the Gutterpress engine (native Chromium pagination)");
|
|
7988
|
-
const { buildNativePdf } = await import("./engine-
|
|
8142
|
+
const { buildNativePdf } = await import("./engine-nv2xddnk.js");
|
|
7989
8143
|
const engineDiagnostics = await buildNativePdf(htmlFile, rawPdf, {
|
|
7990
8144
|
title: config.title,
|
|
7991
8145
|
author: config.authors.length > 0 ? config.authors.join(", ") : undefined,
|
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
UsageError,
|
|
7
7
|
package_default,
|
|
8
8
|
rejectUnknownFlags
|
|
9
|
-
} from "./cli-
|
|
9
|
+
} from "./cli-p8xwsknv.js";
|
|
10
10
|
import {
|
|
11
11
|
EXIT_CODES
|
|
12
12
|
} from "./cli-46ycxe6r.js";
|
|
@@ -18,14 +18,14 @@ import {
|
|
|
18
18
|
import { defineCommand, parseArgs, runMain } from "citty";
|
|
19
19
|
import { statSync } from "node:fs";
|
|
20
20
|
var SUBCOMMANDS = {
|
|
21
|
-
new: () => import("./new-
|
|
22
|
-
preview: () => import("./preview-
|
|
23
|
-
build: () => import("./build-
|
|
24
|
-
publish: () => import("./publish-
|
|
25
|
-
validate: () => import("./validate-
|
|
26
|
-
preflight: () => import("./preflight-
|
|
27
|
-
doctor: () => import("./doctor-
|
|
28
|
-
ext: () => import("./ext-
|
|
21
|
+
new: () => import("./new-daeh9p9p.js").then((m) => m.default),
|
|
22
|
+
preview: () => import("./preview-00298rvf.js").then((m) => m.default),
|
|
23
|
+
build: () => import("./build-46bb205t.js").then((m) => m.default),
|
|
24
|
+
publish: () => import("./publish-jn9t18mr.js").then((m) => m.default),
|
|
25
|
+
validate: () => import("./validate-cm1m5bbf.js").then((m) => m.default),
|
|
26
|
+
preflight: () => import("./preflight-bfvw2qe5.js").then((m) => m.default),
|
|
27
|
+
doctor: () => import("./doctor-tjatz81j.js").then((m) => m.default),
|
|
28
|
+
ext: () => import("./ext-ph0770mx.js").then((m) => m.default)
|
|
29
29
|
};
|
|
30
30
|
var VERSION = package_default.version;
|
|
31
31
|
var main = defineCommand({
|
|
@@ -50,7 +50,7 @@ async function preflightRequiredInvocations(rawArgs) {
|
|
|
50
50
|
const [command, ...commandArgs] = rawArgs;
|
|
51
51
|
try {
|
|
52
52
|
if (command === "new") {
|
|
53
|
-
const { newArgs } = await import("./new-
|
|
53
|
+
const { newArgs } = await import("./new-daeh9p9p.js");
|
|
54
54
|
rejectUnknownFlags(commandArgs, newArgs, "new");
|
|
55
55
|
const parsed = parseArgs(commandArgs, {
|
|
56
56
|
...newArgs,
|
|
@@ -62,7 +62,7 @@ async function preflightRequiredInvocations(rawArgs) {
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
if (command === "preflight") {
|
|
65
|
-
const { preflightArgs } = await import("./preflight-
|
|
65
|
+
const { preflightArgs } = await import("./preflight-bfvw2qe5.js");
|
|
66
66
|
rejectUnknownFlags(commandArgs, preflightArgs, "preflight");
|
|
67
67
|
const parsed = parseArgs(commandArgs, {
|
|
68
68
|
...preflightArgs,
|
|
@@ -82,7 +82,7 @@ async function preflightRequiredInvocations(rawArgs) {
|
|
|
82
82
|
}
|
|
83
83
|
if (subcommand.startsWith("-"))
|
|
84
84
|
return;
|
|
85
|
-
const { EXT_SUBCOMMANDS, extAddArgs, extRemoveArgs, extEnableArgs, extDisableArgs } = await import("./ext-
|
|
85
|
+
const { EXT_SUBCOMMANDS, extAddArgs, extRemoveArgs, extEnableArgs, extDisableArgs } = await import("./ext-ph0770mx.js");
|
|
86
86
|
if (!EXT_SUBCOMMANDS.includes(subcommand)) {
|
|
87
87
|
throw new UsageError(`gutterpress ext: unknown command "${subcommand}"`);
|
|
88
88
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSystemDiagnostics,
|
|
3
3
|
log
|
|
4
|
-
} from "./cli-
|
|
4
|
+
} from "./cli-6tfc4ed6.js";
|
|
5
5
|
import {
|
|
6
6
|
UsageError,
|
|
7
7
|
rejectExtraPositionals,
|
|
8
8
|
rejectUnknownFlags
|
|
9
|
-
} from "./cli-
|
|
9
|
+
} from "./cli-p8xwsknv.js";
|
|
10
10
|
import"./cli-46ycxe6r.js";
|
|
11
11
|
import"./cli-7fkhgtfn.js";
|
|
12
12
|
import"./cli-37x76zdn.js";
|
|
@@ -12,16 +12,16 @@ import {
|
|
|
12
12
|
searchNpmExtensions,
|
|
13
13
|
setExtensionEnabled,
|
|
14
14
|
updateExtensions
|
|
15
|
-
} from "./cli-
|
|
16
|
-
import"./cli-
|
|
15
|
+
} from "./cli-sq0awkbf.js";
|
|
16
|
+
import"./cli-6tfc4ed6.js";
|
|
17
17
|
import {
|
|
18
18
|
UsageError,
|
|
19
19
|
exitForUsage,
|
|
20
20
|
rejectExtraPositionals,
|
|
21
21
|
rejectUnknownFlags,
|
|
22
22
|
resolveProjectDir
|
|
23
|
-
} from "./cli-
|
|
24
|
-
import"./cli-
|
|
23
|
+
} from "./cli-p8xwsknv.js";
|
|
24
|
+
import"./cli-d55z7rtk.js";
|
|
25
25
|
import {
|
|
26
26
|
EXIT_CODES
|
|
27
27
|
} from "./cli-46ycxe6r.js";
|