mirror of
https://gitlab.rlp.net/proj-wise2526-video2document/video2document.git
synced 2026-06-15 18:01:52 +02:00
Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
//Call with convert.js <input.md> <output.pdf|docx|html|odt>
|
||||||
|
const { execSync } = require('child_process');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
|
||||||
|
if (args.length < 2) {
|
||||||
|
console.log('Usage: node convert.js <input.md> <output.pdf|docx|html|odt>');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const inputFile = args[0];
|
||||||
|
const outputFile = args[1];
|
||||||
|
const format = path.extname(outputFile).slice(1);
|
||||||
|
|
||||||
|
if (!fs.existsSync(inputFile)) {
|
||||||
|
console.error(`File not found: ${inputFile}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Converting ${path.basename(inputFile)} → ${path.basename(outputFile)} ...`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cmd = `pandoc "${inputFile}" -o "${outputFile}"`;
|
||||||
|
execSync(cmd, { stdio: 'inherit' });
|
||||||
|
console.log(`Successfully saved: ${outputFile}`);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error during conversion.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user