Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: accept markdown format like this: ```mermaid (also plantuml in the similar format) #13

Open
SmartLayer opened this issue Jul 21, 2023 · 1 comment

Comments

@SmartLayer
Copy link

SmartLayer commented Jul 21, 2023

I am unsure whether this request should be filed with https://github.com/vsch/flexmark-java or this project. The feature requested is to enable support for Mermaid, and PlantUML in the github/gitlab format.

Sample PlantUML/Kroki/Mermaid codes can be found in this gitlab link.

This request is not because I dislike the <foreign> tag, but rather because having the ability to render diagrams on github/gitlab is crucial for workflows based on their features.

For comparison, examples of using <foreign> versus using the github format are here:

Using github format:
https://github.com/TokenScript/documents/blob/6604b1453c7845ddf84aa475928a261290c56893/src/usecase/guide/air.cab.md#instantiation-process

Using <foreign> format:
https://github.com/TokenScript/documents/blob/50d775de825502a2a42f6a0da7115ebc5c152a73/src/usecase/guide/air.cab.md#instantiation-process

@SmartLayer SmartLayer changed the title accept mermaid and plantuml accept ```mermaid Jul 21, 2023
@SmartLayer SmartLayer changed the title accept ```mermaid accept ```mermaid (also plantuml in the similar format) Jul 21, 2023
@SmartLayer SmartLayer changed the title accept ```mermaid (also plantuml in the similar format) Feature Request: accept markdown format like this: ```mermaid (also plantuml in the similar format) Jul 21, 2023
@raducoravu
Copy link
Collaborator

This particular "dita-ot-diagrams-plugin" plugin adds xslt processing which matches the DITA XML "foreign" element with various output class values and produces the diagrams from it.

When you have Markdown content referenced in a DITA Map, the DITA Open Toolkit has a pre-installed plugin:
https://github.com/jelovirt/org.lwdita
The job of this "org.lwdita" plugin is to dynamically convert Markdown to DITA XML content while publishing. It uses the Flexmark engine to accomplish this.
So my "dita-ot-diagrams-plugin" plugin applies its processing later on in the publishing stage, when the Markdown has been converted to DITA XML by the "org.lwdita".

I tried this experiment:

  1. Created a DITA Map which refers to a Markdown file containing a small Plantuml graph inside in Markdown format:

         # Title
         
         Text
         ```plantuml
         Alice -> Bob: Authentication Request
         Bob --> Alice: Authentication Response
         
         Alice -> Bob: Another authentication Request
         Alice <-- Bob: Another authentication Response
         ```
    
  2. Published the DITA Map to HTML5 setting the "clean.temp=no" parameter.

  3. After publishing I looked in the transformation temporary files folder and the original Markdown file was converted to this:

         <topic ...>
             <title..>Title</title..>
             <body ..>
                 <p ..>Text</p>
                 <codeblock class="+ topic/pre pr-d/codeblock " xml:space="preserve" outputclass="plantuml" ...>Alice -&gt; Bob: Authentication Request
         Bob --&gt; Alice: Authentication Response
         
         Alice -&gt; Bob: Another authentication Request
         Alice &lt;-- Bob: Another authentication Response</codeblock>
             </body>
         </topic>
    

So the "org.lwdita" plugin converts the plantuml embedded content to a DITA XML codeblock with a certain @outputclass attribute value. But my plugin matches "foreign" with a certain @outputclass value.
So maybe the XSLT templates in my plugin can be made more flexible like:

https://github.com/oxygenxml/dita-ot-diagrams-plugin/blob/master/com.oxygenxml.diagrams.svg/xsl/xhtmlSVG.xsl

 <xsl:template match="*[contains(@class, ' topic/foreign ')][contains(@outputclass, 'embed-plant-uml')] | *[contains(@class, ' topic/plant-uml ')]" priority="10">

could be replaced with:

  <xsl:template match="*[contains(@class, ' topic/foreign ')][contains(@outputclass, 'embed-plant-uml')] | *[contains(@class, ' topic/plant-uml ')] | *[contains(@class, ' pr-d/codeblock ')][contains(@outputclass, 'plantuml')]" priority="10">

so that it also matches codeblocks with a certain outputclass value.
Maybe you can experiment with this and open a pull request if it works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants