BlueHatbRit / mdpdf

Markdown to PDF command line app with support for stylesheets
https://npmjs.com/package/mdpdf
Apache License 2.0
679 stars 45 forks source link

Feature Request: Add PlantUML diagram support #180

Open PeterDaveHello opened 1 month ago

PeterDaveHello commented 1 month ago

Thanks for the great work on mdpdf! It's been a convenient tool for converting Markdown to PDF.

It looks like mdpdf currently doesn't support rendering PlantUML diagrams embedded in the Markdown source. PlantUML is a popular plain text format for defining various types of diagrams. Having native support for it, similar to how GitLab supports rendering PlantUML code blocks directly in Markdown files, would be a handy feature.

This would allow users to easily include sequence diagrams, use case diagrams, class diagrams, etc., right in their Markdown documents and have them show up properly in the generated PDF.

Is this a feature you would consider adding to mdpdf? Let me know what you think!

BlueHatbRit commented 1 month ago

Glad you've found the package useful!

mdpdf started as just something I needed to help me with some assignments when I was in university (too long ago now). I've never really had a need for a UML plugin to be honest, although I could see it being useful to other users so I'd happily have support for it. That said, I don't have much time to dedicate to the project at the moment so it's not something I'd be able to add any time soon. I'd be up for reviewing a pull request though if someone else fancied it.

The markdown -> html step uses Showdownjs, so you'd either need a pre-processor to generate images before that step and replace the markup, or a showdown plugin. A showdown plugin would be preferrable, even if it didn't do the full range of functionality that PlantUML supports as it would be far easier to maintain on this side. But I'm up for discussing some ideas with anyone who wants to have a go at implementing it.

PeterDaveHello commented 1 month ago

Thanks @BlueHatbRit, I just took a look at Showdownjs, and it looks like the development has been pending for a while. Though I might not be able to take a deep look, but maybe a trick is to use plantuml-encoder(https://www.npmjs.com/package/plantuml-encoder) to encode the PlantUML code block, and use a PlantUML server to handle the rendering, that's how GitLab is doing it, if I remember correctly.