oxygenxml / dita-ot-diagrams-plugin

Dynamically convert PlantUML content inside DITA topics to SVG
Apache License 2.0
9 stars 3 forks source link

Text set on an arrow in an included diagram not properly rendered in output SVG #2

Closed raducoravu closed 4 years ago

raducoravu commented 4 years ago

Pasting below received email feedback:

I am still prototyping with these diagrams and they are proving to be very useful. However, I notice that when I attempt to put text on an arrow in an included diagram, in the DITAOT output, the text does not render on the arrow. It becomes a flow diagram box instead. If the text on the arrow is in the main (not included) diagram, it works fine.

I engaged the PlantUML developers in case this is a bug, but it appears to be specific to the Oxygen DITAOT plugin. https://forum.plantuml.net/10871/text-on-arrows-not-working-if-in-include?show=10899#c10899

The problematic PlantUML syntax is as follows: ->Mobile;

As you can see, this is in the example I gave you. I believe the greater than sign is what is causing the problem.

By the way, everything renders very good in the Oxygen Author plugin. It is only the published output from the DITAOT that has the problem.

raducoravu commented 4 years ago

The HTML5 from the "samples\test_diagram_includes.dita" sample DITA file should have an arrow which has a "Mobile" text on it. But instead it gets a flow diagram box instead containing something like '>Mobile;'.

raducoravu commented 4 years ago

The plugin code is similar to the XSLT code: https://github.com/oxygenxml/wsaccess-javascript-sample-plugins/blob/master/plantuml-images-support/wsAccess.js

https://github.com/oxygenxml/dita-plant-uml/blob/master/com.oxygenxml.plantuml.svg/src/com/oxygenxml/plantuml/svg/PlantumlToSVG.java

I checked and they both receive the same initial UML content. The plugin code saves to PNG and the XSLT extension to SVG. I tried in the XSLT code to save to a PNG on the side and same problem so the fact that it saved to SVG is not to blame.

raducoravu commented 4 years ago

Both codes set the property:

java.lang.System.setProperty("plantuml.include.path", newCurrentDir.getAbsolutePath());

so that it's the PlantUML library which actually reads the contents of the included file.

raducoravu commented 4 years ago

The problem is that the XSLT script is called after both DITA topics have been moved to the temporary files folder and the ">" in the target topic was probably escaped to ">".

raducoravu commented 4 years ago

One possible way to fix this would be to use some XSLT code like the one here:

https://github.com/oxygenxml/dita-embed-html-mathml-svg/blob/master/com.oxygenxml.embed.mathml.svg/customXHTML.xsl

to find the original place where the topic was located. Or some extra API in PlantUML to control the contents of the included file.

raducoravu commented 4 years ago

The plugin now has a new parameter named "plantuml.include.path" which can be added in the Oxygen transformation scenario Parameters tab and set to the folder path where the included PlantUML diagram files are placed. The value of the parameter allows you to set an enumeration of file paths separated on Linux/Mac by ":" and on Windows by ";". If the parameter is not set in the transformation scenario, the plugin works as before, it will read the included files next to the current topic file (which is placed in the transformation temporary files folder).