Skip to content

Commit

Permalink
Merge pull request #577 from Fdawgs/fix/rtf-conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Dec 1, 2021
2 parents b6dee34 + d4285d9 commit cb01eaf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/plugins/rtf-to-txt/index.js
Expand Up @@ -79,15 +79,15 @@ async function plugin(server, options) {
await fs.writeFile(tempFile, req.body);

try {
/**
* `fixUtf8` function replaces most common incorrectly converted
* Windows-1252 to UTF-8 results with HTML equivalents.
* Refer to https://www.i18nqa.com/debug/utf8-debug.html for more info.
*/
req.conversionResults.body = await unrtf.convert(
tempFile,
config.rtfToTxtOptions
);

// Remove metadata comments UnRTF adds to beginning of file
req.conversionResults.body = req.conversionResults.body
.replace(/^###(?:\s){0,3}.*?(?:-){1,17}/ms, "")
.trim();
} catch (err) {
/**
* UnRTF will throw if the .rtf file provided
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/tidy-html/index.js
Expand Up @@ -56,13 +56,15 @@ async function plugin(server) {
* - clean (replace legacy HTML tags)
* - dropProprietaryAttributes (remove proprietary attributes, such as Microsoft data binding attributes)
* - escapeCdata (convert <![CDATA[]]> sections to normal text)
* - hideComments (do not print HTML comment tags)
* - sortAttributes (sort attributes in element in ascending alphabetic sort)
*/
const config = {
bare: true,
clean: true,
dropProprietaryAttributes: true,
escapeCdata: true,
hideComments: true,
sortAttributes: "alpha",
};

Expand Down

0 comments on commit cb01eaf

Please sign in to comment.