gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.51k stars 7.51k forks source link

Add PlantUML rendering support -- post-hugo processing #8398

Closed gadams999 closed 1 year ago

gadams999 commented 3 years ago

Similar to the MathJax proposal (#6694), I would like to add PlantUML support via a goldmark extension (https://github.com/OhYee/goldmark-plantuml). By including the module and changes to the markdown/goldmark config, this would provide the ability to use code fencing to process and render PlantUML through a local script.

I have already created a fork and commit with intitial success here. Once compiled, any goldmark rendered content such as this:

```plantuml
@startuml
Alice -> Bob : here is my secret
Bob -> Alice : So I see
@enduml
The will create an inline `<svg...>` image object output by PlantUML on the rendered page by passing the contents of the code fence to a local script named `plantuml` on the user's path which then run the `plantuml.jar` file. Here is an example  script `/usr/local/bin/plantuml` that is on my `PATH`:

```bash
#!/bin/bash
echo "$(cat)" | java -jar /opt/plantuml/plantuml.jar "$@"

I am new to golang in general, so don't know if the OhYee modules (it pulls in a couple others) affects other aspects of Hugo or themes in general. As far as I can tell, there is no CGO conflicts. So glad to see goldmark and not have to resort to Asciidoctor files to generate PUMLs!

Before submitting a pull request, I'd like to get feedback and any recommended changes if necessary. For now using 0.82.0, I can create a container to generate my content. Thought I'd share what I've learned for others to use.

stevegt commented 3 years ago

This looks like a special case of #7921, which @bep has currently targeted for milestone v0.84. Not sure if he's working on code for it yet, but a PR might be welcome over there.

tveyben commented 2 years ago

Searching for info on how to use plantuml and hugo together I found this ticket which looks like the best candidate (based on my googling). In #7921 I see that it have been a moving milestone (+10 releases so far) thus this makes me wonder what it takes to give hugo plantuml capabilities.

Can this https://github.com/gadams999/hugo/commit/2fc83fc58b642a8aa566cae152b360ad3c76575e be changed to a PR or is something else blocking progress?

bep commented 2 years ago

The referenced library used os/exec to shell out to some external plantuml binary, which is not something I will add to Hugo at this point.

gadams999 commented 2 years ago

I respect the security approach for Hugo. It would be good to have some method to either use external rendering solutions, with some taint or other indicator for non-Hugo controlled packages or binaries.

For our use, we build Hugo in a container for local development and also to render the PlantUML code as SVG for our iotatlas.net. Here's the start of how we do the process today (latest tested version being 0.82.0):

https://github.com/aws/iot-atlas/blob/95b9e6c85f31d652f4fa3621af2c16f6defc579a/src/Dockerfile#L41

tveyben commented 2 years ago

@bep & @gadams999 Thank you for the info (and greetings from Denmark :-) I'll probably start by generating my plantuml illustrations "by hand"

stevegt commented 2 years ago

I like the taint idea -- added a few details to #7921.

ElanHasson commented 2 years ago

Hi @tveyben,

I see how you're adding goldmark-plantuml to the container, how are you handling post-processing?

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help. If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open. If this is a feature request, and you feel that it is still relevant and valuable, please tell us why. This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

tveyben commented 1 year ago

Hi @ElanHasson I think you're comment should have been targeted @gadams999 ;-) Unfortunately I have not been progressing with my plantUML /HUGO activities (got pinged by the BOT that this issue got closed - was happy as I thought it was now implemented, but sadly it was'nt (and I don't have the skills to do so myself..)

ElanHasson commented 1 year ago

Heh I too was excited 😅

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.