kroki icon indicating copy to clipboard operation
kroki copied to clipboard

Support image map service in plantuml

Open nejch opened this issue 1 year ago • 2 comments

When hyperlinks are added in plantuml, ~~the server will call~~ the /map/ service can be used to create image maps (see Image Map service /plantuml/map/, https://plantuml.com/server, also plantuml-server code).

It seems like Kroki will return a 400 response instead: 400 Unsupported output format: map for plantuml. Must be one of png, svg, jpeg, base64, txt or utxt.

I poked around the code a bit and it doesn't seem like a case of just adding another file format as was done in https://github.com/yuzutech/kroki/pull/40. Any ideas @Mogztter?

nejch avatar Sep 16 '22 12:09 nejch

I wasn't aware of this feature. I find it odd that PlantUML send a HTTP request to itself 🤔 Could you please provide a reproduction case (i.e., the request your are sending)?

ggrossetie avatar Sep 16 '22 15:09 ggrossetie

@Mogztter thanks. I should say we found this issue via plantuml-markdown, which does some pre-processing of its own, and manually calls the /map/ endpoint: https://github.com/mikitex70/plantuml-markdown/blob/master/plantuml_markdown.py#L228-L240. So maybe my wording above was a bit inaccurate as I'm not sure if/how this gets called internally otherwise. But it works with plain plantuml. Here's a minimal reproduction:

plantuml:

@startuml
Bob -> Alice : [[https://www.example.com]]
@enduml

run containers:

$ docker run -d -p 8080:8080 plantuml/plantuml-server:jetty
$ docker run -d -p 8081:8000 yuzutech/kroki

curl the encoded diagram from above, e.g. via browser http://localhost:8080

plantuml-server:

$ curl http://localhost:8080/map/SyfFKj2rKt3CoKnELR1Io4ZDoSbNY8xEA2afABRIroylBzTBpyzFpqdLIyxFZOq50000
<map id="plantuml_map" name="plantuml_map">
<area shape="rect" id="id1" href="https://www.google.com" title="https://www.google.com" alt="" coords="67,48,218,63"/>
</map>

kroki:

$ curl http://localhost:8081/plantuml/map/SyfFKj2rKt3CoKnELR1Io4ZDoSbNY8xEA2afABRIroylBzTBpyzFpqdLIyxFZOq50000
Error 400: Unsupported output format: map. Must be one of plantuml for png, svg, jpeg, base64, txt or utxt.

/cc @anb0s @fgreinacher

nejch avatar Oct 06 '22 21:10 nejch