mark-deco-cli 0.15.0 → 0.17.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/dist/index.cjs +234 -0
- package/dist/index.cjs.map +1 -0
- package/package.json +12 -12
- package/dist/cli.cjs +0 -33643
- package/dist/cli.cjs.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* name: mark-deco-cli
|
|
5
|
+
* version: 0.17.0
|
|
6
|
+
* description: Command-line interface for mark-deco Markdown to HTML conversion processor
|
|
7
|
+
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
8
|
+
* license: MIT
|
|
9
|
+
* repository.url: https://github.com/kekyo/mark-deco
|
|
10
|
+
* git.commit.hash: 50ed26c3accc15bee0957672d131f1a905d82351
|
|
11
|
+
*/
|
|
12
|
+
const commander = require("commander");
|
|
13
|
+
const promises = require("fs/promises");
|
|
14
|
+
const path = require("path");
|
|
15
|
+
const process$1 = require("process");
|
|
16
|
+
const markDeco = require("mark-deco");
|
|
17
|
+
const name = "mark-deco-cli";
|
|
18
|
+
const version = "0.17.0";
|
|
19
|
+
const description = "Command-line interface for mark-deco Markdown to HTML conversion processor";
|
|
20
|
+
const author = "Kouji Matsui (@kekyo@mi.kekyo.net)";
|
|
21
|
+
const repository_url = "https://github.com/kekyo/mark-deco";
|
|
22
|
+
const git_commit_hash = "50ed26c3accc15bee0957672d131f1a905d82351";
|
|
23
|
+
const loadConfig = async (configPath) => {
|
|
24
|
+
if (!configPath) {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const configFile = path.resolve(configPath);
|
|
29
|
+
const configContent = await promises.readFile(configFile, "utf-8");
|
|
30
|
+
if (configPath.endsWith(".json")) {
|
|
31
|
+
return JSON.parse(configContent);
|
|
32
|
+
} else if (configPath.endsWith(".js") || configPath.endsWith(".cjs") || configPath.endsWith(".mjs")) {
|
|
33
|
+
const configModule = await import(configFile);
|
|
34
|
+
return configModule.default || configModule;
|
|
35
|
+
} else {
|
|
36
|
+
return JSON.parse(configContent);
|
|
37
|
+
}
|
|
38
|
+
} catch (error) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`Failed to load config file "${configPath}": ${error instanceof Error ? error.message : String(error)}`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const readInput = async (inputPath) => {
|
|
45
|
+
if (inputPath) {
|
|
46
|
+
try {
|
|
47
|
+
return await promises.readFile(inputPath, "utf-8");
|
|
48
|
+
} catch (error) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Failed to read input file "${inputPath}": ${error instanceof Error ? error.message : String(error)}`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
let data = "";
|
|
56
|
+
if (process$1.stdin.isTTY) {
|
|
57
|
+
reject(
|
|
58
|
+
new Error(
|
|
59
|
+
"No input file specified and stdin is not available. Use -i option to specify input file."
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
process$1.stdin.setEncoding("utf-8");
|
|
65
|
+
process$1.stdin.on("data", (chunk) => {
|
|
66
|
+
data += chunk;
|
|
67
|
+
});
|
|
68
|
+
process$1.stdin.on("end", () => {
|
|
69
|
+
resolve(data);
|
|
70
|
+
});
|
|
71
|
+
process$1.stdin.on("error", (error) => {
|
|
72
|
+
reject(new Error(`Failed to read from stdin: ${error.message}`));
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const writeOutput = async (html, outputPath) => {
|
|
78
|
+
if (outputPath) {
|
|
79
|
+
try {
|
|
80
|
+
await promises.writeFile(outputPath, html, "utf-8");
|
|
81
|
+
} catch (error) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`Failed to write output file "${outputPath}": ${error instanceof Error ? error.message : String(error)}`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
try {
|
|
88
|
+
process.stdout.write(html);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`Failed to write to stdout: ${error instanceof Error ? error.message : String(error)}`
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const writeJsonOutput = async (data, outputPath) => {
|
|
97
|
+
try {
|
|
98
|
+
const jsonContent = JSON.stringify(data, null, 2);
|
|
99
|
+
await promises.writeFile(outputPath, jsonContent, "utf-8");
|
|
100
|
+
} catch (error) {
|
|
101
|
+
throw new Error(
|
|
102
|
+
`Failed to write JSON output file "${outputPath}": ${error instanceof Error ? error.message : String(error)}`
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const setupProcessor = (config) => {
|
|
107
|
+
const plugins = [];
|
|
108
|
+
const logger = markDeco.getConsoleLogger();
|
|
109
|
+
const fetcher = markDeco.createCachedFetcher(
|
|
110
|
+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.0.0 Safari/537.36",
|
|
111
|
+
5e3,
|
|
112
|
+
markDeco.createMemoryCacheStorage()
|
|
113
|
+
);
|
|
114
|
+
const enabledPlugins = config.noPlugins ? [] : Array.isArray(config.plugins) ? config.plugins : ["oembed", "card", "mermaid"];
|
|
115
|
+
if (enabledPlugins.includes("oembed") && config.oembed?.enabled !== false) {
|
|
116
|
+
plugins.push(markDeco.createOEmbedPlugin(markDeco.defaultProviderList, {}));
|
|
117
|
+
}
|
|
118
|
+
if (enabledPlugins.includes("card") && config.card?.enabled !== false) {
|
|
119
|
+
plugins.push(markDeco.createCardPlugin({}));
|
|
120
|
+
}
|
|
121
|
+
if (enabledPlugins.includes("mermaid") && config.mermaid?.enabled !== false) {
|
|
122
|
+
plugins.push(markDeco.createMermaidPlugin({}));
|
|
123
|
+
}
|
|
124
|
+
return markDeco.createMarkdownProcessor({
|
|
125
|
+
plugins,
|
|
126
|
+
logger,
|
|
127
|
+
fetcher
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
const program = new commander.Command();
|
|
131
|
+
const main = async () => {
|
|
132
|
+
program.name(name).summary(description).version(`${version}-${git_commit_hash}`);
|
|
133
|
+
program.addOption(
|
|
134
|
+
new commander.Option("-i, --input <file>", "Input markdown file (default: stdin)")
|
|
135
|
+
).addOption(
|
|
136
|
+
new commander.Option("-o, --output <file>", "Output HTML file (default: stdout)")
|
|
137
|
+
).addOption(new commander.Option("-c, --config <file>", "Configuration file path")).addOption(
|
|
138
|
+
new commander.Option(
|
|
139
|
+
"-p, --plugins [plugins...]",
|
|
140
|
+
"Enable specific plugins (oembed, card, mermaid)"
|
|
141
|
+
)
|
|
142
|
+
).addOption(new commander.Option("--no-plugins", "Disable all default plugins")).addOption(
|
|
143
|
+
new commander.Option(
|
|
144
|
+
"--unique-id-prefix <prefix>",
|
|
145
|
+
"Prefix for unique IDs"
|
|
146
|
+
).default("section")
|
|
147
|
+
).addOption(
|
|
148
|
+
new commander.Option(
|
|
149
|
+
"--hierarchical-heading-id",
|
|
150
|
+
"Use hierarchical heading IDs"
|
|
151
|
+
).default(true)
|
|
152
|
+
).addOption(
|
|
153
|
+
new commander.Option(
|
|
154
|
+
"--content-based-heading-id",
|
|
155
|
+
"Use content-based heading IDs"
|
|
156
|
+
).default(false)
|
|
157
|
+
).addOption(
|
|
158
|
+
new commander.Option(
|
|
159
|
+
"--heading-base-level <level>",
|
|
160
|
+
"Base heading level for markdown headings"
|
|
161
|
+
).argParser((value) => Number.parseInt(value, 10)).default(1)
|
|
162
|
+
).addOption(
|
|
163
|
+
new commander.Option(
|
|
164
|
+
"--header-title-transform <mode>",
|
|
165
|
+
"Control how the first base-level heading is applied to frontmatter.title (extract, extractAndRemove, none)"
|
|
166
|
+
).choices(["extract", "extractAndRemove", "none"])
|
|
167
|
+
).addOption(
|
|
168
|
+
new commander.Option(
|
|
169
|
+
"--frontmatter-output <file>",
|
|
170
|
+
"Output frontmatter as JSON to specified file"
|
|
171
|
+
)
|
|
172
|
+
).addOption(
|
|
173
|
+
new commander.Option(
|
|
174
|
+
"--heading-tree-output <file>",
|
|
175
|
+
"Output heading tree as JSON to specified file"
|
|
176
|
+
)
|
|
177
|
+
).action(async () => {
|
|
178
|
+
const options = program.opts();
|
|
179
|
+
try {
|
|
180
|
+
const config = await loadConfig(options.config);
|
|
181
|
+
const mergedOptions = { ...config, ...options };
|
|
182
|
+
const markdown = await readInput(options.input);
|
|
183
|
+
const processor = setupProcessor(mergedOptions);
|
|
184
|
+
const headerTitleTransform = options.headerTitleTransform ?? config.headerTitleTransform ?? "extractAndRemove";
|
|
185
|
+
const headingBaseLevel = options.headingBaseLevel ?? config.headingBaseLevel ?? 1;
|
|
186
|
+
const result = await processor.process(
|
|
187
|
+
markdown,
|
|
188
|
+
options.uniqueIdPrefix || "section",
|
|
189
|
+
{
|
|
190
|
+
useHierarchicalHeadingId: options.hierarchicalHeadingId ?? true,
|
|
191
|
+
useContentStringHeaderId: options.contentBasedHeadingId ?? false,
|
|
192
|
+
headingBaseLevel,
|
|
193
|
+
headerTitleTransform
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
await writeOutput(result.html, options.output);
|
|
197
|
+
if (options.frontmatterOutput) {
|
|
198
|
+
await writeJsonOutput(result.frontmatter, options.frontmatterOutput);
|
|
199
|
+
}
|
|
200
|
+
if (options.headingTreeOutput) {
|
|
201
|
+
await writeJsonOutput(result.headingTree, options.headingTreeOutput);
|
|
202
|
+
}
|
|
203
|
+
} catch (error) {
|
|
204
|
+
console.error(
|
|
205
|
+
"Error:",
|
|
206
|
+
error instanceof Error ? error.message : String(error)
|
|
207
|
+
);
|
|
208
|
+
process.exit(1);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
process.on("unhandledRejection", (reason, promise) => {
|
|
212
|
+
console.error("Unhandled Rejection at:", promise, "reason:", reason);
|
|
213
|
+
process.exit(1);
|
|
214
|
+
});
|
|
215
|
+
process.on("uncaughtException", (error) => {
|
|
216
|
+
console.error("Uncaught Exception:", error);
|
|
217
|
+
process.exit(1);
|
|
218
|
+
});
|
|
219
|
+
const userArgs = process.argv.slice(2);
|
|
220
|
+
if (userArgs.length === 0 || userArgs.includes("--help") || userArgs.includes("-h")) {
|
|
221
|
+
console.log(`${name} [${version}-${git_commit_hash}]`);
|
|
222
|
+
console.log(description);
|
|
223
|
+
console.log(`Copyright (c) ${author}`);
|
|
224
|
+
console.log(repository_url);
|
|
225
|
+
console.log("License: Under MIT");
|
|
226
|
+
console.log("");
|
|
227
|
+
}
|
|
228
|
+
program.parse();
|
|
229
|
+
};
|
|
230
|
+
main().catch((error) => {
|
|
231
|
+
console.error("Failed to start CLI:", error);
|
|
232
|
+
process.exit(1);
|
|
233
|
+
});
|
|
234
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/generated/packageMetadata.ts","../src/config.ts","../src/io.ts","../src/processor.ts","../src/index.ts"],"sourcesContent":["// @ts-nocheck\n// This file is auto-generated by screw-up plugin\n// Do not edit manually\n\nexport const name = \"mark-deco-cli\";\nexport const version = \"0.17.0\";\nexport const description = \"Command-line interface for mark-deco Markdown to HTML conversion processor\";\nexport const author = \"Kouji Matsui (@kekyo@mi.kekyo.net)\";\nexport const license = \"MIT\";\nexport const repository_url = \"https://github.com/kekyo/mark-deco\";\nexport const git_commit_hash = \"50ed26c3accc15bee0957672d131f1a905d82351\";\n","// mark-deco - Flexible Markdown to HTML conversion library\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/mark-deco\n\nimport { readFile } from 'fs/promises';\nimport { resolve } from 'path';\n\nexport interface Config {\n plugins?: string[];\n noPlugins?: boolean;\n uniqueIdPrefix?: string;\n hierarchicalHeadingId?: boolean;\n contentBasedHeadingId?: boolean;\n headingBaseLevel?: number;\n headerTitleTransform?: 'extract' | 'extractAndRemove' | 'none';\n // Plugin-specific configurations\n oembed?: {\n enabled?: boolean;\n };\n card?: {\n enabled?: boolean;\n };\n mermaid?: {\n enabled?: boolean;\n };\n}\n\n/**\n * Load configuration from file\n */\nexport const loadConfig = async (configPath?: string): Promise<Config> => {\n if (!configPath) {\n return {};\n }\n\n try {\n const configFile = resolve(configPath);\n const configContent = await readFile(configFile, 'utf-8');\n\n // Support both JSON and JS config files\n if (configPath.endsWith('.json')) {\n return JSON.parse(configContent);\n } else if (\n configPath.endsWith('.js') ||\n configPath.endsWith('.cjs') ||\n configPath.endsWith('.mjs')\n ) {\n // For JS/MJS files, we need to use dynamic import\n const configModule = await import(configFile);\n return configModule.default || configModule;\n } else {\n // Default to JSON parsing\n return JSON.parse(configContent);\n }\n } catch (error) {\n throw new Error(\n `Failed to load config file \"${configPath}\": ${error instanceof Error ? error.message : String(error)}`\n );\n }\n};\n\n/**\n * Get default configuration\n */\nexport const getDefaultConfig = (): Config => {\n return {\n plugins: ['oembed', 'card', 'mermaid'],\n uniqueIdPrefix: 'section',\n hierarchicalHeadingId: true,\n contentBasedHeadingId: false,\n headingBaseLevel: 1,\n headerTitleTransform: 'extractAndRemove',\n oembed: {\n enabled: true,\n },\n card: {\n enabled: true,\n },\n mermaid: {\n enabled: true,\n },\n };\n};\n","// mark-deco - Flexible Markdown to HTML conversion library\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/mark-deco\n\nimport { readFile, writeFile } from 'fs/promises';\nimport { stdin } from 'process';\n\n/**\n * Read input from file or stdin\n */\nexport const readInput = async (inputPath?: string): Promise<string> => {\n if (inputPath) {\n // Read from file\n try {\n return await readFile(inputPath, 'utf-8');\n } catch (error) {\n throw new Error(\n `Failed to read input file \"${inputPath}\": ${error instanceof Error ? error.message : String(error)}`\n );\n }\n } else {\n // Read from stdin\n return new Promise((resolve, reject) => {\n let data = '';\n\n // Check if stdin is a TTY (interactive mode)\n if (stdin.isTTY) {\n reject(\n new Error(\n 'No input file specified and stdin is not available. Use -i option to specify input file.'\n )\n );\n return;\n }\n\n stdin.setEncoding('utf-8');\n\n stdin.on('data', (chunk) => {\n data += chunk;\n });\n\n stdin.on('end', () => {\n resolve(data);\n });\n\n stdin.on('error', (error) => {\n reject(new Error(`Failed to read from stdin: ${error.message}`));\n });\n });\n }\n};\n\n/**\n * Write output to file or stdout\n */\nexport const writeOutput = async (\n html: string,\n outputPath?: string\n): Promise<void> => {\n if (outputPath) {\n // Write to file\n try {\n await writeFile(outputPath, html, 'utf-8');\n } catch (error) {\n throw new Error(\n `Failed to write output file \"${outputPath}\": ${error instanceof Error ? error.message : String(error)}`\n );\n }\n } else {\n // Write to stdout\n try {\n process.stdout.write(html);\n } catch (error) {\n throw new Error(\n `Failed to write to stdout: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n }\n};\n\n/**\n * Write JSON output to file\n */\nexport const writeJsonOutput = async (\n data: unknown,\n outputPath: string\n): Promise<void> => {\n try {\n const jsonContent = JSON.stringify(data, null, 2);\n await writeFile(outputPath, jsonContent, 'utf-8');\n } catch (error) {\n throw new Error(\n `Failed to write JSON output file \"${outputPath}\": ${error instanceof Error ? error.message : String(error)}`\n );\n }\n};\n","// mark-deco - Flexible Markdown to HTML conversion library\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/mark-deco\n\nimport {\n createMarkdownProcessor,\n createOEmbedPlugin,\n createCardPlugin,\n createMermaidPlugin,\n createCachedFetcher,\n createMemoryCacheStorage,\n getConsoleLogger,\n defaultProviderList,\n} from 'mark-deco';\nimport type { Config } from './config';\n\n// Import the MarkdownProcessor type - this should be available from mark-deco package\ntype MarkdownProcessor = ReturnType<typeof createMarkdownProcessor>;\n\n/**\n * Setup markdown processor with plugins based on configuration\n */\nexport const setupProcessor = (config: Config): MarkdownProcessor => {\n const plugins = [];\n const logger = getConsoleLogger();\n const fetcher = createCachedFetcher(\n 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.0.0 Safari/537.36',\n 5000,\n createMemoryCacheStorage()\n );\n\n // Determine which plugins to enable\n const enabledPlugins = config.noPlugins\n ? []\n : Array.isArray(config.plugins)\n ? config.plugins\n : ['oembed', 'card', 'mermaid'];\n\n // Add oEmbed plugin\n if (enabledPlugins.includes('oembed') && config.oembed?.enabled !== false) {\n plugins.push(createOEmbedPlugin(defaultProviderList, {}));\n }\n\n // Add card plugin\n if (enabledPlugins.includes('card') && config.card?.enabled !== false) {\n plugins.push(createCardPlugin({}));\n }\n\n // Add Mermaid plugin\n if (enabledPlugins.includes('mermaid') && config.mermaid?.enabled !== false) {\n plugins.push(createMermaidPlugin({}));\n }\n\n // Create and return processor\n return createMarkdownProcessor({\n plugins,\n logger,\n fetcher,\n });\n};\n","// mark-deco - Flexible Markdown to HTML conversion library\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/mark-deco\n\nimport { Command, Option } from 'commander';\nimport type { HeaderTitleTransform } from 'mark-deco';\n\nimport {\n author,\n description,\n git_commit_hash,\n name,\n repository_url,\n version,\n} from './generated/packageMetadata';\nimport { loadConfig } from './config';\nimport { readInput, writeOutput, writeJsonOutput } from './io';\nimport { setupProcessor } from './processor';\n\ninterface CLIOptions {\n input?: string;\n config?: string;\n output?: string;\n plugins?: string[];\n noPlugins?: boolean;\n uniqueIdPrefix?: string;\n hierarchicalHeadingId?: boolean;\n contentBasedHeadingId?: boolean;\n headingBaseLevel?: number;\n headerTitleTransform?: HeaderTitleTransform;\n frontmatterOutput?: string;\n headingTreeOutput?: string;\n}\n\nconst program = new Command();\n\nconst main = async () => {\n program\n .name(name)\n .summary(description)\n .version(`${version}-${git_commit_hash}`);\n\n program\n .addOption(\n new Option('-i, --input <file>', 'Input markdown file (default: stdin)')\n )\n .addOption(\n new Option('-o, --output <file>', 'Output HTML file (default: stdout)')\n )\n .addOption(new Option('-c, --config <file>', 'Configuration file path'))\n .addOption(\n new Option(\n '-p, --plugins [plugins...]',\n 'Enable specific plugins (oembed, card, mermaid)'\n )\n )\n .addOption(new Option('--no-plugins', 'Disable all default plugins'))\n .addOption(\n new Option(\n '--unique-id-prefix <prefix>',\n 'Prefix for unique IDs'\n ).default('section')\n )\n .addOption(\n new Option(\n '--hierarchical-heading-id',\n 'Use hierarchical heading IDs'\n ).default(true)\n )\n .addOption(\n new Option(\n '--content-based-heading-id',\n 'Use content-based heading IDs'\n ).default(false)\n )\n .addOption(\n new Option(\n '--heading-base-level <level>',\n 'Base heading level for markdown headings'\n )\n .argParser((value) => Number.parseInt(value, 10))\n .default(1)\n )\n .addOption(\n new Option(\n '--header-title-transform <mode>',\n 'Control how the first base-level heading is applied to frontmatter.title (extract, extractAndRemove, none)'\n ).choices(['extract', 'extractAndRemove', 'none'])\n )\n .addOption(\n new Option(\n '--frontmatter-output <file>',\n 'Output frontmatter as JSON to specified file'\n )\n )\n .addOption(\n new Option(\n '--heading-tree-output <file>',\n 'Output heading tree as JSON to specified file'\n )\n )\n .action(async () => {\n const options = program.opts<CLIOptions>();\n try {\n // Load configuration\n const config = await loadConfig(options.config);\n\n // Merge CLI options with config\n const mergedOptions = { ...config, ...options };\n\n // Read input\n const markdown = await readInput(options.input);\n\n // Setup processor with plugins\n const processor = setupProcessor(mergedOptions);\n\n // Process markdown\n const headerTitleTransform: HeaderTitleTransform =\n options.headerTitleTransform ??\n config.headerTitleTransform ??\n 'extractAndRemove';\n const headingBaseLevel =\n options.headingBaseLevel ?? config.headingBaseLevel ?? 1;\n\n const result = await processor.process(\n markdown,\n options.uniqueIdPrefix || 'section',\n {\n useHierarchicalHeadingId: options.hierarchicalHeadingId ?? true,\n useContentStringHeaderId: options.contentBasedHeadingId ?? false,\n headingBaseLevel,\n headerTitleTransform,\n }\n );\n\n // Write output\n await writeOutput(result.html, options.output);\n\n // Write frontmatter if output path is specified\n if (options.frontmatterOutput) {\n await writeJsonOutput(result.frontmatter, options.frontmatterOutput);\n }\n\n // Write heading tree if output path is specified\n if (options.headingTreeOutput) {\n await writeJsonOutput(result.headingTree, options.headingTreeOutput);\n }\n } catch (error) {\n console.error(\n 'Error:',\n error instanceof Error ? error.message : String(error)\n );\n process.exit(1);\n }\n });\n\n // Handle unhandled errors\n process.on('unhandledRejection', (reason, promise) => {\n console.error('Unhandled Rejection at:', promise, 'reason:', reason);\n process.exit(1);\n });\n\n process.on('uncaughtException', (error) => {\n console.error('Uncaught Exception:', error);\n process.exit(1);\n });\n\n // Parse command line arguments\n const userArgs = process.argv.slice(2);\n if (\n userArgs.length === 0 ||\n userArgs.includes('--help') ||\n userArgs.includes('-h')\n ) {\n console.log(`${name} [${version}-${git_commit_hash}]`);\n console.log(description);\n console.log(`Copyright (c) ${author}`);\n console.log(repository_url);\n console.log('License: Under MIT');\n console.log('');\n }\n program.parse();\n};\n\n// Run the main function\nmain().catch((error) => {\n console.error('Failed to start CLI:', error);\n process.exit(1);\n});\n"],"names":["resolve","readFile","stdin","writeFile","getConsoleLogger","createCachedFetcher","createMemoryCacheStorage","createOEmbedPlugin","defaultProviderList","createCardPlugin","createMermaidPlugin","createMarkdownProcessor","Command","Option"],"mappings":";;;;;;;;;;;;;;;;AAIO,MAAM,OAAO;AACb,MAAM,UAAU;AAChB,MAAM,cAAc;AACpB,MAAM,SAAS;AAEf,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;ACqBxB,MAAM,aAAa,OAAO,eAAyC;AACxE,MAAI,CAAC,YAAY;AACf,WAAO,CAAA;AAAA,EACT;AAEA,MAAI;AACF,UAAM,aAAaA,KAAAA,QAAQ,UAAU;AACrC,UAAM,gBAAgB,MAAMC,kBAAS,YAAY,OAAO;AAGxD,QAAI,WAAW,SAAS,OA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qB,CAAC,UAAU;AACzC,YAAQ,MAAM,uBAAuB,KAAK;AAC1C,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AAGD,QAAM,WAAW,QAAQ,KAAK,MAAM,CAAC;AACrC,MACE,SAAS,WAAW,KACpB,SAAS,SAAS,QAAQ,KAC1B,SAAS,SAAS,IAAI,GACtB;AACA,YAAQ,IAAI,GAAG,IAAI,KAAK,OAAO,IAAI,eAAe,GAAG;AACrD,YAAQ,IAAI,WAAW;AACvB,YAAQ,IAAI,iBAAiB,MAAM,EAAE;AACrC,YAAQ,IAAI,cAAc;AAC1B,YAAQ,IAAI,oBAAoB;AAChC,YAAQ,IAAI,EAAE;AAAA,EAChB;AACA,UAAQ,MAAA;AACV;AAGA,OAAO,MAAM,CAAC,UAAU;AACtB,UAAQ,MAAM,wBAAwB,KAAK;AAC3C,UAAQ,KAAK,CAAC;AAChB,CAAC;"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"git": {
|
|
3
3
|
"tags": [
|
|
4
|
-
"0.
|
|
4
|
+
"0.17.0"
|
|
5
5
|
],
|
|
6
6
|
"branches": [
|
|
7
7
|
"main"
|
|
8
8
|
],
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.17.0",
|
|
10
10
|
"commit": {
|
|
11
|
-
"hash": "
|
|
12
|
-
"shortHash": "
|
|
13
|
-
"date": "2026-01-
|
|
11
|
+
"hash": "50ed26c3accc15bee0957672d131f1a905d82351",
|
|
12
|
+
"shortHash": "50ed26c",
|
|
13
|
+
"date": "2026-01-16T19:20:52+09:00",
|
|
14
14
|
"message": "Merge branch 'develop'"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"version": "0.
|
|
17
|
+
"version": "0.17.0",
|
|
18
18
|
"description": "Command-line interface for mark-deco Markdown to HTML conversion processor",
|
|
19
19
|
"name": "mark-deco-cli",
|
|
20
20
|
"keywords": [
|
|
@@ -29,13 +29,14 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
32
|
-
"url": "https://github.com/kekyo/mark-deco
|
|
32
|
+
"url": "https://github.com/kekyo/mark-deco"
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/kekyo/mark-deco#readme",
|
|
35
|
+
"type": "module",
|
|
35
36
|
"bin": {
|
|
36
|
-
"mark-deco
|
|
37
|
+
"mark-deco": "./dist/index.cjs"
|
|
37
38
|
},
|
|
38
|
-
"main": "./dist/
|
|
39
|
+
"main": "./dist/index.cjs",
|
|
39
40
|
"files": [
|
|
40
41
|
"dist",
|
|
41
42
|
"LICENSE"
|
|
@@ -43,7 +44,6 @@
|
|
|
43
44
|
"scripts": {
|
|
44
45
|
"dev": "npm run build",
|
|
45
46
|
"build": "vite build",
|
|
46
|
-
"build:esbuild": "esbuild src/cli.ts --bundle --platform=node --target=node18 --outfile=dist/cli-esbuild.js --format=cjs --minify",
|
|
47
47
|
"test": "npm run build && vitest run",
|
|
48
48
|
"pack": "npm run build && screw-up pack --pack-destination ../artifacts/"
|
|
49
49
|
},
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
"@types/node": ">=20.0.0",
|
|
60
60
|
"esbuild": ">=0.21.5",
|
|
61
61
|
"prettier-max": ">=1.13.0",
|
|
62
|
-
"screw-up": ">=1.
|
|
62
|
+
"screw-up": ">=1.20.0",
|
|
63
63
|
"rollup": ">=4.42.0",
|
|
64
64
|
"tslib": ">=2.8.1",
|
|
65
65
|
"typescript": ">=5.0.0",
|
|
66
66
|
"vite": ">=6.3.5",
|
|
67
67
|
"vitest": ">=1.0.0"
|
|
68
68
|
},
|
|
69
|
-
"buildDate": "2026-01-
|
|
69
|
+
"buildDate": "2026-01-16T19:24:24+09:00"
|
|
70
70
|
}
|