-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
Maybe I need a break from coding, but I really don't get why I can't retrieve the value from the function...
Can anyone please tell me what I'm doing wrong?
const parseRTF = require("rtf-parser");
let string = `{\\rtf1\\ansi\\deff0\\nouicompat{\\ etc...}`;
function convertRTFtoPlainText(string) {
parseRTF.string(string, (err, doc) => {
let result = "";
doc.content.forEach((item) => {
if (item.content) {
item.content.forEach((span) => {
result += span.value;
});
}
});
console.log(result); // <-------- Shows the converted string
return result.trim();
});
}
let value = convertRTFtoPlainText(string);
console.log(value); // <-------- undefinedReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels