AVATEAM-IT-SYSTEMHAUS / mkdocs-kroki-plugin

MkDocs plugin for Kroki-Diagrams
MIT License
41 stars 27 forks source link

mkdocs-kroki-plugin 0.8.1 doesn't work anymore with Backstage techdoc #70

Open jonesbusy opened 1 week ago

jonesbusy commented 1 week ago

Hi,

Mkdoc material works well on 0.8.1 and we have finally the fonts loaded (thanks for this!)

But after this upgrade the mkdocs-kroki-plugin to version 0.8.1 it doesn't work anymore with Backstage techdoc.

We are including our excalidraw like this

kroki-excalidraw
@from_file:test.excalidraw

I didn't found any relevant logs, but I've setup a reproduction repo here https://github.com/jonesbusy/mkdocs-kroki-backstage

Using the version 0.8.1 the diagram is just no displayed at all.

It's not only the preview but also when building techdoc https://backstage.io/docs/features/techdocs/how-to-guides/#how-to-add-mermaid-support-in-techdocs

I'm not sure if it's something what must be fixed on Backstage side of should be adatped on the mkdocs-kroki-plugin

I'm not sure which one of the 2 PR included between 0.8.0 and 0.8.1 cause this issue

netmMDHemmings commented 6 days ago

This is because in 0.8.1 there was a switch to using <object> tags for the generated images, for example:

<object name="Kroki" type="image/svg+xml" data="https://someurl/somedata" style="max-width:100%"></object>

Whereas previously in 0.8.0 it was <img> tags:

<p><img alt="Kroki" src="https://someurl/somedata" /></p>

And the techdocs plugin for Backstage strips out <object> tags because they're deemed unsafe (and has done for about three years now) -> https://github.com/advisories/GHSA-gg96-f8wr-p89f

So the workaround for now would be to downgrade to 0.8.0

jonesbusy commented 6 days ago

Thanks. Explanation has also been given https://github.com/AVATEAM-IT-SYSTEMHAUS/mkdocs-kroki-plugin/pull/66

I think it would be better to use the svg tag instead of object which should work the same

oniboni commented 6 days ago

I've tried to use the svg tags directly, sadly the different diagram generators produce different types of svg data, sometimes with a viewport setting, sometimes with hard width and height, that interferes with the layout.

Maybe the option whether to use img tags should be settable via a config option?

I can try out some other approaches, when I'm well and fit again :face_with_thermometer:

Thank you all for the clues and leads :detective:

jonesbusy commented 6 days ago

Sure, that would be nice to have a config option for the format like the plantuml markdown : https://github.com/mikitex70/plantuml-markdown

svg (like 0.8.0) svg_object (like 0.8.1) svg_inline

Take care