Final touches to the facelift

This commit is contained in:
Bad Manners 2024-09-07 18:02:53 -03:00
parent 379287af36
commit a2fbf908aa
No known key found for this signature in database
GPG key ID: 8C88292CCB075609
19 changed files with 194 additions and 87 deletions

View file

@ -168,10 +168,16 @@ async function exportStory(slug: string, options: { outputDir: string }) {
);
const rtfText = await readFile(join(tempDir, "temp.rtf"), "utf-8");
const rtfStyles = getRTFStyles(rtfText);
await writeFile(
join(outputDir, `${slug}.rtf`),
rtfText.replaceAll(rtfStyles["Preformatted Text"], rtfStyles["Normal"]),
);
if (!rtfStyles["Preformatted Text"]) {
console.warn(`Missing RTF style "Preformatted Text"! Skipping RTF file generation.`);
} else if (!rtfStyles["Normal"]) {
console.warn(`Missing RTF style "Normal"! Skipping RTF file generation.`);
} else {
await writeFile(
join(outputDir, `${slug}.rtf`),
rtfText.replaceAll(rtfStyles["Preformatted Text"], rtfStyles["Normal"]),
);
}
})(),
]);
console.log("Success!");