progsource / maddy

C++ Markdown to HTML header-only parser library
MIT License
203 stars 40 forks source link

Local image to data URI? #16

Open fengwang opened 5 years ago

fengwang commented 5 years ago

Minimal Code Example

![]( ./images/a.png)

to html5

<img  src="data:image/png;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOy...">

Conditions

If in absolute path or relative path, there exists such an image, generate its data URI instead of providing a link.

Description

convert image to base64 seems a bit annoying, is it possible to implement this feature?

progsource commented 5 years ago

Adding the functionality to maddy directly would make it necessary to add file handling and image-to-bas64 processing. I actually like libraries which do one thing and one thing only, so I don't feel like this should go directly into maddy. At the moment I am considering making some kind of plugin functionality, so that you could hook into the parsing and replace the image filename yourself.

At the moment the only thing you can do is either replacing it before or after maddy is parsing your markdown files.