INNER CODE UNIT · TypeScript
htmlFiles
philschmid/clipper.js · src/index.ts:27
const htmlFiles = fs.readdirSync(inputPath).filter(file => file.endsWith('.html')).map(file => path.join(inputPath, file));
res = []
for await (const file of htmlFiles) {
const md = await extract_from_html(readHtmlFileFromPath(file));
res.push({ markdown: md, file });
}
} else {
res = await extract_from_html(readHtmlFileFromPath(inputPath));
}
} else {
throw new Error("Please specify either a URL or a file path");
}
// writes to file
if (args.format === "json") {
writeMarkdownToJsonlines(res, args.output);
} else {
writeMarkdownToFile(res, args.output);
}