simonhaenisch / md-to-pdf

Hackable CLI tool for converting Markdown files to PDF using Node.js and headless Chrome.
https://www.npmjs.com/md-to-pdf
MIT License
1.18k stars 111 forks source link

bug: Links to images now contain http://localhost:port prefix when using --as-html flag #256

Closed MarshalX closed 8 months ago

MarshalX commented 1 year ago

Context: I use HTML snippets in my markdown. Previously it worked fine and didn't touch src attr. Now it modifies it.

Describe the bug:

Starting from ~July the behavior of HTML output has been changed.

This is what I have in my MD file:

<img alt="GitHub" class="align-middle" height="16" src="icons/dark/github.svg">

This is what I get in HTML output:

<img alt="GitHub" class="align-middle" height="16" src="http://localhost:60331/icons/dark/github.svg">

This is the command that I use:

md-to-pdf --as-html --config-file config/html.js Ilya_Siamionau_CV.md

I locked npm version, I locked md-to-pdf version. CI worked fine 2 months ago, but now fails.

Project (with html.js config): https://github.com/MarshalX/cv/tree/a6d62eb475d3e68f4c9b878826eeacea626d7067 Success CI run: https://github.com/MarshalX/cv/actions/runs/5567446756 Failed CI run: https://github.com/MarshalX/cv/actions/runs/6266508744

After upgrading node to 16 I have described bug. Probably not related to this project and thanks to deps, but just want to inform you in case you are interested.

simonhaenisch commented 1 year ago

hm ok that's weird, i agree they should be relative links. maybe it's from upgrading marked? can you check which version you were using when it worked and now (if you have a lockfile e.g. package-lock.json committed you should be able to tell from there).

simonhaenisch commented 1 year ago

btw just an idea but can you try

<img alt="GitHub" class="align-middle" height="16" src="/icons/dark/github.svg">

i.e. prefix the src path with a /?

MarshalX commented 1 year ago

btw just an idea but can you try

<img alt="GitHub" class="align-middle" height="16" src="/icons/dark/github.svg">

i.e. prefix the src path with a /?

yep that was my try before making dirty hacks xd doesnt work

MarshalX commented 1 year ago

hm ok that's weird, i agree they should be relative links. maybe it's from upgrading marked? can you check which version you were using when it worked and now (if you have a lockfile e.g. package-lock.json committed you should be able to tell from there).

Unfortunately, im using cli and global installation... there is not package-lock

npm i -g md-to-pdf@4.0.0
MarshalX commented 8 months ago

closed because it's bug of md-to-pdf