markdown-pdf-export 0.0.0-stage → 2.0.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 +21 -0
- package/README.md +91 -2
- package/cli.mjs +695 -0
- package/default.css +230 -0
- package/export.mjs +1369 -0
- package/lib/asset-resolver.mjs +493 -0
- package/lib/config-merger.mjs +488 -0
- package/lib/doctor-report.mjs +52 -0
- package/lib/editor-setup.mjs +280 -0
- package/lib/frontmatter-parser.mjs +595 -0
- package/lib/html-generator.mjs +837 -0
- package/lib/looks.mjs +150 -0
- package/lib/placeholder-resolver.mjs +490 -0
- package/lib/schema-validator.mjs +725 -0
- package/lib/settings-loader.mjs +167 -0
- package/lib/settings-schema.mjs +192 -0
- package/lib/studio-server.mjs +490 -0
- package/lib/types.mjs +334 -0
- package/looks/academic.css +8 -0
- package/looks/compact.css +5 -0
- package/looks/report.css +8 -0
- package/looks/technical.css +11 -0
- package/mcp.mjs +263 -0
- package/package.json +97 -4
- package/schema/settings.schema.json +768 -0
- package/studio/app.mjs +589 -0
- package/studio/index.html +113 -0
- package/studio/model.mjs +316 -0
- package/studio/sample.md +53 -0
- package/studio/style.css +497 -0
- package/templates/academic.json +26 -0
- package/templates/corporate.json +24 -0
- package/templates/minimal.json +6 -0
- package/templates/simple.json +12 -0
- package/templates/two-logo.json +27 -0
- package/tool-schemas.mjs +215 -0
- package/vendor/katex-inline.css +1 -0
package/tool-schemas.mjs
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-schema definitions shared by the MCP server (tools/list) and the CLI
|
|
3
|
+
* (option parsing / --help). Single source of truth for the export options.
|
|
4
|
+
*/
|
|
5
|
+
import { HIGHLIGHT_STYLES, ALLOWED_PAGE_FORMATS } from "./export.mjs";
|
|
6
|
+
|
|
7
|
+
export const EXPORT_INPUT_SCHEMA = {
|
|
8
|
+
type: "object",
|
|
9
|
+
additionalProperties: false,
|
|
10
|
+
required: ["input_path"],
|
|
11
|
+
properties: {
|
|
12
|
+
input_path: {
|
|
13
|
+
type: "string",
|
|
14
|
+
description:
|
|
15
|
+
"Absolute or relative path to the Markdown file.",
|
|
16
|
+
},
|
|
17
|
+
output_path: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "Optional output PDF path.",
|
|
20
|
+
},
|
|
21
|
+
stylesheet_path: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description:
|
|
24
|
+
"Optional CSS file applied after the built-in stylesheet.",
|
|
25
|
+
},
|
|
26
|
+
open_after_export: {
|
|
27
|
+
type: "boolean",
|
|
28
|
+
description: "Open the PDF after export.",
|
|
29
|
+
},
|
|
30
|
+
page_format: {
|
|
31
|
+
type: "string",
|
|
32
|
+
enum: [...ALLOWED_PAGE_FORMATS],
|
|
33
|
+
description: "Paper format.",
|
|
34
|
+
},
|
|
35
|
+
print_background: {
|
|
36
|
+
type: "boolean",
|
|
37
|
+
description:
|
|
38
|
+
"Whether to print background colours and images.",
|
|
39
|
+
},
|
|
40
|
+
margin: {
|
|
41
|
+
type: "object",
|
|
42
|
+
description:
|
|
43
|
+
"Optional per-call page margins. Any omitted side falls back to settings/defaults.",
|
|
44
|
+
additionalProperties: false,
|
|
45
|
+
properties: {
|
|
46
|
+
top: {
|
|
47
|
+
type: "string",
|
|
48
|
+
description: "Top margin, for example '10mm' or '0.5in'.",
|
|
49
|
+
},
|
|
50
|
+
right: {
|
|
51
|
+
type: "string",
|
|
52
|
+
description:
|
|
53
|
+
"Right margin, for example '10mm' or '0.5in'.",
|
|
54
|
+
},
|
|
55
|
+
bottom: {
|
|
56
|
+
type: "string",
|
|
57
|
+
description:
|
|
58
|
+
"Bottom margin, for example '10mm' or '0.5in'.",
|
|
59
|
+
},
|
|
60
|
+
left: {
|
|
61
|
+
type: "string",
|
|
62
|
+
description:
|
|
63
|
+
"Left margin, for example '10mm' or '0.5in'.",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
orientation: {
|
|
68
|
+
type: "string",
|
|
69
|
+
enum: ["portrait", "landscape"],
|
|
70
|
+
description: "Paper orientation.",
|
|
71
|
+
},
|
|
72
|
+
scale: {
|
|
73
|
+
type: "number",
|
|
74
|
+
description: "Scale of the page rendering (default 1).",
|
|
75
|
+
},
|
|
76
|
+
page_ranges: {
|
|
77
|
+
type: "string",
|
|
78
|
+
description:
|
|
79
|
+
"Paper ranges to print, e.g. '1-5, 8, 11-13'. Empty means all pages.",
|
|
80
|
+
},
|
|
81
|
+
include_default_styles: {
|
|
82
|
+
type: "boolean",
|
|
83
|
+
description: "Include the built-in default CSS stylesheet.",
|
|
84
|
+
},
|
|
85
|
+
highlight: {
|
|
86
|
+
type: "boolean",
|
|
87
|
+
description: "Enable syntax highlighting for code blocks.",
|
|
88
|
+
},
|
|
89
|
+
highlight_style: {
|
|
90
|
+
type: "string",
|
|
91
|
+
enum: [...HIGHLIGHT_STYLES].sort(),
|
|
92
|
+
description:
|
|
93
|
+
"Highlight.js style filename to use (e.g. 'github.css', 'monokai.css').",
|
|
94
|
+
},
|
|
95
|
+
breaks: {
|
|
96
|
+
type: "boolean",
|
|
97
|
+
description:
|
|
98
|
+
"Enable hard line breaks in the Markdown renderer.",
|
|
99
|
+
},
|
|
100
|
+
emoji: {
|
|
101
|
+
type: "boolean",
|
|
102
|
+
description:
|
|
103
|
+
"Render :emoji: shortcodes as Unicode characters.",
|
|
104
|
+
},
|
|
105
|
+
math: {
|
|
106
|
+
type: "boolean",
|
|
107
|
+
description:
|
|
108
|
+
"Render LaTeX math via KaTeX. Use $inline$ and $$display$$ syntax.",
|
|
109
|
+
},
|
|
110
|
+
math_options: {
|
|
111
|
+
type: "object",
|
|
112
|
+
additionalProperties: false,
|
|
113
|
+
description: "KaTeX rendering options.",
|
|
114
|
+
properties: {
|
|
115
|
+
throw_on_error: {
|
|
116
|
+
type: "boolean",
|
|
117
|
+
description:
|
|
118
|
+
"If true, abort rendering on a LaTeX error. Default false (renders error inline).",
|
|
119
|
+
},
|
|
120
|
+
error_color: {
|
|
121
|
+
type: "string",
|
|
122
|
+
description: "CSS color used for inline error messages.",
|
|
123
|
+
},
|
|
124
|
+
macros: {
|
|
125
|
+
type: "object",
|
|
126
|
+
additionalProperties: { type: "string" },
|
|
127
|
+
description:
|
|
128
|
+
'User-defined LaTeX macros, e.g. {"\\\\RR": "\\\\mathbb{R}"}.',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
heading_anchors: {
|
|
133
|
+
type: "boolean",
|
|
134
|
+
description:
|
|
135
|
+
"Add id slugs to headings (required infrastructure for TOC links).",
|
|
136
|
+
},
|
|
137
|
+
toc: {
|
|
138
|
+
type: "boolean",
|
|
139
|
+
description:
|
|
140
|
+
"Render a [[toc]] marker as an auto-generated table of contents (also enables heading anchors).",
|
|
141
|
+
},
|
|
142
|
+
toc_options: {
|
|
143
|
+
type: "object",
|
|
144
|
+
additionalProperties: false,
|
|
145
|
+
description: "Table-of-contents rendering options.",
|
|
146
|
+
properties: {
|
|
147
|
+
level: {
|
|
148
|
+
type: "array",
|
|
149
|
+
items: { type: "number" },
|
|
150
|
+
description: "Heading levels to include, e.g. [1, 2, 3].",
|
|
151
|
+
},
|
|
152
|
+
list_type: {
|
|
153
|
+
type: "string",
|
|
154
|
+
enum: ["ul", "ol"],
|
|
155
|
+
description: "List type for the TOC.",
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
display_header_footer: {
|
|
160
|
+
type: "boolean",
|
|
161
|
+
default: false,
|
|
162
|
+
description:
|
|
163
|
+
"Display header and footer on each page. Content comes from `header` / `footer` (here, in settings or in front matter); without them the header and footer are empty. Enabled automatically when `header` or `footer` is given.",
|
|
164
|
+
},
|
|
165
|
+
header: {
|
|
166
|
+
type: "object",
|
|
167
|
+
description:
|
|
168
|
+
"Structured page header as JSON. Shorthand keys: left_text, center_text, right_text, left_image, height. Placeholders: {title}, {date}, {page}, {pages}, {filename}, {author}. Example: {\"center_text\":\"{title}\",\"right_text\":\"{date}\"}. Replaces the header from settings; front matter still overrides it.",
|
|
169
|
+
},
|
|
170
|
+
footer: {
|
|
171
|
+
type: "object",
|
|
172
|
+
description:
|
|
173
|
+
"Structured page footer as JSON, same shape as `header`. Example for page numbers: {\"center_text\":\"Page {page} of {pages}\"}. Replaces the footer from settings; front matter still overrides it.",
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
font_family: {
|
|
177
|
+
type: "string",
|
|
178
|
+
description:
|
|
179
|
+
"CSS font-family value for the document body and header/footer. Overrides the default system font stack. Example: \"Georgia, 'Times New Roman', serif\".",
|
|
180
|
+
},
|
|
181
|
+
heading_font_family: {
|
|
182
|
+
type: "string",
|
|
183
|
+
description:
|
|
184
|
+
"CSS font-family value for headings (h1-h6). Default: same as the body text.",
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export const DOCTOR_INPUT_SCHEMA = {
|
|
190
|
+
type: "object",
|
|
191
|
+
additionalProperties: false,
|
|
192
|
+
properties: {
|
|
193
|
+
input_path: {
|
|
194
|
+
type: "string",
|
|
195
|
+
description: "Optional Markdown file used to resolve relative settings.",
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export const TOOLS = [
|
|
201
|
+
{
|
|
202
|
+
name: "export_markdown_pdf",
|
|
203
|
+
title: "Export Markdown PDF",
|
|
204
|
+
description:
|
|
205
|
+
"Render a Markdown file to HTML and convert it to PDF with Playwright/Chromium.",
|
|
206
|
+
inputSchema: EXPORT_INPUT_SCHEMA,
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: "doctor_markdown_pdf",
|
|
210
|
+
title: "Doctor Markdown PDF",
|
|
211
|
+
description:
|
|
212
|
+
"Inspect browser setup and current settings.",
|
|
213
|
+
inputSchema: DOCTOR_INPUT_SCHEMA,
|
|
214
|
+
},
|
|
215
|
+
];
|