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.2k stars 110 forks source link

feat: add new listr function with add capability #144

Open chamabreu opened 2 years ago

chamabreu commented 2 years ago

BREAKING CHANGE: It is now possible to give a folder as file argument e.g.: md2pdf $(pwd)

This works recursive. The watcher will listen for all add and change events in all subfolders, but only for markdown files.

For compatibility, a legacy function is kept alive, to handle multiple input paths, like ./*/.md, so the old cli app works like before.

chamabreu commented 2 years ago

Hi, related to #137 , this is my example how this could be implemented.

Refactored on the way a few things.

Would be nice, if we can pull this in. If not, no Problem, I will work then only on my fork.

chamabreu commented 2 years ago

Thanks for the feedback.

I implemented the convertFactory for that it is not more necessary to push all the configs and args around. But maybe this could be overpowered now, I have to review it myself.

If you are willing to merge it, if I develop it further to your coding style, I will do. If you dont want this feature in your repo, I will stick to my fork.

Just tell me. I would do: Refactor the factoryFunction (remove)

Dunno if its necessary to add that -r flag. At the state now, it is not really breaking, is it? Because i kept the posibility to pass a glob pattern.

But I had the idea, that a user could give a folder, and set the recursive depth. Maybe this and the -r flag could go in a next PR/Feature.

chamabreu commented 2 years ago

Pushed a commit where convertFactory is removed.

I would need to dig deeper in CLI flags, to get to know how to implement the -r flag. Is this mandatory for you? I think, because the program works like before, with the ./*.md and ./**/*.md inputs, the folder functionality as is now, is just added, and does not replace or interrupt the old approach.