Skip to content

Commit

Permalink
fix(render): Fix HTML rendering when no images are referenced (#9)
Browse files Browse the repository at this point in the history
Unable to render HTML (thus PDF) correctly when no images are referenced in markdown (#9)
* Fix incorrect output when var encoded is undefined
  • Loading branch information
bernardkkt authored Apr 27, 2021
1 parent bec0721 commit bd9881b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions markdown-to-pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ async function ConvertImageRoutes(html) {
while (m = rex.exec(newPaths)) {
try {
let image = await encodeImage(m[1]);
newPaths = newPaths.replace(new RegExp(m[1], "g"), image);
if (image != null) { newPaths = newPaths.replace(new RegExp(m[1], "g"), image); }
} catch (error) {
console.log('ERROR:', error);
}
encoded = newPaths
}
return encoded;
return (encoded == null) ? newPaths : encoded;
}

// This converts the markdown string to it's HTML values # => h1 etc.
Expand Down

0 comments on commit bd9881b

Please sign in to comment.