Input
# Hello
## CódigoFacilito
This is a test
Script
const fs = require("fs/promises");
function processMarkdown(markdownText) {
const html = markdownText
.replace(/^#\s+(.*)/gm, "<h1>$1</h1>")
.replace(/^##\s+(.*)/gm, "<h2>$1</h2>")
.replace(/^(?!<h\d>)(.*)/gm, "<p>$1</p>");
return html;
}
async function main() {
try {
const data = await fs.readFile("./text.md", "utf-8");
const html = processMarkdown(data);
await fs.writeFile("./text.html", html, "utf-8");
console.log("HTML file generated!");
} catch (error) {
console.error("Error: ", error);
}
}
main();