I'm converting a doc file into html using mammoth and then trying to read the html file line by line.
As explained in this question, i've tried nodejs inbuilt readline module, but i'm getting the whole page as a single line.
mammoth.convertToHtml({path: path.resolve("articles") + "a_doc_file.docx"}, options)
.then(async function(result) {
var html = result.value;
var messages = result.messages;
const fileStream = fs.createReadStream(`${path.resolve("articles")}/article.html`);
fs.writeFileSync(`${path.resolve("articles")}/article.html`, html);
const rl = readline.createInterface({
input: fileStream,
crlfDelay: Infinity
});
for await (const line of rl) {
console.log(`Line from file: ${line}`);
}
})
.done();
I need to get the html output line by line so that i can save the data accordingly in the schema
Thanks for any help in advance