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.12k stars 108 forks source link

feature: Supporting marked plugins #292

Open tothlp opened 3 months ago

tothlp commented 3 months ago

Problem:

Marked has some pretty awesome plugins, like alert and footnote, but I can't get to figure out how to use them with md-to-pdf. I believe that upgrading the marked library is needed.

Solution:

I want to be able to use marked extensions. see: https://github.com/bent10/marked-extensions?tab=readme-ov-file#packages

simonhaenisch commented 3 months ago

I think it's basically this: #228.

With a .js config file you can already use extensions IIRC, via the marked_extensions config option, but I don't remember how it works exactly 🙈 you can probably find some info by searching the issues (:

Upgrading Marked is also on the todo list. I don't receive any sponsoring for this project so things take a while at this point with small children at home 🙃

tothlp commented 3 months ago

Thanks a lot for the tip, I will check it out! Can I update this issue, if I figure something out?

simonhaenisch commented 3 months ago

Yes please!

tothlp commented 3 months ago

I'm afraid, that the plugins that can be passed to marked.use() are limited by the given marked version number. As I see these are the supported plugins for marked version 4.2.12. (I believe that is what md-to-pdf uses). So I think that alert and footnote can not be used with this.

https://github.com/markedjs/marked/blob/v4.2.12/docs/USING_ADVANCED.md#known-extensions

simonhaenisch commented 3 months ago

Ok i'm planning to upgrade Marked though, would that solve the compatibility problem?

tothlp commented 2 months ago

I'm sorry, I did not see that comment somehow. Yes, I believe, it would. I am not an expert at all with these libs as I develop mainly in Kotlin, but I think it is worth a try. :)