RobertWeinmeister / dokuwiki-mermaid

A plugin for DokuWiki to support Mermaid.
GNU General Public License v2.0
3 stars 0 forks source link

# Mermaid Plugin for DokuWiki

This is a plugin for Dokuwiki. It provides support for the diagramming tool Mermaid. Mermaid is a JavaScript based diagramming and charting tool that renders Markdown-inspired text definitions to create and modify diagrams dynamically.

  1. Installation
  2. Basic example
  3. Further Functionality
  4. Configuration and Settings
  5. Known Problems
  6. Further Information
  7. License

Installation

Install the plugin using the Dokuwiki Plugin Manager. Refer to Plugins on how to install plugins manually.

Basic example

Provide the Mermaid code enclosed by the <mermaid> tags:

<mermaid>
  graph TD
    A(**mermaid**)-->B((__plugin__))
    A-->C(((//for//)))
    B-->D[["[[https://www.dokuwiki.org/dokuwiki|Dokuwiki]]"]]
    C-->D
</mermaid>

This will be rendered by the plugin and shown as:

The diagram as provided by Mermaid

For more examples and details on the Mermaid syntax, see https://mermaid.js.org/intro/.

Further Functionality

Size Adjustmens

The width and height of the container of the diagram can be adjusted using

<mermaid #width #height>

where #width and #height can take any value supported by CSS, for example:

<mermaid 100% 1cm>

Raw mode

If needed, the Mermaid code can be passed on without any processing or rendering by DokuWiki. Insert a line containing only the word raw before the Mermaid code.

<mermaid>
  raw
  graph TD
    A(**mermaid**)-->B((__plugin__))
    A-->C(((//for//)))
    B-->D[["[[https://www.dokuwiki.org/dokuwiki|Dokuwiki]]"]]
    C-->D
</mermaid>

This allows to use the full feature set of Mermaid without interference from DokuWiki, albeit at the expanse of not being able to use any functionality provided by DokuWiki.

🆕 Exporting Diagrams

To export a diagram, simply hover your mouse over the diagram to reveal the Save button. Clicking it will allow you to download the diagram in SVG format, preserving the exact appearance as rendered by Mermaid.

🆕 🧪 No Client Side Diagram Conversion

By default, Mermaid diagrams are converted from Mermaid syntax to SVG on the client side. To change this to get the SVG directly form the server, simply hover your mouse over the diagram to reveal the Lock button. Clicking it will include the SVG directly in a new page revision, eliminating the need for client-side transformation.

This can be useful for archiving pages or for use with other plugins that do not work with client side changes like dw2pdf.

To unlock and edit the diagram again, hover over it to reveal the Unlock button. Clicking it will remove the embedded SVG in a new page revision, allowing for further modification.

Configuration and Settings

No further configuration is required.

Version and Location

You can choose which Mermaid version you want to use:

Default theme

You can choose which Mermaid theme should be used as a default. The available themes are the five integrated themes of Mermaid.

Known Problems

Allmost all of the DokuWiki syntax is supported. In rare cases it can clash with the syntax of Mermaid. If you encounter any problems, feel free to report them and open an issue.

You can sidestep these problems by using the raw mode which disables the processing by DokuWiki, or adjust your Mermaid code as shown below.

Usage of Brackets

Mermaid and DokuWiki both use brackets. If you need to use them both at the same time, make your intentions clear by using quotation marks like ["[[link]]"].

Binding Click Events

Mermaid supports the binding of click events. This can and will clash with DokuWikis own handling of links. In general, use DokuWiki style links instead of click events, i. e. instead of

<mermaid>
  flowchart TD
    A[Link]
    click A "https://www.github.com"
</mermaid>

please use

<mermaid>
  flowchart TD
    A["[[https://www.github.com|Link]]"]
</mermaid>

DokuWiki Search Highlight

The search highlight of the DokuWiki search can prevent the proper parsing of the diagram, leading to an error. For that reason, it is disabled for the Mermaid diagrams. The search itself is not affected.

Further Information

Mermaid supports multiple other diagrams besides the shown flowchart, for example:

For more information, see https://mermaid.js.org/intro/.

License

This project is licensed under the GNU General Public License v2.0. See the LICENSE file for details.

Mermaid is licensed under the MIT License. See the LICENSE Mermaid file for details.