Run a JS file or Java executable and embed output

I’ve a need to generate rail road diagrams from BNF. We have a tool in java and javascript that can generate these diagrams. For now, the team has been generating the files manually add adding them as static files to be served by Hugo.

Is there any way I can write a shortcode that can execute the jar or js file to create the diagram and have the diagram automatically generated during the site generation? Can I convert the js (or jar) as a plugin?

ESBuild seems to process js files, but is there a way to execute them?

Note: I understand that I can use resource.GetRemote to fetch from a hosted dynamic page (for now I don’t have that option , unless I could do it within HUGO)

@jmooring - any suggestions ?

No.

You might consider writing a local Node server that can return an SVG given a BNF payload, then use resources.GetRemote.

Thanks @jmooring. Are there plans to support os.exec in Hugo pipeline ? And plugins ??

No; too dangerous.

Other than Hugo Modules, no. Maybe at some point, but not in the near future.

1 Like

See https://discourse.gohugo.io/t/42145/3. I think this approach is applicable.

Thanks @jmooring . I setup a small web-service to start along with hugo (with npm start) & talked to the service via resources.GetRemote. works fine.

Nice. Great job.