workdir and path2project directives are missing when using my own plugin

40 views
Skip to first unread message

Alex

unread,
Mar 3, 2021, 9:17:07 AM3/3/21
to DITA-OT Users

Hi,

when transforming to HTML5 (and PDF), I want to render PlantUML diagrams that are embedded in markdown files. Therefore I have written a really small plugin that piggybacks on Radu's com.oxygenxml.plantuml.svg.

This is my plugin.xml:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="dita-ot/plugin.rnc" type="application/relax-ng-compact-syntax"?>
<plugin id="mysoopadoopanamespace.plugin.mdita-plantuml">
  <require plugin="com.oxygenxml.plantuml.svg"/>
   <feature extension="dita.xsl.xhtml" value="xsl/xhtmlSVG.xsl" type="file"/>
   <feature extension="dita.xsl.html5" value="xsl/xhtmlSVG.xsl" type="file"/>
   <feature extension="dita.xsl.xslfo" value="xsl/pdfSVG.xsl" type="file"/>
</plugin>

This is the full xhtmlSVG.xsl:

<?xml version="1.0" encoding="UTF-8"?>
<!--
    
Oxygen Latex to SVG sample conversion plugin
Copyright (c) 1998-2019 Syncro Soft SRL, Romania.  All rights reserved.
Licensed under the terms stated in the license file LICENSE 
available in the base directory of this plugin.

-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="2.0"
  xmlns:saxon="http://saxon.sf.net/"
  xmlns:converter="java:com.oxygenxml.plantuml.svg.PlantumlToSVG">
  <xsl:param name="plantuml.include.path"/>
  <xsl:template match="*[contains(@class,' pr-d/codeblock ')][contains(@outputclass, 'plantuml')] | *[contains(@class,' pr-d/codeblock ')][contains(@outputclass, 'puml')]" priority="10">
    <p>
      <xsl:call-template name="commonattributes"/>
      <xsl:copy-of select="parse-xml(converter:convert(text(), $plantuml.include.path))" use-when="not(function-available('saxon:parse'))"/>
      <xsl:copy-of select="saxon:parse(converter:convert(text(), $plantuml.include.path)" use-when="function-available('saxon:parse')"/>
    </p>
  </xsl:template>
</xsl:stylesheet>

I just have changed the template to match the classes derived from the intermediary .md-document in the temp directory produced by DITA-OT.

First thing to say: Thank you, Radu, for putting so much effort in DITA-OT, the plugins and the community!

Second: The plugin com.oxygenxml.plantuml.svg works flawlessly. My piggyback solution on the other hand gets the svg rendering done, but destroys the layout and navigation of the HTML5 output. After further investigation of the intermediary .md-document in the temp directory produced by DITA-OT, it is missing these directives at the start of the document:

<?workdir /out/tempppppp/topic?><?workdir-uri file:/out/tempppppp/topic/?><?path2project ../?><?path2project-uri ../?><?path2rootmap-uri ../?>

The consequence of missing these directives is, that the directory containing the .md-document is used as the basedir, which messes up the internal links, the navigation and links to stylesheets, js, etc.

Intermediary .md-documents without plantuml code do include these directives and work fine. Real DITA topics that embed plantuml and using com.oxygenxml.plantuml.svg do include these directives and work fine. So this is definitely caused by my plugin.

How can these directives be included? Does this have something to do with the order of the processing pipeline? I am stuck right now. Can you help?

Best regards

Alex

P.S.: I do not do any fancy chunking in my ditamap like in this maybe related issue.

Radu Coravu

unread,
Mar 4, 2021, 12:23:43 AM3/4/21
to Alex, DITA-OT Users
Hi Alex,

Thanks for the kind words.
I'm not sure what the problem is, if you remove your plugin completely and make the changes instead to the "com.oxygenxml.plantuml.svg" plugin do you encounter the same problems?
Do you have an extra XSLT stylesheet which is applied in the pre-processing stage?
Otherwise if you can provide the custom plugin and a small sample DITA project either publicly or to (radu_...@oxygenxml.com) I can try to find some time to look into this.

Regards,
Radu

--
You received this message because you are subscribed to the Google Groups "DITA-OT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/dita-ot-users/1e67aa1d-bfb2-4c39-89dc-7205a04d0633n%40googlegroups.com.

Alex

unread,
Mar 4, 2021, 8:49:18 AM3/4/21
to DITA-OT Users
Hi Radu,

thank you for the quick response. I found out the problem while building a small example for you (relates to your second question):

I also use fox.jason.prismjs, which highlights code and therefore hooks up on the same classes as com.oxygenxml.plantuml.svg. If I uninstall this plugin, the rendering of PlantUML works for DITA Topics and for Markdown (the latter with my plugin/my modification of your plugin)! :-) The last version of fox.jason.prismjs causes the problem, there is already an issue created: https://github.com/jason-fox/fox.jason.prismjs/issues/3. With an older version of fox.jason.prismjs, there is no problem and I can have highlighted code and PlantUML diagrams rendered from markdown within the same topic. :-)

I will create a GitHub account to report further information to the issue.
And while I am on GitHub already:
Are you interested in the PlantUML transformation from markdown? Should I then fork the com.oxygenxml.plantuml.svg repo and create a pull request with my changes?

Best regards
Alex

Radu Coravu

unread,
Mar 4, 2021, 9:46:00 AM3/4/21
to Alex, DITA-OT Users
Hi Alex,

I'm glad you found the problem. If you want to contribute changes to my original plugin project, they are welcomed. I can consider the changes only if they are not specific to your workflows, if they can benefit more people and if you explain in the pull request why they are useful maybe with some examples.

Regards,
Radu

Reply all
Reply to author
Forward
0 new messages