Skip to content

Commit

Permalink
fixes a bug on raw text spacing / line breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
joanfabregat committed Feb 22, 2024
1 parent 01bef30 commit 1dfce3a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ app.post('/convert', upload.single('file'), async (req, res) => {
} else {
res.send(
extractResult.pages.reduce(
(acc1, page) => acc1 + page.content.reduce(
(acc2, content) => acc2 + content.str,
'',
),
(acc1, page) => {
const pageContent = page.content.reduce(
(acc2, content) => content.str ? acc2 + '\n' + content.str : acc2,
'',
);
return pageContent ? acc1 + '\n' + pageContent : acc1;
},
'',
),
).trim(),
);
}

Expand Down

0 comments on commit 1dfce3a

Please sign in to comment.