-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline (with base64 data-uri) externally linked images and resolved path fix #16
Conversation
…ed, i.e., if not inlined). - Images included in the markdown (either as specified with markdown syntax or with the \<img\> tag) are now inlined in a data:base64 uri. This makes the output html file really self-contained.
Thanks for the PR! I have a few questions on this:
|
In principle it downloads and inlines any kind of url (besides data:). Moreover, as for the <img> images in the markdown, if the source is included as a string in the call to remark.create(), inliner ignores it. |
Did you try it with http resources? I think that |
No, I admit I didn't. I will check whether it works also with http URLs but in case I will switch to the asynchronous file read (adapting the code). If it is ok with you I will first proceed with sync including only file:/// urls and then I will take care of http. |
Apparently it will not work with http urls, therefore I changed the regular expression so that now only images having file:/// urls will be inlined. |
Perfect! |
I did it, now I listed it on github config. :-) Next PR of mine will include also the inline inclusion of external (http) Images! Keep in touch! |
If found an edge case on this, when using CSS or Remark statements directly in the markdown files (like |
I just fixed that edge case and published a new |
I succeeded in inlining also externally linked images (with ad-hoc code). Now they are rendered in a data:base64 uri that is inlined in the markdown (and eventually in the remark.js generated html).
Moreover, I fixed relative paths for export also in html template and sass style (if they do not need to be inlined).
The only added dependency is mime, which is already included by inliner. I didn't make it explicit in the package.json file, so feel free to do it.