danburzo / percollate

A command-line tool to turn web pages into readable PDF, EPUB, HTML, or Markdown docs.
https://danburzo.ro/projects/percollate/
MIT License
4.32k stars 166 forks source link

Fixed issue with converting ArrayBuffer to base64 #154

Closed vongrad closed 1 year ago

vongrad commented 1 year ago

There seems to be an issue with generating Epub with inline images using the following command: percollate epub --inline https://da.m.wikipedia.org/wiki/Danmarks_historie

The function fetchBase64 does not properly convert the ArrayBuffer to base64 string and instead produces [object ArrayBuffer]. Example of the output: <img data-file-height="355" data-file-width="330" decoding="async" src="data:image/png;base64,[object ArrayBuffer]" />

I have included a small patch that should fix this issue.

danburzo commented 1 year ago

Great catch, @vongrad! I carelessly replaced the buffer() deprecated call with arrayBuffer() and forgot about the serialization. Although not strictly necessary, could you please also import Buffer from node:buffer?

vongrad commented 1 year ago

Sure thing, it's imported now.

danburzo commented 1 year ago

Perfect, thank you for the fix!