@markitdownjs/cli 0.1.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.
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerBatchCommand(program: Command): void;
3
+ //# sourceMappingURL=batch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/commands/batch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyE3D"}
@@ -0,0 +1,71 @@
1
+ import { readFile, writeFile, readdir, mkdir } from 'fs/promises';
2
+ import { join, extname, resolve, relative, dirname } from 'path';
3
+ import { MarkItDown } from '@markitdownjs/core';
4
+ export function registerBatchCommand(program) {
5
+ program
6
+ .command('batch')
7
+ .description('Batch convert all files in a directory')
8
+ .argument('[dir]', 'Directory to process', '.')
9
+ .option('-o, --output <dir>', 'Output directory')
10
+ .option('-e, --extensions <exts>', 'Comma-separated extensions to process', '.pdf,.docx,.xlsx,.pptx,.html,.csv,.json,.xml')
11
+ .option('-c, --concurrency <n>', 'Max concurrent conversions', '5')
12
+ .option('-v, --verbose', 'Verbose output')
13
+ .action(async (dir, options) => {
14
+ const inputDir = resolve(dir);
15
+ const outputDir = options.output ? resolve(options.output) : inputDir;
16
+ const extensions = options.extensions.split(',').map(e => e.trim());
17
+ const concurrency = parseInt(options.concurrency, 10);
18
+ const parser = new MarkItDown();
19
+ async function getFiles(dirPath) {
20
+ const entries = await readdir(dirPath, { withFileTypes: true });
21
+ const files = [];
22
+ for (const entry of entries) {
23
+ const fullPath = join(dirPath, entry.name);
24
+ if (entry.isDirectory()) {
25
+ files.push(...await getFiles(fullPath));
26
+ }
27
+ else if (entry.isFile() && extensions.includes(extname(entry.name).toLowerCase())) {
28
+ files.push(fullPath);
29
+ }
30
+ }
31
+ return files;
32
+ }
33
+ try {
34
+ const files = await getFiles(inputDir);
35
+ let converted = 0;
36
+ let failed = 0;
37
+ console.error(`Found ${files.length} files to convert`);
38
+ async function processFile(filePath) {
39
+ try {
40
+ const content = await readFile(filePath);
41
+ const result = await parser.convert({
42
+ data: new Uint8Array(content),
43
+ fileName: filePath,
44
+ });
45
+ const relPath = relative(inputDir, filePath);
46
+ const mdPath = join(outputDir, relPath.replace(extname(filePath), '.md'));
47
+ await mkdir(dirname(mdPath), { recursive: true });
48
+ await writeFile(mdPath, result.markdown, 'utf-8');
49
+ converted++;
50
+ if (options.verbose) {
51
+ console.error(`[${converted}/${files.length}] Converted: ${relPath}`);
52
+ }
53
+ }
54
+ catch (error) {
55
+ failed++;
56
+ console.error(`Failed: ${filePath} - ${error instanceof Error ? error.message : String(error)}`);
57
+ }
58
+ }
59
+ for (let i = 0; i < files.length; i += concurrency) {
60
+ const batch = files.slice(i, i + concurrency);
61
+ await Promise.all(batch.map(processFile));
62
+ }
63
+ console.error(`\nBatch complete: ${converted} converted, ${failed} failed`);
64
+ }
65
+ catch (error) {
66
+ console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
67
+ process.exit(1);
68
+ }
69
+ });
70
+ }
71
+ //# sourceMappingURL=batch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch.js","sourceRoot":"","sources":["../../src/commands/batch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,wCAAwC,CAAC;SACrD,QAAQ,C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AS,IAAI,KAAK,CAAC,MAAM,gBAAgB,OAAO,EAAE,CAAC,CAAC;oBACxE,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,EAAE,CAAC;oBACT,OAAO,CAAC,KAAK,CAAC,WAAW,QAAQ,MAAM,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBACnG,CAAC;YACH,CAAC;YAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC;gBACnD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC;gBAC9C,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;YAC5C,CAAC;YAED,OAAO,CAAC,KAAK,CAAC,qBAAqB,SAAS,eAAe,MAAM,SAAS,CAAC,CAAC;QAC9E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAClF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerConvertCommand(program: Command): void;
3
+ //# sourceMappingURL=convert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../src/commands/convert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA4D7D"}
@@ -0,0 +1,62 @@
1
+ import { readFile, writeFile, mkdir } from 'fs/promises';
2
+ import { dirname } from 'path';
3
+ import { MarkItDown } from '@markitdownjs/core';
4
+ export function registerConvertCommand(program) {
5
+ program
6
+ .command('convert')
7
+ .description('Convert a document to Markdown')
8
+ .argument('<file>', 'File to convert')
9
+ .option('-o, --output <path>', 'Output file path')
10
+ .option('-f, --format <format>', 'Output format (markdown, json, plaintext, html)', 'markdown')
11
+ .option('-v, --verbose', 'Verbose output')
12
+ .action(async (file, options) => {
13
+ try {
14
+ if (options.verbose) {
15
+ console.error(`Converting: ${file}`);
16
+ }
17
+ const fileBuffer = await readFile(file);
18
+ const parser = new MarkItDown();
19
+ const result = await parser.convert({
20
+ data: new Uint8Array(fileBuffer),
21
+ fileName: file,
22
+ options: {
23
+ outputFormat: options.format,
24
+ },
25
+ });
26
+ let output;
27
+ switch (options.format) {
28
+ case 'json':
29
+ output = JSON.stringify(result, null, 2);
30
+ break;
31
+ case 'plaintext':
32
+ output = result.markdown;
33
+ break;
34
+ case 'html':
35
+ output = result.markdown;
36
+ break;
37
+ case 'markdown':
38
+ default:
39
+ output = result.markdown;
40
+ break;
41
+ }
42
+ if (options.output) {
43
+ await mkdir(dirname(options.output), { recursive: true });
44
+ await writeFile(options.output, output, 'utf-8');
45
+ if (options.verbose) {
46
+ console.error(`Written to: ${options.output}`);
47
+ }
48
+ }
49
+ else {
50
+ process.stdout.write(output);
51
+ }
52
+ if (options.verbose) {
53
+ console.error(`Conversion completed in ${result.stats.duration.toFixed(1)}ms`);
54
+ }
55
+ }
56
+ catch (error) {
57
+ console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
58
+ process.exit(1);
59
+ }
60
+ });
61
+ }
62
+ //# sourceMappingURL=convert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert.js","sourceRoot":"","sources":["../../src/commands/convert.ts"],"names":[],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M,CAAC,QAAQ,CAAC;oBACzB,MAAM;gBACR,KAAK,MAAM;oBACT,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;oBACzB,MAAM;gBACR,KAAK,UAAU,CAAC;gBAChB;oBACE,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;oBACzB,MAAM;YACV,CAAC;YAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACnB,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC1D,MAAM,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;gBACjD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;oBACpB,OAAO,CAAC,KAAK,CAAC,eAAe,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;gBACjD,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC/B,CAAC;YAED,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,CAAC,KAAK,CAAC,2BAA2B,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACjF,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAClF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerFormatsCommand(program: Command): void;
3
+ //# sourceMappingURL=formats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../../src/commands/formats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA0B7D"}
@@ -0,0 +1,24 @@
1
+ import { getSupportedExtensions, getSupportedMimeTypes } from '@markitdownjs/shared';
2
+ export function registerFormatsCommand(program) {
3
+ program
4
+ .command('formats')
5
+ .description('List all supported file formats')
6
+ .action(() => {
7
+ const extensions = getSupportedExtensions();
8
+ const mimeTypes = getSupportedMimeTypes();
9
+ console.log('Supported Formats:');
10
+ console.log('==================\n');
11
+ const rows = [];
12
+ for (let i = 0; i < extensions.length; i++) {
13
+ rows.push([extensions[i] ?? '', mimeTypes[i] ?? '']);
14
+ }
15
+ const maxExt = Math.max(...rows.map(r => (r[0] ?? '').length), 'Extension'.length);
16
+ console.log(`${'Extension'.padEnd(maxExt)} MIME Type`);
17
+ console.log(`${'-'.repeat(maxExt)} ${'-'.repeat(40)}`);
18
+ for (const row of rows) {
19
+ console.log(`${(row[0] ?? '').padEnd(maxExt)} ${row[1] ?? ''}`);
20
+ }
21
+ console.log(`\nTotal: ${extensions.length} formats supported`);
22
+ });
23
+ }
24
+ //# sourceMappingURL=formats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formats.js","sourceRoot":"","sources":["../../src/commands/formats.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAErF,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,iCAAiC,CAAC;SAC9C,MAAM,CAAC,GAAG,EAAE;QACX,MAAM,UAAU,GAAG,sBAAsB,EAAE,CAAC;QAC5C,MAAM,SAAS,GAAG,qBAAqB,EAAE,CAAC;QAE1C,OAAO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L=serve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6F3D"}
@@ -0,0 +1,89 @@
1
+ import { createServer } from 'http';
2
+ import { MarkItDown } from '@markitdownjs/core';
3
+ export function registerServeCommand(program) {
4
+ program
5
+ .command('serve')
6
+ .description('Start an HTTP server for document conversion')
7
+ .option('-p, --port <port>', 'Port to listen on', '3000')
8
+ .option('-v, --verbose', 'Verbose output')
9
+ .action((options) => {
10
+ const port = parseInt(options.port, 10);
11
+ const parser = new MarkItDown();
12
+ const server = createServer(async (req, res) => {
13
+ if (req.method === 'GET' && req.url === '/health') {
14
+ res.writeHead(200, { 'Content-Type': 'application/json' });
15
+ res.end(JSON.stringify({ status: 'ok', timestamp: new Date().toISOString() }));
16
+ return;
17
+ }
18
+ if (req.method === 'POST' && req.url === '/convert') {
19
+ try {
20
+ const chunks = [];
21
+ for await (const chunk of req) {
22
+ chunks.push(chunk);
23
+ }
24
+ const body = Buffer.concat(chunks).toString();
25
+ let fileData;
26
+ let fileName;
27
+ const contentType = req.headers['content-type'] ?? '';
28
+ if (contentType.includes('multipart/form-data')) {
29
+ const boundaryMatch = contentType.match(/boundary=(.+)/);
30
+ if (!boundaryMatch) {
31
+ res.writeHead(400, { 'Content-Type': 'application/json' });
32
+ res.end(JSON.stringify({ error: 'Missing boundary in multipart content-type' }));
33
+ return;
34
+ }
35
+ const boundary = boundaryMatch[1];
36
+ const parts = body.split(`--${boundary}`);
37
+ for (const part of parts) {
38
+ if (part.includes('Content-Disposition')) {
39
+ const nameMatch = part.match(/name="([^"]+)"/);
40
+ const filenameMatch = part.match(/filename="([^"]+)"/);
41
+ if (nameMatch?.[1] === 'file') {
42
+ const headerEnd = part.indexOf('\r\n\r\n');
43
+ if (headerEnd !== -1) {
44
+ fileData = part.substring(headerEnd + 4).replace(/\r\n--$/, '');
45
+ if (filenameMatch?.[1]) {
46
+ fileName = filenameMatch[1];
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
53
+ else {
54
+ const json = JSON.parse(body);
55
+ fileData = json.data;
56
+ fileName = json.fileName;
57
+ }
58
+ if (!fileData) {
59
+ res.writeHead(400, { 'Content-Type': 'application/json' });
60
+ res.end(JSON.stringify({ error: 'No file provided' }));
61
+ return;
62
+ }
63
+ const result = await parser.convert({
64
+ data: Buffer.from(fileData, 'base64'),
65
+ fileName,
66
+ });
67
+ res.writeHead(200, { 'Content-Type': 'application/json' });
68
+ res.end(JSON.stringify(result));
69
+ }
70
+ catch (error) {
71
+ if (options.verbose) {
72
+ console.error('Conversion error:', error);
73
+ }
74
+ res.writeHead(500, { 'Content-Type': 'application/json' });
75
+ res.end(JSON.stringify({
76
+ error: error instanceof Error ? error.message : 'Conversion failed',
77
+ }));
78
+ }
79
+ return;
80
+ }
81
+ res.writeHead(404, { 'Content-Type': 'application/json' });
82
+ res.end(JSON.stringify({ error: 'Not found' }));
83
+ });
84
+ server.listen(port, () => {
85
+ console.error(`MarkItDownJS server running on http://localhost:${port}`);
86
+ });
87
+ });
88
+ }
89
+ //# sourceMappingURL=serve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAmC,MAAM,MAAM,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,8CAA8C,CAAC;SAC3D,MAAM,CAAC,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,CAAC;SACxD,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAAC;SACzC,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AG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;YACvB,OAAO,CAAC,KAAK,CAAC,mDAAmD,IAAI,EAAE,CAAC,CAAC;QAC3E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerWatchCommand(program: Command): void;
3
+ //# sourceMappingURL=watch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/commands/watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAoF3D"}
@@ -0,0 +1,81 @@
1
+ import { watch, readFile, writeFile, stat, readdir } from 'fs/promises';
2
+ import { join, basename, extname, resolve } from 'path';
3
+ import { MarkItDown } from '@markitdownjs/core';
4
+ export function registerWatchCommand(program) {
5
+ program
6
+ .command('watch')
7
+ .description('Watch a directory and convert new/modified files to Markdown')
8
+ .argument('[dir]', 'Directory to watch', '.')
9
+ .option('-r, --recursive', 'Watch subdirectories recursively')
10
+ .option('-v, --verbose', 'Verbose output')
11
+ .action(async (dir, options) => {
12
+ const watchDir = resolve(dir);
13
+ const parser = new MarkItDown();
14
+ const processedFiles = new Set();
15
+ console.error(`Watching: ${watchDir}`);
16
+ async function convertFile(filePath) {
17
+ try {
18
+ const content = await readFile(filePath);
19
+ const result = await parser.convert({
20
+ data: new Uint8Array(content),
21
+ fileName: filePath,
22
+ });
23
+ const mdPath = join(watchDir, basename(filePath, extname(filePath)) + '.md');
24
+ await writeFile(mdPath, result.markdown, 'utf-8');
25
+ if (options.verbose) {
26
+ console.error(`Converted: ${filePath} -> ${mdPath}`);
27
+ }
28
+ }
29
+ catch (error) {
30
+ console.error(`Error converting ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
31
+ }
32
+ }
33
+ async function scanDirectory(dirPath) {
34
+ try {
35
+ const entries = await readdir(dirPath, { withFileTypes: true });
36
+ for (const entry of entries) {
37
+ const fullPath = join(dirPath, entry.name);
38
+ if (entry.isDirectory() && options.recursive) {
39
+ await scanDirectory(fullPath);
40
+ }
41
+ else if (entry.isFile()) {
42
+ processedFiles.add(fullPath);
43
+ await convertFile(fullPath);
44
+ }
45
+ }
46
+ }
47
+ catch (error) {
48
+ console.error(`Error scanning ${dirPath}: ${error instanceof Error ? error.message : String(error)}`);
49
+ }
50
+ }
51
+ await scanDirectory(watchDir);
52
+ try {
53
+ const watcher = watch(watchDir, { recursive: options.recursive });
54
+ for await (const event of watcher) {
55
+ if (!event.filename)
56
+ continue;
57
+ const filePath = join(watchDir, event.filename);
58
+ try {
59
+ const fileStat = await stat(filePath);
60
+ if (!fileStat.isFile())
61
+ continue;
62
+ }
63
+ catch {
64
+ continue;
65
+ }
66
+ if (!processedFiles.has(filePath)) {
67
+ processedFiles.add(filePath);
68
+ if (options.verbose) {
69
+ console.error(`New file detected: ${filePath}`);
70
+ }
71
+ }
72
+ await convertFile(filePath);
73
+ }
74
+ }
75
+ catch (error) {
76
+ console.error(`Watch error: ${error instanceof Error ? error.message : String(error)}`);
77
+ process.exit(1);
78
+ }
79
+ });
80
+ }
81
+ //# sourceMappingURL=watch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/commands/watch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,EAAE,UAAU,E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,IAAI,CAAC,KAAK,CAAC,QAAQ;oBAAE,SAAS;gBAE9B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAEhD,IAAI,CAAC;oBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;oBACtC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;wBAAE,SAAS;gBACnC,CAAC;gBAAC,MAAM,CAAC;oBACP,SAAS;gBACX,CAAC;gBAED,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAClC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;oBAC7B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;wBACpB,OAAO,CAAC,KAAK,CAAC,sBAAsB,QAAQ,EAAE,CAAC,CAAC;oBAClD,CAAC;gBACH,CAAC;gBAED,MAAM,WAAW,CAAC,QAAQ,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gBAAgB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACxF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { registerConvertCommand } from './commands/convert.js';
4
+ import { registerWatchCommand } from './commands/watch.js';
5
+ import { registerBatchCommand } from './commands/batch.js';
6
+ import { registerServeCommand } from './commands/serve.js';
7
+ import { registerFormatsCommand } from './commands/formats.js';
8
+ const program = new Command();
9
+ program
10
+ .name('markitdownjs')
11
+ .description('Universal document-to-Markdown conversion tool')
12
+ .version('0.1.0');
13
+ registerConvertCommand(program);
14
+ registerWatchCommand(program);
15
+ registerBatchCommand(program);
16
+ registerServeCommand(program);
17
+ registerFormatsCommand(program);
18
+ program.parse();
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,cAAc,CAAC;KACpB,WAAW,CAAC,gDAAgD,CAAC;KAC7D,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAChC,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC9B,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC9B,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC9B,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAEhC,OAAO,CAAC,KAAK,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@markitdownjs/cli",
3
+ "version": "0.1.0",
4
+ "description": "CLI tool for MarkItDownJS document conversion",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "bin": {
9
+ "markitdownjs": "./dist/index.js"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "commander": "^12.0.0",
21
+ "@markitdownjs/core": "0.1.0",
22
+ "@markitdownjs/shared": "0.1.0"
23
+ },
24
+ "devDependencies": {
25
+ "typescript": "^5.5.0",
26
+ "@types/node": "^20.0.0"
27
+ },
28
+ "scripts": {
29
+ "build": "tsc --project tsconfig.json",
30
+ "dev": "tsc --watch --project tsconfig.json",
31
+ "typecheck": "tsc --noEmit",
32
+ "clean": "rm -rf dist tsconfig.tsbuildinfo"
33
+ }
34
+ }