markdown-pdf-export 2.0.3 → 2.1.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/cli.mjs +126 -18
- package/export.mjs +11 -1
- package/lib/doctor-report.mjs +56 -9
- package/lib/editor-setup.mjs +134 -8
- package/lib/looks.mjs +24 -1
- package/lib/studio-server.mjs +27 -7
- package/lib/term-style.mjs +27 -0
- package/looks/report.css +4 -3
- package/looks/technical.css +7 -6
- package/package.json +8 -3
- package/schema/settings.schema.json +7 -0
- package/studio/app.mjs +142 -12
- package/studio/index.html +9 -0
- package/studio/model.mjs +27 -1
- package/studio/sample.md +12 -0
- package/studio/style.css +76 -1
- package/tool-schemas.mjs +6 -0
package/cli.mjs
CHANGED
|
@@ -40,8 +40,17 @@ import {
|
|
|
40
40
|
userSettingsPath,
|
|
41
41
|
} from "./lib/settings-loader.mjs";
|
|
42
42
|
import { formatDoctor } from "./lib/doctor-report.mjs";
|
|
43
|
+
import { makeStyle } from "./lib/term-style.mjs";
|
|
43
44
|
import { LOOKS, FONTS, applyPresets } from "./lib/looks.mjs";
|
|
44
|
-
import {
|
|
45
|
+
import {
|
|
46
|
+
EDITOR_IDS,
|
|
47
|
+
ITEM_LABELS,
|
|
48
|
+
applySetupItem,
|
|
49
|
+
buildEditorSetup,
|
|
50
|
+
editorStatus,
|
|
51
|
+
launchSpec,
|
|
52
|
+
pendingItems,
|
|
53
|
+
} from "./lib/editor-setup.mjs";
|
|
45
54
|
|
|
46
55
|
const BIN = "markdown-pdf-export";
|
|
47
56
|
const CLI_PATH = fileURLToPath(import.meta.url);
|
|
@@ -275,12 +284,15 @@ async function main(argv) {
|
|
|
275
284
|
if (fromArg) setSettings(fromArg.data, fromArg.file);
|
|
276
285
|
|
|
277
286
|
if (isDoctor) {
|
|
278
|
-
const report =
|
|
287
|
+
const report = {
|
|
288
|
+
...(await doctorMarkdownPdf({ input_path: positional[0] })),
|
|
289
|
+
editors: editorStatus(),
|
|
290
|
+
};
|
|
279
291
|
if (asJson) {
|
|
280
292
|
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
281
293
|
return report.browser.available ? 0 : 1;
|
|
282
294
|
}
|
|
283
|
-
const { text, ok } = formatDoctor(report, { bin: BIN });
|
|
295
|
+
const { text, ok } = formatDoctor(report, { bin: BIN, style: makeStyle() });
|
|
284
296
|
process.stdout.write(text);
|
|
285
297
|
return ok ? 0 : 1;
|
|
286
298
|
}
|
|
@@ -322,7 +334,8 @@ async function runMenu() {
|
|
|
322
334
|
if (pick === "1") return runSetup([]);
|
|
323
335
|
if (pick === "2") return runStudio([]);
|
|
324
336
|
if (pick === "3") {
|
|
325
|
-
const
|
|
337
|
+
const report = { ...(await doctorMarkdownPdf({})), editors: editorStatus() };
|
|
338
|
+
const { text, ok } = formatDoctor(report, { bin: BIN, style: makeStyle() });
|
|
326
339
|
process.stdout.write(text);
|
|
327
340
|
return ok ? 0 : 1;
|
|
328
341
|
}
|
|
@@ -661,14 +674,90 @@ async function runInit(argv) {
|
|
|
661
674
|
|
|
662
675
|
// ── setup ────────────────────────────────────────────────────────────────────
|
|
663
676
|
|
|
677
|
+
/**
|
|
678
|
+
* Ask editor by editor; skip what is already set up. Returns an exit code
|
|
679
|
+
* (130 when the person aborts with Ctrl+C / Ctrl+D).
|
|
680
|
+
*/
|
|
681
|
+
async function setupInteractive(setups, c) {
|
|
682
|
+
const out = process.stdout;
|
|
683
|
+
const status = Object.fromEntries(editorStatus().map((e) => [e.id, e]));
|
|
684
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
685
|
+
let aborted = false;
|
|
686
|
+
rl.on("SIGINT", () => {
|
|
687
|
+
aborted = true;
|
|
688
|
+
rl.close();
|
|
689
|
+
});
|
|
690
|
+
const ask = async (question) => {
|
|
691
|
+
try {
|
|
692
|
+
const answer = (await rl.question(question)).trim().toLowerCase();
|
|
693
|
+
return answer === "" || answer === "y" || answer === "yes" || answer === "o" || answer === "oui";
|
|
694
|
+
} catch {
|
|
695
|
+
aborted = true; // input closed
|
|
696
|
+
return false;
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
out.write(`\n${c.bold(`Set up ${BIN} ${SERVER_VERSION}`)}\n`);
|
|
701
|
+
out.write(c.dim(`Found: ${setups.map((s) => s.name).join(", ")}`) + "\n\n");
|
|
702
|
+
try {
|
|
703
|
+
for (const setup of setups) {
|
|
704
|
+
const todo = pendingItems(setup, status[setup.id]);
|
|
705
|
+
if (todo.length === 0) {
|
|
706
|
+
out.write(`${c.green("✓")} ${c.bold(setup.name)}: already set up\n`);
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
const what = todo.map((i) => ITEM_LABELS[i.kind]).join(" + ");
|
|
710
|
+
const yes = await ask(`${c.cyan("?")} Set up ${c.bold(setup.name)} (${what})? ${c.dim("[Y/n]")} `);
|
|
711
|
+
if (aborted) {
|
|
712
|
+
out.write(`\n${c.yellow("Setup stopped.")}\n`);
|
|
713
|
+
return 130;
|
|
714
|
+
}
|
|
715
|
+
if (!yes) {
|
|
716
|
+
out.write(` ${c.dim("· skipped")}\n`);
|
|
717
|
+
continue;
|
|
718
|
+
}
|
|
719
|
+
for (const item of todo) {
|
|
720
|
+
const label = ITEM_LABELS[item.kind];
|
|
721
|
+
if (item.write === "print") {
|
|
722
|
+
out.write(
|
|
723
|
+
` ${c.yellow("→")} ${label}: add this to ${item.file}` +
|
|
724
|
+
`${fs.existsSync(item.file) ? " (merge with what is there)" : ""}:\n` +
|
|
725
|
+
`${item.snippet.replace(/^/gm, " ")}\n`,
|
|
726
|
+
);
|
|
727
|
+
continue;
|
|
728
|
+
}
|
|
729
|
+
const { done, message } = applySetupItem(item, { stdio: "pipe" });
|
|
730
|
+
if (done) {
|
|
731
|
+
out.write(` ${c.green("✓")} ${label}: ${c.green(message)}\n`);
|
|
732
|
+
} else {
|
|
733
|
+
out.write(
|
|
734
|
+
` ${c.red("✗")} ${label}: ${message}\n` +
|
|
735
|
+
`${item.snippet.replace(/^/gm, " ")}\n`,
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
} finally {
|
|
741
|
+
rl.close();
|
|
742
|
+
}
|
|
743
|
+
const others = EDITOR_IDS.filter((id) => !setups.some((s) => s.id === id));
|
|
744
|
+
if (others.length) {
|
|
745
|
+
out.write(c.dim(`\nOther editors: ${BIN} setup <${others.join("|")}>`) + "\n");
|
|
746
|
+
}
|
|
747
|
+
return 0;
|
|
748
|
+
}
|
|
749
|
+
|
|
664
750
|
async function runSetup(argv) {
|
|
665
|
-
const flags = parseSubArgs(argv, { write: "boolean" });
|
|
751
|
+
const flags = parseSubArgs(argv, { write: "boolean", print: "boolean" });
|
|
666
752
|
if (flags.help) {
|
|
667
753
|
process.stdout.write(
|
|
668
|
-
`Usage: ${BIN} setup [${EDITOR_IDS.join("|")}|all] [--write]\n\n` +
|
|
669
|
-
"
|
|
670
|
-
"
|
|
671
|
-
"
|
|
754
|
+
`Usage: ${BIN} setup [${EDITOR_IDS.join("|")}|all] [--write|--print]\n\n` +
|
|
755
|
+
"Sets up the export task and AI tools in your editors (the ones found by default).\n" +
|
|
756
|
+
"In a terminal it asks editor by editor and skips what is already set up.\n" +
|
|
757
|
+
"--write set up everything without asking (scripts)\n" +
|
|
758
|
+
"--print only show what to add\n" +
|
|
759
|
+
"Files that do not exist yet are created and editor CLIs are run;\n" +
|
|
760
|
+
"existing files are never modified: you get the snippet to paste.\n",
|
|
672
761
|
);
|
|
673
762
|
return 0;
|
|
674
763
|
}
|
|
@@ -688,28 +777,47 @@ async function runSetup(argv) {
|
|
|
688
777
|
}
|
|
689
778
|
|
|
690
779
|
const out = process.stdout;
|
|
691
|
-
|
|
692
|
-
|
|
780
|
+
const c = makeStyle();
|
|
781
|
+
const interactive =
|
|
782
|
+
!flags.write && !flags.print && process.stdin.isTTY && process.stdout.isTTY;
|
|
783
|
+
if (interactive) {
|
|
784
|
+
const code = await setupInteractive(setups, c);
|
|
785
|
+
if (code !== 0) return code;
|
|
786
|
+
}
|
|
787
|
+
const status = flags.write ? Object.fromEntries(editorStatus().map((e) => [e.id, e])) : {};
|
|
788
|
+
for (const setup of interactive ? [] : setups) {
|
|
789
|
+
const todo = flags.write ? new Set(pendingItems(setup, status[setup.id])) : null;
|
|
790
|
+
out.write(
|
|
791
|
+
`\n${c.bold(`━━ ${setup.name} ━━`)}${setup.detected ? "" : c.dim(" (not detected)")}\n`,
|
|
792
|
+
);
|
|
693
793
|
for (const item of setup.items) {
|
|
694
|
-
out.write(`\n
|
|
695
|
-
if (item.file) out.write(` file: ${item.file}\n
|
|
794
|
+
out.write(`\n${c.cyan(`▸ ${item.label}`)}\n`);
|
|
795
|
+
if (item.file) out.write(c.dim(` file: ${item.file}`) + "\n");
|
|
696
796
|
out.write(`${item.snippet}\n`);
|
|
697
797
|
if (!flags.write) continue;
|
|
798
|
+
if (!todo.has(item)) {
|
|
799
|
+
const set = status[setup.id]?.[item.kind] === true;
|
|
800
|
+
out.write(` ${set ? c.green("✓") : c.dim("·")} ${set ? "already set up" : "not needed here"}\n`);
|
|
801
|
+
continue;
|
|
802
|
+
}
|
|
698
803
|
|
|
699
804
|
const { done, message } = applySetupItem(item);
|
|
700
|
-
|
|
805
|
+
const mark = done ? c.green("✓") : item.write === "print" ? c.yellow("→") : c.red("✗");
|
|
806
|
+
out.write(` ${mark} ${done ? c.green(message) : message}\n`);
|
|
701
807
|
}
|
|
702
808
|
}
|
|
703
809
|
|
|
810
|
+
const settingsFile = userSettingsPath();
|
|
704
811
|
out.write(
|
|
705
|
-
|
|
706
|
-
|
|
812
|
+
fs.existsSync(settingsFile)
|
|
813
|
+
? `\n${c.green("✓")} Settings file: ${settingsFile}\n`
|
|
814
|
+
: `\n${c.yellow("·")} No settings file yet (built-in look is used). Design your pages: ${c.cyan(`${BIN} studio`)}\n`,
|
|
707
815
|
);
|
|
708
816
|
const report = await doctorMarkdownPdf({});
|
|
709
817
|
out.write(
|
|
710
818
|
report.browser.available
|
|
711
|
-
?
|
|
712
|
-
:
|
|
819
|
+
? `${c.green("✓")} Browser: ${report.browser.version}\n`
|
|
820
|
+
: `${c.red("✗")} Browser: not found — ${report.browser.hint}\n`,
|
|
713
821
|
);
|
|
714
822
|
return report.browser.available ? 0 : 1;
|
|
715
823
|
}
|
package/export.mjs
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
readSettingsFile,
|
|
29
29
|
userSettingsPath,
|
|
30
30
|
} from "./lib/settings-loader.mjs";
|
|
31
|
-
import { applyPresets } from "./lib/looks.mjs";
|
|
31
|
+
import { accentCss, applyPresets, normalizeAccentColor } from "./lib/looks.mjs";
|
|
32
32
|
import { PAGE_BREAK_CSS, pageBreakComments } from "./lib/page-breaks.mjs";
|
|
33
33
|
import {
|
|
34
34
|
createPlaceholderResolver,
|
|
@@ -94,6 +94,7 @@ export const DEFAULT_SETTINGS = {
|
|
|
94
94
|
// content / rendering
|
|
95
95
|
font_family: null,
|
|
96
96
|
heading_font_family: null,
|
|
97
|
+
accent_color: null,
|
|
97
98
|
include_default_styles: true,
|
|
98
99
|
highlight: true,
|
|
99
100
|
highlight_style: "github.css",
|
|
@@ -342,6 +343,7 @@ export function normalizeSettings(raw) {
|
|
|
342
343
|
|
|
343
344
|
font_family: normalizeNonEmptyString(safe.font_family),
|
|
344
345
|
heading_font_family: normalizeNonEmptyString(safe.heading_font_family),
|
|
346
|
+
accent_color: normalizeAccentColor(safe.accent_color),
|
|
345
347
|
|
|
346
348
|
// Structured header/footer configs – pass through as-is for the
|
|
347
349
|
// config-merger / html-generator pipeline to consume.
|
|
@@ -560,6 +562,7 @@ function buildEffectiveOptions(args = {}, settings) {
|
|
|
560
562
|
normalizeNonEmptyString(args.font_family) ?? settings.font_family,
|
|
561
563
|
heading_font_family:
|
|
562
564
|
normalizeNonEmptyString(args.heading_font_family) ?? settings.heading_font_family,
|
|
565
|
+
accent_color: normalizeAccentColor(args.accent_color) ?? settings.accent_color,
|
|
563
566
|
};
|
|
564
567
|
}
|
|
565
568
|
|
|
@@ -874,6 +877,7 @@ export async function doctorMarkdownPdf(args) {
|
|
|
874
877
|
);
|
|
875
878
|
|
|
876
879
|
return {
|
|
880
|
+
version: SERVER_VERSION,
|
|
877
881
|
browser: browserInfo,
|
|
878
882
|
settings_sources: doc.sources,
|
|
879
883
|
settings: {
|
|
@@ -895,6 +899,7 @@ export async function doctorMarkdownPdf(args) {
|
|
|
895
899
|
display_header_footer: doc.settings.display_header_footer,
|
|
896
900
|
font_family: doc.settings.font_family,
|
|
897
901
|
heading_font_family: doc.settings.heading_font_family,
|
|
902
|
+
accent_color: doc.settings.accent_color,
|
|
898
903
|
header: doc.settings.header,
|
|
899
904
|
footer: doc.settings.footer,
|
|
900
905
|
},
|
|
@@ -968,6 +973,7 @@ export async function exportMarkdownPdf(args) {
|
|
|
968
973
|
margin: options.margin,
|
|
969
974
|
font_family: options.font_family,
|
|
970
975
|
heading_font_family: options.heading_font_family,
|
|
976
|
+
accent_color: options.accent_color,
|
|
971
977
|
include_default_styles: options.include_default_styles,
|
|
972
978
|
highlight: options.highlight,
|
|
973
979
|
highlight_style: options.highlight_style,
|
|
@@ -1001,6 +1007,7 @@ export async function exportMarkdownPdf(args) {
|
|
|
1001
1007
|
margin: mergedConfig.margin ?? options.margin,
|
|
1002
1008
|
font_family: mergedConfig.font_family ?? options.font_family,
|
|
1003
1009
|
heading_font_family: mergedConfig.heading_font_family ?? options.heading_font_family,
|
|
1010
|
+
accent_color: normalizeAccentColor(mergedConfig.accent_color) ?? options.accent_color,
|
|
1004
1011
|
include_default_styles:
|
|
1005
1012
|
mergedConfig.include_default_styles ?? options.include_default_styles,
|
|
1006
1013
|
highlight: mergedConfig.highlight ?? options.highlight,
|
|
@@ -1302,6 +1309,9 @@ async function renderMarkdownToHtmlWithBody(inputPath, body, title, options) {
|
|
|
1302
1309
|
if (options.heading_font_family) {
|
|
1303
1310
|
styleBlocks += `<style>h1, h2, h3, h4, h5, h6 { font-family: ${options.heading_font_family}; }</style>\n `;
|
|
1304
1311
|
}
|
|
1312
|
+
// Accent colour: only page styles that read --accent change with it.
|
|
1313
|
+
const accent = accentCss(options.accent_color);
|
|
1314
|
+
if (accent) styleBlocks += `<style>${accent}</style>\n `;
|
|
1305
1315
|
|
|
1306
1316
|
const baseHref = `${pathToFileURL(path.dirname(inputPath)).href}/`;
|
|
1307
1317
|
|
package/lib/doctor-report.mjs
CHANGED
|
@@ -3,25 +3,35 @@
|
|
|
3
3
|
* where every problem comes with the one command that fixes it.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { plain } from "./term-style.mjs";
|
|
7
|
+
|
|
6
8
|
/**
|
|
7
9
|
* @param {object} report result of doctorMarkdownPdf()
|
|
8
|
-
* @param {{bin?: string, nodeVersion?: string}} [opts]
|
|
10
|
+
* @param {{bin?: string, nodeVersion?: string, style?: typeof plain}} [opts]
|
|
9
11
|
* @returns {{text: string, ok: boolean}}
|
|
10
12
|
*/
|
|
11
|
-
export function formatDoctor(
|
|
13
|
+
export function formatDoctor(
|
|
14
|
+
report,
|
|
15
|
+
{ bin = "markdown-pdf-export", nodeVersion = process.versions.node, style = plain } = {},
|
|
16
|
+
) {
|
|
17
|
+
const c = style;
|
|
12
18
|
const lines = [];
|
|
13
19
|
let ok = true;
|
|
14
|
-
const good = (msg) => lines.push(` ✓ ${msg}`);
|
|
20
|
+
const good = (msg) => lines.push(` ${c.green("✓")} ${msg}`);
|
|
15
21
|
const bad = (msg, fix) => {
|
|
16
22
|
ok = false;
|
|
17
|
-
lines.push(` ✗ ${msg}`);
|
|
18
|
-
if (fix) lines.push(` fix: ${fix}`);
|
|
23
|
+
lines.push(` ${c.red("✗")} ${msg}`);
|
|
24
|
+
if (fix) lines.push(` fix: ${c.cyan(fix)}`);
|
|
19
25
|
};
|
|
20
26
|
const info = (msg, hint) => {
|
|
21
|
-
lines.push(` · ${msg}`);
|
|
22
|
-
if (hint) lines.push(` ${hint}`);
|
|
27
|
+
lines.push(` ${c.dim("·")} ${msg}`);
|
|
28
|
+
if (hint) lines.push(` ${c.cyan(hint)}`);
|
|
23
29
|
};
|
|
24
30
|
|
|
31
|
+
if (report.version) {
|
|
32
|
+
good(`${c.bold(`${bin} ${report.version}`)}` + (report.server_dir ? c.dim(` (${report.server_dir})`) : ""));
|
|
33
|
+
}
|
|
34
|
+
|
|
25
35
|
const major = Number.parseInt(nodeVersion, 10);
|
|
26
36
|
if (major >= 20) good(`Node ${nodeVersion}`);
|
|
27
37
|
else bad(`Node ${nodeVersion} is too old (needs 20 or newer)`, "install Node 20+ from nodejs.org");
|
|
@@ -47,6 +57,43 @@ export function formatDoctor(report, { bin = "markdown-pdf-export", nodeVersion
|
|
|
47
57
|
(st.font_family ? " · custom font" : ""),
|
|
48
58
|
);
|
|
49
59
|
|
|
50
|
-
const head = ok
|
|
51
|
-
|
|
60
|
+
const head = ok
|
|
61
|
+
? c.green(c.bold("✨ Everything is ready."))
|
|
62
|
+
: c.red(c.bold("Something needs attention:"));
|
|
63
|
+
const editors = report.editors ? `\n${formatEditors(report.editors, bin, c)}` : "";
|
|
64
|
+
return { text: `${head}\n\n${lines.join("\n")}\n${editors}`, ok };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const PARTS = { task: "export task", mcp: "AI tools" };
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Editors section: what is set up where. Never fails the check — a missing
|
|
71
|
+
* editor is a choice, not an error.
|
|
72
|
+
* @param {ReturnType<typeof import("./editor-setup.mjs").editorStatus>} editors
|
|
73
|
+
* @param {string} bin
|
|
74
|
+
*/
|
|
75
|
+
export function formatEditors(editors, bin = "markdown-pdf-export", style = plain) {
|
|
76
|
+
const c = style;
|
|
77
|
+
const lines = [c.bold("Editors:")];
|
|
78
|
+
for (const e of editors.filter((x) => x.detected)) {
|
|
79
|
+
const parts = Object.keys(PARTS).filter((k) => e[k] !== undefined);
|
|
80
|
+
const done = parts.filter((k) => e[k] === true);
|
|
81
|
+
const missing = parts.filter((k) => e[k] !== true);
|
|
82
|
+
const label = (ks) => ks.map((k) => PARTS[k]).join(", ");
|
|
83
|
+
if (missing.length === 0) {
|
|
84
|
+
lines.push(` ${c.green("✓")} ${c.bold(e.name)}: ${label(done)}`);
|
|
85
|
+
} else {
|
|
86
|
+
const note = e.mcp === "project" ? " (only in some project folders)" : "";
|
|
87
|
+
lines.push(
|
|
88
|
+
` ${c.yellow("·")} ${c.bold(e.name)}: ${done.length ? `${label(done)} ${c.green("✓")}, ` : ""}` +
|
|
89
|
+
c.yellow(`${label(missing)} not set up${note}`),
|
|
90
|
+
` add: ${c.cyan(`${bin} setup ${e.id} --write`)}`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
for (const w of e.warnings ?? []) lines.push(` ${c.yellow("!")} ${c.yellow(w)}`);
|
|
94
|
+
}
|
|
95
|
+
const absent = editors.filter((x) => !x.detected).map((x) => x.name);
|
|
96
|
+
// Not installed is a choice, not a problem: neutral grey, never red.
|
|
97
|
+
if (absent.length) lines.push(c.dim(` · Not found: ${absent.join(", ")}`));
|
|
98
|
+
return `${lines.join("\n")}\n`;
|
|
52
99
|
}
|
package/lib/editor-setup.mjs
CHANGED
|
@@ -16,6 +16,8 @@ export const SERVER_NAME = "markdown-pdf-export";
|
|
|
16
16
|
export const MCP_KEY = "markdown-pdf";
|
|
17
17
|
export const TASK_LABEL = "Markdown: Export to PDF";
|
|
18
18
|
export const EDITOR_IDS = ["zed", "vscode", "cursor", "claude-code", "claude-desktop", "copilot-cli"];
|
|
19
|
+
/** Short names people type for an editor id. */
|
|
20
|
+
export const EDITOR_ALIASES = { claude: "claude-code", code: "vscode", copilot: "copilot-cli" };
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* Version managers install node under a version-specific directory; editors
|
|
@@ -98,7 +100,8 @@ function roots({ home, platform, env }) {
|
|
|
98
100
|
* @property {string|null} file target file (null for CLI-only)
|
|
99
101
|
* @property {string} snippet text to show / write
|
|
100
102
|
* @property {"create"|"print"|"command"} write safe-write strategy
|
|
101
|
-
* @property {{cmd: string, args: string[]}} [run]
|
|
103
|
+
* @property {{cmd: string, args: string[], fallbacks?: string[]}} [run]
|
|
104
|
+
* CLI to run for "command"; `fallbacks` are full paths tried when `cmd` is not on PATH
|
|
102
105
|
*/
|
|
103
106
|
|
|
104
107
|
/**
|
|
@@ -108,6 +111,7 @@ function roots({ home, platform, env }) {
|
|
|
108
111
|
* @returns {{id: string, name: string, detected: boolean, items: SetupItem[]}}
|
|
109
112
|
*/
|
|
110
113
|
export function buildEditorSetup(editor, launch, ctx = {}) {
|
|
114
|
+
editor = EDITOR_ALIASES[editor] ?? editor;
|
|
111
115
|
const home = ctx.home ?? os.homedir();
|
|
112
116
|
const platform = ctx.platform ?? process.platform;
|
|
113
117
|
const env = ctx.env ?? process.env;
|
|
@@ -128,7 +132,8 @@ export function buildEditorSetup(editor, launch, ctx = {}) {
|
|
|
128
132
|
kind: "task",
|
|
129
133
|
label: "Zed task (add to tasks.json)",
|
|
130
134
|
file: path.join(dir, "tasks.json"),
|
|
131
|
-
|
|
135
|
+
// Zed files are JSONC: create a missing one, never edit an existing one.
|
|
136
|
+
write: exists(path.join(dir, "tasks.json")) ? "print" : "create",
|
|
132
137
|
snippet: json([
|
|
133
138
|
{
|
|
134
139
|
label: TASK_LABEL,
|
|
@@ -155,14 +160,15 @@ export function buildEditorSetup(editor, launch, ctx = {}) {
|
|
|
155
160
|
const isCursor = editor === "cursor";
|
|
156
161
|
const userDir = path.join(r.userData, isCursor ? "Cursor" : "Code", "User");
|
|
157
162
|
const mcpFile = path.join(home, ".cursor", "mcp.json");
|
|
163
|
+
const taskFile = path.join(userDir, "tasks.json");
|
|
158
164
|
const addMcp = JSON.stringify({ name: MCP_KEY, ...server });
|
|
159
165
|
/** @type {SetupItem[]} */
|
|
160
166
|
const items = [
|
|
161
167
|
{
|
|
162
168
|
kind: "task",
|
|
163
169
|
label: `${isCursor ? "Cursor" : "VS Code"} task (add to tasks.json)`,
|
|
164
|
-
file:
|
|
165
|
-
write: "print",
|
|
170
|
+
file: taskFile,
|
|
171
|
+
write: exists(taskFile) ? "print" : "create",
|
|
166
172
|
snippet: json({
|
|
167
173
|
version: "2.0.0",
|
|
168
174
|
tasks: [
|
|
@@ -190,7 +196,18 @@ export function buildEditorSetup(editor, launch, ctx = {}) {
|
|
|
190
196
|
label: "VS Code MCP server",
|
|
191
197
|
file: null,
|
|
192
198
|
write: "command",
|
|
193
|
-
run: {
|
|
199
|
+
run: {
|
|
200
|
+
cmd: "code",
|
|
201
|
+
args: ["--add-mcp", addMcp],
|
|
202
|
+
// macOS: `code` is only on PATH after "Install 'code' command in PATH".
|
|
203
|
+
fallbacks:
|
|
204
|
+
platform === "darwin"
|
|
205
|
+
? [
|
|
206
|
+
"/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code",
|
|
207
|
+
path.join(home, "Applications", "Visual Studio Code.app", "Contents", "Resources", "app", "bin", "code"),
|
|
208
|
+
]
|
|
209
|
+
: [],
|
|
210
|
+
},
|
|
194
211
|
snippet: shellJoin(["code", "--add-mcp", addMcp], platform),
|
|
195
212
|
},
|
|
196
213
|
];
|
|
@@ -215,10 +232,10 @@ export function buildEditorSetup(editor, launch, ctx = {}) {
|
|
|
215
232
|
write: "command",
|
|
216
233
|
run: {
|
|
217
234
|
cmd: "claude",
|
|
218
|
-
args: ["mcp", "add", MCP_KEY, "--", server.command, ...server.args],
|
|
235
|
+
args: ["mcp", "add", "--scope", "user", MCP_KEY, "--", server.command, ...server.args],
|
|
219
236
|
},
|
|
220
237
|
snippet: shellJoin(
|
|
221
|
-
["claude", "mcp", "add", MCP_KEY, "--", server.command, ...server.args],
|
|
238
|
+
["claude", "mcp", "add", "--scope", "user", MCP_KEY, "--", server.command, ...server.args],
|
|
222
239
|
platform,
|
|
223
240
|
),
|
|
224
241
|
},
|
|
@@ -289,13 +306,122 @@ export function applySetupItem(item, { stdio = "inherit" } = {}) {
|
|
|
289
306
|
if (item.write === "command") {
|
|
290
307
|
// Windows: code/claude are .cmd shims, which need the shell; pass one
|
|
291
308
|
// pre-quoted command line so JSON arguments survive cmd.exe.
|
|
292
|
-
|
|
309
|
+
let result =
|
|
293
310
|
process.platform === "win32"
|
|
294
311
|
? spawnSync(item.snippet, { stdio, shell: true })
|
|
295
312
|
: spawnSync(item.run.cmd, item.run.args, { stdio });
|
|
313
|
+
for (const cmd of item.run.fallbacks ?? []) {
|
|
314
|
+
if (result.error?.code !== "ENOENT") break;
|
|
315
|
+
if (fs.existsSync(cmd)) result = spawnSync(cmd, item.run.args, { stdio });
|
|
316
|
+
}
|
|
296
317
|
return result.status === 0
|
|
297
318
|
? { done: true, message: `ran: ${item.snippet}` }
|
|
298
319
|
: { done: false, message: `could not run "${item.run.cmd}" — run the command yourself` };
|
|
299
320
|
}
|
|
300
321
|
return { done: false, message: "existing file: paste the snippet yourself" };
|
|
301
322
|
}
|
|
323
|
+
|
|
324
|
+
// ── Status (doctor) ──────────────────────────────────────────────────────────
|
|
325
|
+
|
|
326
|
+
const readText = (file) => {
|
|
327
|
+
try {
|
|
328
|
+
return fs.readFileSync(file, "utf8");
|
|
329
|
+
} catch {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
/** Task file: names our package. Settings/MCP file: has a "markdown-pdf" entry. */
|
|
335
|
+
const hasTask = (text) => text !== null && text.includes(SERVER_NAME);
|
|
336
|
+
const hasMcpKey = (text) => text !== null && text.includes(`"${MCP_KEY}"`);
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Claude Code keeps user-scope servers at the top of ~/.claude.json and
|
|
340
|
+
* local-scope ones per project. "project" = only set up for some folders.
|
|
341
|
+
* @returns {boolean|"project"}
|
|
342
|
+
*/
|
|
343
|
+
function claudeCodeMcp(file) {
|
|
344
|
+
const text = readText(file);
|
|
345
|
+
if (text === null) return false;
|
|
346
|
+
try {
|
|
347
|
+
const data = JSON.parse(text);
|
|
348
|
+
if (data?.mcpServers?.[MCP_KEY]) return true;
|
|
349
|
+
const inProject = Object.values(data?.projects ?? {}).some((p) => p?.mcpServers?.[MCP_KEY]);
|
|
350
|
+
return inProject ? "project" : false;
|
|
351
|
+
} catch {
|
|
352
|
+
return hasMcpKey(text);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* What is set up in each editor: read-only, for `doctor`.
|
|
358
|
+
* `task` / `mcp` are undefined when the editor has no such thing.
|
|
359
|
+
* `warnings` flags configs known to cause trouble (an old settings override).
|
|
360
|
+
* @param {{home?: string, platform?: string, env?: NodeJS.ProcessEnv}} [ctx]
|
|
361
|
+
* @returns {{id: string, name: string, detected: boolean, task?: boolean, mcp?: boolean|"project", warnings: string[]}[]}
|
|
362
|
+
*/
|
|
363
|
+
export function editorStatus(ctx = {}) {
|
|
364
|
+
const home = ctx.home ?? os.homedir();
|
|
365
|
+
const platform = ctx.platform ?? process.platform;
|
|
366
|
+
const env = ctx.env ?? process.env;
|
|
367
|
+
const r = roots({ home, platform, env });
|
|
368
|
+
|
|
369
|
+
return EDITOR_IDS.map((id) => {
|
|
370
|
+
const { name, detected } = buildEditorSetup(id, { command: "npx", args: [] }, { home, platform, env });
|
|
371
|
+
const out = { id, name, detected, warnings: [] };
|
|
372
|
+
let taskFile = null;
|
|
373
|
+
switch (id) {
|
|
374
|
+
case "zed":
|
|
375
|
+
taskFile = path.join(r.zed, "tasks.json");
|
|
376
|
+
out.mcp = hasMcpKey(readText(path.join(r.zed, "settings.json")));
|
|
377
|
+
break;
|
|
378
|
+
case "vscode":
|
|
379
|
+
case "cursor": {
|
|
380
|
+
const userDir = path.join(r.userData, id === "cursor" ? "Cursor" : "Code", "User");
|
|
381
|
+
// ~/.cursor alone = Cursor Agent CLI without the app: no task to offer.
|
|
382
|
+
if (id === "vscode" || fs.existsSync(userDir)) taskFile = path.join(userDir, "tasks.json");
|
|
383
|
+
out.mcp = hasMcpKey(
|
|
384
|
+
readText(id === "cursor" ? path.join(home, ".cursor", "mcp.json") : path.join(userDir, "mcp.json")),
|
|
385
|
+
);
|
|
386
|
+
break;
|
|
387
|
+
}
|
|
388
|
+
case "claude-code":
|
|
389
|
+
out.mcp = claudeCodeMcp(path.join(home, ".claude.json"));
|
|
390
|
+
break;
|
|
391
|
+
case "claude-desktop":
|
|
392
|
+
out.mcp = hasMcpKey(readText(path.join(r.appData, "Claude", "claude_desktop_config.json")));
|
|
393
|
+
break;
|
|
394
|
+
case "copilot-cli":
|
|
395
|
+
out.mcp = hasMcpKey(readText(path.join(home, ".copilot", "mcp-config.json")));
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
if (taskFile) {
|
|
399
|
+
const text = readText(taskFile);
|
|
400
|
+
out.task = hasTask(text);
|
|
401
|
+
if (out.task && text.includes("MARKDOWN_PDF_SETTINGS")) {
|
|
402
|
+
out.warnings.push(
|
|
403
|
+
`${taskFile} sets MARKDOWN_PDF_SETTINGS, which replaces your settings file`,
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (out.task || out.mcp) out.detected = true; // set up, even if its folder moved
|
|
408
|
+
return out;
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** What a setup item adds, in words. */
|
|
413
|
+
export const ITEM_LABELS = { task: "export task", mcp: "AI tools" };
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Items of one editor that are not set up yet, given its editorStatus() entry.
|
|
417
|
+
* Claude Code set up only for some folders ("project") still counts as to do;
|
|
418
|
+
* a kind the status does not list is skipped (it does not apply here).
|
|
419
|
+
* @param {{items: SetupItem[]}} setup
|
|
420
|
+
* @param {{task?: boolean, mcp?: boolean|"project"}|undefined} status
|
|
421
|
+
* @returns {SetupItem[]}
|
|
422
|
+
*/
|
|
423
|
+
export function pendingItems(setup, status) {
|
|
424
|
+
if (!status) return [...setup.items];
|
|
425
|
+
// A kind missing from the status does not apply here (Cursor CLI without the app).
|
|
426
|
+
return setup.items.filter((item) => item.kind in status && status[item.kind] !== true);
|
|
427
|
+
}
|
package/lib/looks.mjs
CHANGED
|
@@ -14,7 +14,11 @@ import { fileURLToPath } from "node:url";
|
|
|
14
14
|
|
|
15
15
|
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
16
16
|
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* `accent` = the colour of titles, rules and code bars in that style; only the
|
|
19
|
+
* styles that have one let `accent_color` change it.
|
|
20
|
+
* @type {Record<string, {description: string, accent?: string, settings: object}>}
|
|
21
|
+
*/
|
|
18
22
|
export const LOOKS = {
|
|
19
23
|
clean: {
|
|
20
24
|
description: "Default. GitHub-style, neutral.",
|
|
@@ -22,6 +26,7 @@ export const LOOKS = {
|
|
|
22
26
|
},
|
|
23
27
|
report: {
|
|
24
28
|
description: "Serif headings, strong title rule. Business reports.",
|
|
29
|
+
accent: "#24292e",
|
|
25
30
|
settings: { stylesheet: "report.css", highlight_style: "github.css" },
|
|
26
31
|
},
|
|
27
32
|
academic: {
|
|
@@ -41,6 +46,7 @@ export const LOOKS = {
|
|
|
41
46
|
},
|
|
42
47
|
technical: {
|
|
43
48
|
description: "For documents with code: framed code blocks, blue accents.",
|
|
49
|
+
accent: "#0969da",
|
|
44
50
|
settings: { stylesheet: "technical.css", highlight_style: "atom-one-light.css" },
|
|
45
51
|
},
|
|
46
52
|
};
|
|
@@ -51,6 +57,8 @@ export const FONTS = {
|
|
|
51
57
|
book: '"Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif',
|
|
52
58
|
humanist: 'Seravek, "Gill Sans Nova", "Gill Sans", Ubuntu, Calibri, "DejaVu Sans", sans-serif',
|
|
53
59
|
geometric: 'Avenir, "Avenir Next", Montserrat, Corbel, "Century Gothic", "URW Gothic", sans-serif',
|
|
60
|
+
// Microsoft Office's default fonts; Carlito = free, same-width stand-in for Calibri (Linux).
|
|
61
|
+
office: 'Aptos, Calibri, Carlito, "Segoe UI", Arial, sans-serif',
|
|
54
62
|
mono: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',
|
|
55
63
|
system: "system-ui, sans-serif",
|
|
56
64
|
};
|
|
@@ -62,6 +70,7 @@ export const FONT_LABELS = {
|
|
|
62
70
|
book: "Book serif",
|
|
63
71
|
humanist: "Humanist sans",
|
|
64
72
|
geometric: "Geometric sans",
|
|
73
|
+
office: "Office",
|
|
65
74
|
mono: "Mono",
|
|
66
75
|
system: "System",
|
|
67
76
|
};
|
|
@@ -94,6 +103,20 @@ export function readTemplate(name) {
|
|
|
94
103
|
return data;
|
|
95
104
|
}
|
|
96
105
|
|
|
106
|
+
/** A valid `accent_color` (#rgb or #rrggbb), else null. */
|
|
107
|
+
export function normalizeAccentColor(value) {
|
|
108
|
+
if (typeof value !== "string") return null;
|
|
109
|
+
const v = value.trim();
|
|
110
|
+
return /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(v) ? v.toLowerCase() : null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** CSS that hands an accent colour to the page styles (they read --accent*). */
|
|
114
|
+
export function accentCss(color) {
|
|
115
|
+
const c = normalizeAccentColor(color);
|
|
116
|
+
if (!c) return "";
|
|
117
|
+
return `:root { --accent: ${c}; --accent-strong: color-mix(in srgb, ${c} 80%, black); --accent-soft: color-mix(in srgb, ${c} 8%, white); }`;
|
|
118
|
+
}
|
|
119
|
+
|
|
97
120
|
const isPlain = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
98
121
|
|
|
99
122
|
function merge(base, over) {
|
package/lib/studio-server.mjs
CHANGED
|
@@ -36,7 +36,14 @@ import {
|
|
|
36
36
|
readSettingsFile,
|
|
37
37
|
userSettingsPath,
|
|
38
38
|
} from "./settings-loader.mjs";
|
|
39
|
-
import {
|
|
39
|
+
import {
|
|
40
|
+
EDITOR_IDS,
|
|
41
|
+
applySetupItem,
|
|
42
|
+
buildEditorSetup,
|
|
43
|
+
editorStatus,
|
|
44
|
+
launchSpec,
|
|
45
|
+
pendingItems,
|
|
46
|
+
} from "./editor-setup.mjs";
|
|
40
47
|
import { IMAGE_FORMATS } from "./types.mjs";
|
|
41
48
|
|
|
42
49
|
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
@@ -261,6 +268,7 @@ export async function startStudio(opts = {}) {
|
|
|
261
268
|
description: def.description,
|
|
262
269
|
margin: def.settings.margin ?? null,
|
|
263
270
|
highlight: def.settings.highlight_style ?? null,
|
|
271
|
+
accent: def.accent ?? null,
|
|
264
272
|
};
|
|
265
273
|
}
|
|
266
274
|
return {
|
|
@@ -393,15 +401,27 @@ export async function startStudio(opts = {}) {
|
|
|
393
401
|
|
|
394
402
|
if (req.method === "GET" && route === "/api/state") return send(res, 200, state());
|
|
395
403
|
if (req.method === "GET" && route === "/api/editors") {
|
|
404
|
+
const status = Object.fromEntries(editorStatus().map((e) => [e.id, e]));
|
|
396
405
|
return send(
|
|
397
406
|
res,
|
|
398
407
|
200,
|
|
399
|
-
editors().map((e) =>
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
408
|
+
editors().map((e) => {
|
|
409
|
+
const todo = new Set(pendingItems(e, status[e.id]));
|
|
410
|
+
return {
|
|
411
|
+
id: e.id,
|
|
412
|
+
name: e.name,
|
|
413
|
+
detected: e.detected || Boolean(status[e.id]?.detected),
|
|
414
|
+
items: e.items.map((i) => ({
|
|
415
|
+
kind: i.kind,
|
|
416
|
+
label: i.label,
|
|
417
|
+
file: i.file ?? null,
|
|
418
|
+
snippet: i.snippet,
|
|
419
|
+
write: i.write,
|
|
420
|
+
// not set up yet, and applies on this computer
|
|
421
|
+
pending: todo.has(i),
|
|
422
|
+
})),
|
|
423
|
+
};
|
|
424
|
+
}),
|
|
405
425
|
);
|
|
406
426
|
}
|
|
407
427
|
if (req.method === "GET" && route === "/api/check") {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Tiny terminal colours, no dependency. On only for a TTY;
|
|
3
|
+
* NO_COLOR turns it off, FORCE_COLOR (≠ "0") turns it on. See no-color.org.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {{stream?: {isTTY?: boolean}, env?: NodeJS.ProcessEnv}} [opts]
|
|
8
|
+
*/
|
|
9
|
+
export function makeStyle({ stream = process.stdout, env = process.env } = {}) {
|
|
10
|
+
const enabled = env.FORCE_COLOR
|
|
11
|
+
? env.FORCE_COLOR !== "0"
|
|
12
|
+
: !env.NO_COLOR && Boolean(stream.isTTY) && env.TERM !== "dumb";
|
|
13
|
+
const wrap = (open, close) => (text) =>
|
|
14
|
+
enabled ? `\x1b[${open}m${text}\x1b[${close}m` : String(text);
|
|
15
|
+
return {
|
|
16
|
+
enabled,
|
|
17
|
+
bold: wrap(1, 22),
|
|
18
|
+
dim: wrap(2, 22),
|
|
19
|
+
red: wrap(31, 39),
|
|
20
|
+
green: wrap(32, 39),
|
|
21
|
+
yellow: wrap(33, 39),
|
|
22
|
+
cyan: wrap(36, 39),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** No colours: for tests, JSON, logs. */
|
|
27
|
+
export const plain = makeStyle({ stream: {}, env: { NO_COLOR: "1" } });
|
package/looks/report.css
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
/* Look: report — serif headings, restrained rules, roomy paragraphs.
|
|
1
|
+
/* Look: report — serif headings, restrained rules, roomy paragraphs.
|
|
2
|
+
Accent colours come from accent_color when set (see accentCss in lib/looks.mjs). */
|
|
2
3
|
:root { line-height: 1.7; }
|
|
3
4
|
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; letter-spacing: -0.01em; }
|
|
4
|
-
h1 { border-bottom: 2px solid #24292e; }
|
|
5
|
+
h1 { border-bottom: 2px solid var(--accent, #24292e); }
|
|
5
6
|
h2 { border-bottom: 1px solid #d0d7de; }
|
|
6
7
|
table { border-collapse: collapse; }
|
|
7
8
|
th { background: #f6f8fa; }
|
|
8
|
-
blockquote { border-left: 4px solid #0969da; color: #57606a; }
|
|
9
|
+
blockquote { border-left: 4px solid var(--accent, #0969da); color: #57606a; }
|
package/looks/technical.css
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
/* Look: technical — for documents with code: framed code blocks, blue accents.
|
|
1
|
+
/* Look: technical — for documents with code: framed code blocks, blue accents.
|
|
2
|
+
Accent colours come from accent_color when set (see accentCss in lib/looks.mjs). */
|
|
2
3
|
:root { font-size: 13px; }
|
|
3
|
-
h1 { border-bottom: 3px solid #0969da; }
|
|
4
|
-
h2 { border-bottom: none; color: #0550ae; }
|
|
4
|
+
h1 { border-bottom: 3px solid var(--accent, #0969da); }
|
|
5
|
+
h2 { border-bottom: none; color: var(--accent-strong, #0550ae); }
|
|
5
6
|
pre.hljs, pre:not(.hljs) {
|
|
6
7
|
border: 1px solid #d0d7de;
|
|
7
|
-
border-left: 3px solid #0969da;
|
|
8
|
+
border-left: 3px solid var(--accent, #0969da);
|
|
8
9
|
border-radius: 4px;
|
|
9
10
|
}
|
|
10
|
-
:not(pre) > code { color: #0550ae; background: #eef4fb; }
|
|
11
|
-
th { background: #eef4fb; }
|
|
11
|
+
:not(pre) > code { color: var(--accent-strong, #0550ae); background: var(--accent-soft, #eef4fb); }
|
|
12
|
+
th { background: var(--accent-soft, #eef4fb); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdown-pdf-export",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Markdown to PDF with your header, footer, page numbers and logo. Design pages in Studio, export from VS Code, Zed, Cursor, Claude or any MCP client, or the command line.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"mcpName": "io.github.matinfo-tech/markdown-pdf-export",
|
|
@@ -83,7 +83,11 @@
|
|
|
83
83
|
"documentation",
|
|
84
84
|
"report"
|
|
85
85
|
],
|
|
86
|
-
"author":
|
|
86
|
+
"author": {
|
|
87
|
+
"name": "Matinfo",
|
|
88
|
+
"email": "dev@matinfo.tech",
|
|
89
|
+
"url": "https://matinfo.tech"
|
|
90
|
+
},
|
|
87
91
|
"license": "MIT",
|
|
88
92
|
"repository": {
|
|
89
93
|
"type": "git",
|
|
@@ -91,7 +95,8 @@
|
|
|
91
95
|
},
|
|
92
96
|
"homepage": "https://markdown-pdf.matinfo.tech/",
|
|
93
97
|
"bugs": {
|
|
94
|
-
"url": "https://github.com/matinfo-tech/markdown-pdf-export/issues"
|
|
98
|
+
"url": "https://github.com/matinfo-tech/markdown-pdf-export/issues",
|
|
99
|
+
"email": "dev@matinfo.tech"
|
|
95
100
|
},
|
|
96
101
|
"packageManager": "npm@11.12.1",
|
|
97
102
|
"devDependencies": {
|
|
@@ -257,6 +257,11 @@
|
|
|
257
257
|
"type": "string",
|
|
258
258
|
"description": "CSS font-family value for headings (h1-h6). Default: same as the body text."
|
|
259
259
|
},
|
|
260
|
+
"accent_color": {
|
|
261
|
+
"type": "string",
|
|
262
|
+
"pattern": "^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$",
|
|
263
|
+
"description": "Accent colour of the page style, as #rgb or #rrggbb: title rules, coloured titles, code block bars. Used by the report and technical looks; the others have no accent."
|
|
264
|
+
},
|
|
260
265
|
"look": {
|
|
261
266
|
"type": "string",
|
|
262
267
|
"enum": [
|
|
@@ -276,6 +281,7 @@
|
|
|
276
281
|
"book",
|
|
277
282
|
"humanist",
|
|
278
283
|
"geometric",
|
|
284
|
+
"office",
|
|
279
285
|
"mono",
|
|
280
286
|
"system"
|
|
281
287
|
],
|
|
@@ -289,6 +295,7 @@
|
|
|
289
295
|
"book",
|
|
290
296
|
"humanist",
|
|
291
297
|
"geometric",
|
|
298
|
+
"office",
|
|
292
299
|
"mono",
|
|
293
300
|
"system"
|
|
294
301
|
],
|
package/studio/app.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
ZONES,
|
|
9
9
|
draftToSettings,
|
|
10
10
|
emptyDraft,
|
|
11
|
+
lookAccent,
|
|
11
12
|
lookDefaults,
|
|
12
13
|
matchLayout,
|
|
13
14
|
renderText,
|
|
@@ -66,6 +67,11 @@ const thumbs = new Map(); // image path → object URL of the file just uploaded
|
|
|
66
67
|
const AREA_NAMES = { header: "Top", footer: "Bottom" };
|
|
67
68
|
const SIZE_LABELS = { s: "Small", m: "Medium", l: "Large" };
|
|
68
69
|
const MARGIN_LABELS = { narrow: "Narrow", normal: "Normal", wide: "Wide" };
|
|
70
|
+
/** What the theme colour paints, per page style that has one. */
|
|
71
|
+
const ACCENT_HINTS = {
|
|
72
|
+
technical: "Title rule, section titles, code bars.",
|
|
73
|
+
report: "Title rule and quote bars.",
|
|
74
|
+
};
|
|
69
75
|
const LOOK_LABELS = { clean: "Clean", report: "Report", academic: "Academic", compact: "Compact", technical: "Technical" };
|
|
70
76
|
|
|
71
77
|
const currentSettings = () => draftToSettings(draft, raw, { looks: server.looks });
|
|
@@ -120,6 +126,9 @@ function build() {
|
|
|
120
126
|
$(id).addEventListener("change", (e) => change(() => (draft[key] = e.target.value)));
|
|
121
127
|
}
|
|
122
128
|
|
|
129
|
+
$("accent").addEventListener("input", (e) => change(() => (draft.accent = e.target.value)));
|
|
130
|
+
$("accent-reset").addEventListener("click", () => change(() => (draft.accent = "")));
|
|
131
|
+
|
|
123
132
|
$("format").replaceChildren(...server.pageFormats.map((f) => el("option", { value: f, text: f })));
|
|
124
133
|
$("format").addEventListener("change", (e) => change(() => (draft.page_format = e.target.value)));
|
|
125
134
|
|
|
@@ -357,6 +366,7 @@ function sync() {
|
|
|
357
366
|
$(id).value = draft[key];
|
|
358
367
|
$(id).style.fontFamily = server.fonts[draft[key]] ?? ""; // the control shows its own choice
|
|
359
368
|
}
|
|
369
|
+
syncAccent();
|
|
360
370
|
$("format").value = draft.page_format;
|
|
361
371
|
$("highlight").value = draft.highlight;
|
|
362
372
|
// The diagram's side padding follows the margins, so text and rules sit where they will print.
|
|
@@ -390,6 +400,18 @@ function sync() {
|
|
|
390
400
|
}
|
|
391
401
|
}
|
|
392
402
|
|
|
403
|
+
/** Theme colour: offered only for page styles that have one. */
|
|
404
|
+
function syncAccent() {
|
|
405
|
+
const own = lookAccent(draft.look, server.looks);
|
|
406
|
+
$("accent-box").hidden = !own;
|
|
407
|
+
if (!own) return;
|
|
408
|
+
const value = draft.accent || own;
|
|
409
|
+
$("accent").value = value;
|
|
410
|
+
$("accent-swatch").style.background = value;
|
|
411
|
+
$("accent-hint").textContent = ACCENT_HINTS[draft.look] ?? "";
|
|
412
|
+
$("accent-reset").hidden = !draft.accent || draft.accent.toLowerCase() === own;
|
|
413
|
+
}
|
|
414
|
+
|
|
393
415
|
// ── preview ─────────────────────────────────────────────────────────────────
|
|
394
416
|
let previewTimer = null;
|
|
395
417
|
let previewRun = 0;
|
|
@@ -492,7 +514,7 @@ async function openEditors() {
|
|
|
492
514
|
const dialog = $("editors");
|
|
493
515
|
const list = $("editors-list");
|
|
494
516
|
list.replaceChildren(el("p", { class: "hint", text: "Looking for your editors…" }));
|
|
495
|
-
dialog.showModal();
|
|
517
|
+
if (!dialog.open) dialog.showModal();
|
|
496
518
|
let editors;
|
|
497
519
|
try {
|
|
498
520
|
editors = await api("/api/editors");
|
|
@@ -509,16 +531,7 @@ async function openEditors() {
|
|
|
509
531
|
EDITOR_NOTES[editor.id] ? el("p", { class: "editor-note", text: EDITOR_NOTES[editor.id] }) : null,
|
|
510
532
|
...editor.items.map((item, index) => {
|
|
511
533
|
const result = el("div", { class: "result", role: "status" });
|
|
512
|
-
const copy =
|
|
513
|
-
type: "button",
|
|
514
|
-
class: "btn small",
|
|
515
|
-
text: "Copy",
|
|
516
|
-
onclick: async () => {
|
|
517
|
-
await navigator.clipboard.writeText(item.snippet);
|
|
518
|
-
copy.textContent = "Copied";
|
|
519
|
-
setTimeout(() => (copy.textContent = "Copy"), 1500);
|
|
520
|
-
},
|
|
521
|
-
});
|
|
534
|
+
const copy = copyButton(item.snippet);
|
|
522
535
|
const auto =
|
|
523
536
|
item.write === "print"
|
|
524
537
|
? null
|
|
@@ -596,10 +609,127 @@ async function openEditors() {
|
|
|
596
609
|
tabs.append(button);
|
|
597
610
|
});
|
|
598
611
|
|
|
599
|
-
|
|
612
|
+
const found = sorted.filter((e) => e.detected);
|
|
613
|
+
const manual = el(
|
|
614
|
+
"details",
|
|
615
|
+
{ class: "manual", open: found.length === 0 },
|
|
616
|
+
el("summary", { text: found.length ? "All editors and manual steps" : "Pick your editor" }),
|
|
617
|
+
tabs,
|
|
618
|
+
panel,
|
|
619
|
+
);
|
|
620
|
+
list.replaceChildren(quickSetup(found), manual);
|
|
600
621
|
select(current);
|
|
601
622
|
}
|
|
602
623
|
|
|
624
|
+
function copyButton(text) {
|
|
625
|
+
const button = el("button", {
|
|
626
|
+
type: "button",
|
|
627
|
+
class: "btn small",
|
|
628
|
+
text: "Copy",
|
|
629
|
+
onclick: async () => {
|
|
630
|
+
await navigator.clipboard.writeText(text);
|
|
631
|
+
button.textContent = "Copied";
|
|
632
|
+
setTimeout(() => (button.textContent = "Copy"), 1500);
|
|
633
|
+
},
|
|
634
|
+
});
|
|
635
|
+
return button;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
const KIND_LABEL = { task: "export task", mcp: "AI tools" };
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Editors found on this computer, one switch each (on by default). Already
|
|
642
|
+
* set-up parts are skipped; files that exist are never edited — the person
|
|
643
|
+
* gets the snippet to paste instead.
|
|
644
|
+
*/
|
|
645
|
+
function quickSetup(found) {
|
|
646
|
+
const box = el("section", { class: "quick", "aria-label": "Editors found on this computer" });
|
|
647
|
+
if (found.length === 0) {
|
|
648
|
+
box.append(el("p", { class: "hint", text: "No editor found on this computer. Pick yours below." }));
|
|
649
|
+
return box;
|
|
650
|
+
}
|
|
651
|
+
box.append(el("h3", { text: "Found on this computer" }));
|
|
652
|
+
|
|
653
|
+
const rows = found.map((editor) => {
|
|
654
|
+
const todo = editor.items.map((item, index) => ({ item, index })).filter((x) => x.item.pending);
|
|
655
|
+
const result = el("div", { class: "quick-result", role: "status" });
|
|
656
|
+
if (todo.length === 0) {
|
|
657
|
+
const row = el(
|
|
658
|
+
"div",
|
|
659
|
+
{ class: "quick-row done" },
|
|
660
|
+
el("span", { class: "tick", "aria-hidden": "true", text: "✓" }),
|
|
661
|
+
el("span", { class: "quick-name", text: editor.name }),
|
|
662
|
+
el("span", { class: "quick-what", text: "Already set up" }),
|
|
663
|
+
);
|
|
664
|
+
return { row, toggle: null };
|
|
665
|
+
}
|
|
666
|
+
const id = `quick-${editor.id}`;
|
|
667
|
+
const toggle = el("input", { type: "checkbox", role: "switch", class: "switch", id, checked: true });
|
|
668
|
+
const what = [...new Set(todo.map((x) => KIND_LABEL[x.item.kind]))].join(" + ");
|
|
669
|
+
const row = el(
|
|
670
|
+
"div",
|
|
671
|
+
{ class: "quick-row" },
|
|
672
|
+
toggle,
|
|
673
|
+
el("label", { for: id, class: "quick-name", text: editor.name }),
|
|
674
|
+
el("span", { class: "quick-what", text: what }),
|
|
675
|
+
result,
|
|
676
|
+
);
|
|
677
|
+
return { row, toggle, editor, todo, result };
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
const pending = rows.filter((r) => r.toggle);
|
|
681
|
+
box.append(...rows.map((r) => r.row));
|
|
682
|
+
if (pending.length === 0) {
|
|
683
|
+
box.append(el("p", { class: "hint", text: "Everything found here is set up." }));
|
|
684
|
+
return box;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
const go = el("button", { type: "button", class: "btn primary" });
|
|
688
|
+
const selected = () => pending.filter((r) => r.toggle.checked && !r.toggle.disabled);
|
|
689
|
+
const refresh = () => {
|
|
690
|
+
const n = selected().length;
|
|
691
|
+
go.textContent = n ? `Set up ${n} editor${n > 1 ? "s" : ""}` : "Nothing selected";
|
|
692
|
+
go.disabled = n === 0;
|
|
693
|
+
};
|
|
694
|
+
for (const r of pending) r.toggle.addEventListener("change", refresh);
|
|
695
|
+
|
|
696
|
+
const line = (ok, text, title) => el("p", { class: ok ? "ok" : "bad", text: `${ok ? "✓" : "✗"} ${text}`, title });
|
|
697
|
+
const paste = (item, why) =>
|
|
698
|
+
el(
|
|
699
|
+
"div",
|
|
700
|
+
{ class: "paste" },
|
|
701
|
+
el("div", { class: "step-head" }, el("span", { text: why }), copyButton(item.snippet)),
|
|
702
|
+
el("pre", { text: item.snippet }),
|
|
703
|
+
);
|
|
704
|
+
|
|
705
|
+
go.addEventListener("click", async () => {
|
|
706
|
+
go.disabled = true;
|
|
707
|
+
for (const r of selected()) {
|
|
708
|
+
r.toggle.disabled = true;
|
|
709
|
+
r.result.replaceChildren();
|
|
710
|
+
for (const { item, index } of r.todo) {
|
|
711
|
+
const label = KIND_LABEL[item.kind];
|
|
712
|
+
if (item.write === "print") {
|
|
713
|
+
r.result.append(paste(item, `${label}: paste this into ${item.file}`));
|
|
714
|
+
continue;
|
|
715
|
+
}
|
|
716
|
+
try {
|
|
717
|
+
const { done, message } = await api("/api/editors/apply", { method: "POST", json: { id: r.editor.id, index } });
|
|
718
|
+
r.result.append(line(done, done ? `${label} added` : `${label}: ${message}`, message));
|
|
719
|
+
if (!done) r.result.append(paste(item, "Run or add this yourself:"));
|
|
720
|
+
} catch (error) {
|
|
721
|
+
r.result.append(line(false, `${label}: ${error.message}`), paste(item, "Run or add this yourself:"));
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
refresh();
|
|
726
|
+
if (selected().length === 0) go.textContent = "Done";
|
|
727
|
+
});
|
|
728
|
+
refresh();
|
|
729
|
+
box.append(el("div", { class: "quick-foot" }, go));
|
|
730
|
+
return box;
|
|
731
|
+
}
|
|
732
|
+
|
|
603
733
|
// ── start ───────────────────────────────────────────────────────────────────
|
|
604
734
|
async function start() {
|
|
605
735
|
try {
|
package/studio/index.html
CHANGED
|
@@ -32,6 +32,15 @@
|
|
|
32
32
|
<label class="label" for="heading-font">Title font</label>
|
|
33
33
|
<select id="heading-font"></select>
|
|
34
34
|
|
|
35
|
+
<details class="more" id="accent-box">
|
|
36
|
+
<summary><span class="swatch" id="accent-swatch"></span>Theme colour</summary>
|
|
37
|
+
<div class="more-body">
|
|
38
|
+
<input type="color" class="color" id="accent" aria-label="Theme colour">
|
|
39
|
+
<span class="hint" id="accent-hint"></span>
|
|
40
|
+
<button type="button" class="btn small quiet" id="accent-reset">Reset</button>
|
|
41
|
+
</div>
|
|
42
|
+
</details>
|
|
43
|
+
|
|
35
44
|
<label class="label" for="format">Paper</label>
|
|
36
45
|
<div class="pair">
|
|
37
46
|
<select id="format"></select>
|
package/studio/model.mjs
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Draft shape:
|
|
7
7
|
* { look, font, heading_font, highlight, page_format, orientation, margin,
|
|
8
|
-
* header: Area, footer: Area, text_size, color }
|
|
8
|
+
* header: Area, footer: Area, text_size, color, accent }
|
|
9
|
+
* accent = "" (the page style's own colour) or "#rrggbb"; written only for
|
|
10
|
+
* page styles that have an accent
|
|
9
11
|
* font / heading_font = a preset name, "look" (whatever the page style
|
|
10
12
|
* brings) or "custom" (a hand-written font_family kept from the file)
|
|
11
13
|
* Area = { left: Slot, center: Slot, right: Slot, line: boolean, custom: boolean }
|
|
@@ -90,6 +92,7 @@ export function emptyDraft() {
|
|
|
90
92
|
footer: area(),
|
|
91
93
|
text_size: "m",
|
|
92
94
|
color: DEFAULT_COLOR,
|
|
95
|
+
accent: "",
|
|
93
96
|
};
|
|
94
97
|
}
|
|
95
98
|
|
|
@@ -106,6 +109,15 @@ export function lookMargin(look, looks = {}) {
|
|
|
106
109
|
return mm(looks[look]?.margin?.left) ?? MARGINS.normal;
|
|
107
110
|
}
|
|
108
111
|
|
|
112
|
+
const HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
113
|
+
const longHex = (c) => (c.length === 4 ? `#${[...c.slice(1)].map((x) => x + x).join("")}` : c).toLowerCase();
|
|
114
|
+
|
|
115
|
+
/** Accent colour a look brings, or null when the look has none (no colour to change). */
|
|
116
|
+
export function lookAccent(look, looks = {}) {
|
|
117
|
+
const a = looks[look]?.accent;
|
|
118
|
+
return typeof a === "string" && HEX.test(a) ? longHex(a) : null;
|
|
119
|
+
}
|
|
120
|
+
|
|
109
121
|
/** What picking a look suggests for the controls it influences. */
|
|
110
122
|
export function lookDefaults(look, looks = {}) {
|
|
111
123
|
return {
|
|
@@ -170,6 +182,9 @@ export function settingsToDraft(raw, ctx = {}) {
|
|
|
170
182
|
if (typeof raw.heading_font === "string") draft.heading_font = raw.heading_font;
|
|
171
183
|
else if (typeof raw.heading_font_family === "string" && raw.heading_font_family) draft.heading_font = "custom";
|
|
172
184
|
draft.highlight = typeof raw.highlight_style === "string" ? raw.highlight_style : defaults.highlight;
|
|
185
|
+
if (typeof raw.accent_color === "string" && HEX.test(raw.accent_color.trim())) {
|
|
186
|
+
draft.accent = longHex(raw.accent_color.trim());
|
|
187
|
+
}
|
|
173
188
|
if (typeof raw.page_format === "string") draft.page_format = raw.page_format;
|
|
174
189
|
if (raw.orientation === "landscape") draft.orientation = "landscape";
|
|
175
190
|
|
|
@@ -251,6 +266,17 @@ export function draftToSettings(draft, raw = {}, ctx = {}) {
|
|
|
251
266
|
else out[preset] = choice;
|
|
252
267
|
}
|
|
253
268
|
|
|
269
|
+
// Accent: written when the look has one and the choice differs from it. A
|
|
270
|
+
// look without an accent ignores the key, so whatever the file had stays.
|
|
271
|
+
const ownAccent = lookAccent(draft.look, looks);
|
|
272
|
+
const accent = typeof draft.accent === "string" && HEX.test(draft.accent) ? longHex(draft.accent) : "";
|
|
273
|
+
if (ownAccent) {
|
|
274
|
+
const written = typeof raw?.accent_color === "string" ? raw.accent_color.trim() : "";
|
|
275
|
+
const same = HEX.test(written) && longHex(written) === accent; // "#ABC" stays as typed
|
|
276
|
+
if (accent && accent !== ownAccent) out.accent_color = same ? raw.accent_color : accent;
|
|
277
|
+
else delete out.accent_color;
|
|
278
|
+
}
|
|
279
|
+
|
|
254
280
|
if (draft.highlight === defaults.highlight) delete out.highlight_style;
|
|
255
281
|
else out.highlight_style = draft.highlight;
|
|
256
282
|
|
package/studio/sample.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Quarterly report
|
|
3
3
|
author: Alex Morgan
|
|
4
|
+
pdf:
|
|
5
|
+
math: true
|
|
4
6
|
---
|
|
5
7
|
|
|
6
8
|
# Quarterly report
|
|
@@ -36,6 +38,16 @@ function total(rows) {
|
|
|
36
38
|
}
|
|
37
39
|
```
|
|
38
40
|
|
|
41
|
+
## A little maths
|
|
42
|
+
|
|
43
|
+
Growth over the quarter, with $r$ the monthly rate:
|
|
44
|
+
|
|
45
|
+
$$
|
|
46
|
+
\text{growth} = \frac{47\,300 - 41\,200}{41\,200} \approx 14.8\,\%
|
|
47
|
+
\qquad
|
|
48
|
+
r = \sqrt[3]{1.148} - 1 \approx 4.7\,\%
|
|
49
|
+
$$
|
|
50
|
+
|
|
39
51
|
<div style="page-break-after: always"></div>
|
|
40
52
|
|
|
41
53
|
## Next quarter
|
package/studio/style.css
CHANGED
|
@@ -101,6 +101,37 @@ h2 {
|
|
|
101
101
|
|
|
102
102
|
.label { color: var(--quiet); }
|
|
103
103
|
|
|
104
|
+
/* collapsed extra option inside .fields (theme colour) */
|
|
105
|
+
.more { grid-column: 1 / -1; margin-top: -2px; }
|
|
106
|
+
.more[hidden] { display: none; }
|
|
107
|
+
.more > summary {
|
|
108
|
+
display: inline-flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
gap: 8px;
|
|
111
|
+
color: var(--quiet);
|
|
112
|
+
cursor: pointer;
|
|
113
|
+
list-style: none;
|
|
114
|
+
}
|
|
115
|
+
.more > summary::-webkit-details-marker { display: none; }
|
|
116
|
+
.more > summary::before { content: "▸"; font-size: 0.8em; transition: transform 0.15s; }
|
|
117
|
+
.more[open] > summary::before { transform: rotate(90deg); }
|
|
118
|
+
.more > summary:hover { color: var(--text); }
|
|
119
|
+
.more .swatch {
|
|
120
|
+
width: 12px;
|
|
121
|
+
height: 12px;
|
|
122
|
+
border-radius: 3px;
|
|
123
|
+
box-shadow: 0 0 0 1px var(--rule);
|
|
124
|
+
}
|
|
125
|
+
.more-body {
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
gap: 10px;
|
|
129
|
+
margin-top: 8px;
|
|
130
|
+
padding-left: 18px;
|
|
131
|
+
}
|
|
132
|
+
.more-body .hint { margin: 0; flex: 1; }
|
|
133
|
+
.more-body .btn[hidden] { display: none; }
|
|
134
|
+
|
|
104
135
|
.row {
|
|
105
136
|
display: flex;
|
|
106
137
|
flex-wrap: wrap;
|
|
@@ -481,7 +512,8 @@ dialog .hint { margin: 0 0 6px; }
|
|
|
481
512
|
.step { margin-bottom: 12px; }
|
|
482
513
|
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
|
|
483
514
|
.step-file { font: 11.5px var(--mono); color: var(--quiet); overflow-wrap: anywhere; margin: 2px 0 5px; }
|
|
484
|
-
.step pre
|
|
515
|
+
.step pre,
|
|
516
|
+
.quick-result pre {
|
|
485
517
|
margin: 0;
|
|
486
518
|
max-height: 150px;
|
|
487
519
|
overflow: auto;
|
|
@@ -492,6 +524,48 @@ dialog .hint { margin: 0 0 6px; }
|
|
|
492
524
|
font: 12px/1.45 var(--mono);
|
|
493
525
|
}
|
|
494
526
|
.step .result { margin-top: 5px; color: var(--ok); }
|
|
527
|
+
|
|
528
|
+
/* quick setup: editors found here, one switch each */
|
|
529
|
+
.quick { margin: 14px 0 4px; }
|
|
530
|
+
.quick h3 { margin: 0 0 8px; font: 600 12px var(--ui); letter-spacing: 0.06em; text-transform: uppercase; color: var(--quiet); }
|
|
531
|
+
.quick-row {
|
|
532
|
+
display: grid; grid-template-columns: 40px auto 1fr; align-items: center; gap: 4px 12px;
|
|
533
|
+
padding: 10px 12px; margin-bottom: 8px;
|
|
534
|
+
background: var(--surface); border: 1px solid var(--rule); border-radius: 8px;
|
|
535
|
+
}
|
|
536
|
+
.quick-name { font-weight: 600; cursor: pointer; }
|
|
537
|
+
.quick-row.done .quick-name { cursor: default; }
|
|
538
|
+
.quick-what { color: var(--quiet); font-size: 13px; text-align: right; }
|
|
539
|
+
.quick-row.done .quick-what { color: var(--ok); }
|
|
540
|
+
.quick-row .tick { color: var(--ok); font-weight: 700; text-align: center; }
|
|
541
|
+
.quick-result { grid-column: 2 / -1; }
|
|
542
|
+
.quick-result:empty { display: none; }
|
|
543
|
+
.quick-result p { margin: 4px 0 0; font-size: 13px; }
|
|
544
|
+
.quick-result .ok { color: var(--ok); }
|
|
545
|
+
.quick-result .bad { color: var(--error); }
|
|
546
|
+
.quick-result .paste { margin-top: 8px; }
|
|
547
|
+
.quick-result .step-head { margin-bottom: 6px; font-size: 13px; color: var(--quiet); overflow-wrap: anywhere; }
|
|
548
|
+
.quick-foot { display: flex; justify-content: flex-end; margin-top: 4px; }
|
|
549
|
+
|
|
550
|
+
.switch {
|
|
551
|
+
appearance: none; position: relative; margin: 0;
|
|
552
|
+
width: 34px; height: 20px; border-radius: 999px; cursor: pointer;
|
|
553
|
+
background: var(--rule); transition: background 0.15s;
|
|
554
|
+
}
|
|
555
|
+
.switch::before {
|
|
556
|
+
content: ""; position: absolute; top: 3px; left: 3px;
|
|
557
|
+
width: 14px; height: 14px; border-radius: 50%;
|
|
558
|
+
background: var(--text); transition: transform 0.15s;
|
|
559
|
+
}
|
|
560
|
+
.switch:checked { background: var(--ok); }
|
|
561
|
+
.switch:checked::before { transform: translateX(14px); background: var(--accent-ink); }
|
|
562
|
+
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
563
|
+
.switch:disabled { opacity: 0.5; cursor: default; }
|
|
564
|
+
|
|
565
|
+
details.manual { margin-top: 18px; border-top: 1px solid var(--rule); padding-top: 12px; }
|
|
566
|
+
details.manual > summary { cursor: pointer; font-weight: 600; color: var(--quiet); }
|
|
567
|
+
details.manual > summary:hover { color: var(--text); }
|
|
568
|
+
details.manual[open] > summary { margin-bottom: 4px; }
|
|
495
569
|
.step .result.bad { color: var(--error); }
|
|
496
570
|
|
|
497
571
|
/* ── small screens: form first, preview below ───────────────────────────── */
|
|
@@ -506,4 +580,5 @@ dialog .hint { margin: 0 0 6px; }
|
|
|
506
580
|
|
|
507
581
|
@media (prefers-reduced-motion: reduce) {
|
|
508
582
|
.status.busy::before { animation: none; }
|
|
583
|
+
.switch, .switch::before { transition: none; }
|
|
509
584
|
}
|
package/tool-schemas.mjs
CHANGED
|
@@ -183,6 +183,12 @@ export const EXPORT_INPUT_SCHEMA = {
|
|
|
183
183
|
description:
|
|
184
184
|
"CSS font-family value for headings (h1-h6). Default: same as the body text.",
|
|
185
185
|
},
|
|
186
|
+
accent_color: {
|
|
187
|
+
type: "string",
|
|
188
|
+
pattern: "^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$",
|
|
189
|
+
description:
|
|
190
|
+
"Accent colour of the page style, as #rgb or #rrggbb: title rules, coloured titles, code block bars. Used by the report and technical looks; the others have no accent.",
|
|
191
|
+
},
|
|
186
192
|
},
|
|
187
193
|
};
|
|
188
194
|
|