All Projects → raghur → Mermaid Filter

raghur / Mermaid Filter

Pandoc filter for creating diagrams in mermaid syntax blocks in markdown docs

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Mermaid Filter

Pandoc Plot
Render and include figures in Pandoc documents using your plotting toolkit of choice
Stars: ✭ 75 (-59.24%)
Mutual labels:  pandoc
Pandiff
Prose diffs for any document format supported by Pandoc
Stars: ✭ 110 (-40.22%)
Mutual labels:  pandoc
Webpages To Ebook
Create an EPUB from a list of URLs. Standing on the shoulders of Wget, Readability and Pandoc.
Stars: ✭ 155 (-15.76%)
Mutual labels:  pandoc
Pandoc Letter Din5008
Pandoc template for writing Markdown letters (DIN 5008)
Stars: ✭ 77 (-58.15%)
Mutual labels:  pandoc
Markdown Cv
Simple Markdown CV / Resume
Stars: ✭ 97 (-47.28%)
Mutual labels:  pandoc
Patat
Terminal-based presentations using Pandoc
Stars: ✭ 1,725 (+837.5%)
Mutual labels:  pandoc
Markdeck
presentations as code - author cool slide decks, text-only, offline-ready, collaborative
Stars: ✭ 1,159 (+529.89%)
Mutual labels:  pandoc
Pandoc Goodies
A tresure-box of resources for pandoc, pp and Texts word processor.
Stars: ✭ 167 (-9.24%)
Mutual labels:  pandoc
Oscp Exam Report Template Markdown
📙 Markdown Templates for Offensive Security OSCP, OSWE, OSCE, OSEE, OSWP exam report
Stars: ✭ 2,066 (+1022.83%)
Mutual labels:  pandoc
Dots
Personal *nix configuration files
Stars: ✭ 136 (-26.09%)
Mutual labels:  pandoc
Pandoc Sidenote
Convert Pandoc Markdown-style footnotes into sidenotes
Stars: ✭ 78 (-57.61%)
Mutual labels:  pandoc
Science.md
An easy framework for drafting scientific documents: Write (Markdown), Compile (PDF, Word, HTML), Share.
Stars: ✭ 90 (-51.09%)
Mutual labels:  pandoc
Pandoc Action Example
using the pandoc document converter on GitHub Actions
Stars: ✭ 131 (-28.8%)
Mutual labels:  pandoc
Ieee Pandoc Template
IEEE paper template for pandoc
Stars: ✭ 76 (-58.7%)
Mutual labels:  pandoc
Dockerfiles
Dockerfiles for various pandoc images
Stars: ✭ 158 (-14.13%)
Mutual labels:  pandoc
Libpandoc
C bindings to Pandoc, a markup converter library written in Haskell.
Stars: ✭ 70 (-61.96%)
Mutual labels:  pandoc
Org Pandoc Import
Save yourself from non-org formats, thanks to pandoc
Stars: ✭ 111 (-39.67%)
Mutual labels:  pandoc
Rmarkdown
Dynamic Documents for R
Stars: ✭ 2,319 (+1160.33%)
Mutual labels:  pandoc
Awesome Scientific Writing
⌨️ A curated list of awesome tools, demos and resources to go beyond LaTeX
Stars: ✭ 162 (-11.96%)
Mutual labels:  pandoc
Pandoc Markdown Template
Markdown templates for Pandoc
Stars: ✭ 135 (-26.63%)
Mutual labels:  pandoc

Sequence and Graph diagrams in your markdown files!

mermaid-filter is a pandoc filter that adds support for mermaid syntax diagrams in markdown.

Write your diagrams in fenced code blocks as usual like this:

~~~mermaid
sequenceDiagram
    Alice->>John: Hello John, how are you?
    John-->>Alice: Great!
~~~

and get this in rendered doc

Installation and usage

  1. npm install --global mermaid-filter
  2. To convert your markdown file something.md into something.html, use pandoc -t html -F mermaid-filter -o something.html something.md

WINDOWS - you need mermaid-filter.cmd in the line above

Windows 8.1 - On windows 8.1, mermaid-filter.cmd fails - apparently due to change in how the CMD.exe works for subprocesses? - see this issue thread. You have to edit the globally installed mermaid-filter.cmd located in c:\users\<username>\AppData\Roaming\npm to use ~dp$PATH:0. Unfortunately, you will need to do this each time you install/update mermaid-filter since it overwrites the cmd file.

Options

You have a couple of formatting options via attributes of the fenced code block to control the rendering

  • Pandoc caption, the filename is this value cleaned up - Use {.mermaid caption="Caption Text Here"}
  • Image Format - Use {.mermaid format=svg} Default is png
  • Width - Use {.mermaid width=400} default width is 800
  • Theme - Use {.mermaid theme=forest} default is 'default'. Corresponds to --theme flag of mermaid.cli
  • Filename - Use {.mermaid filename="file with space"} to set the filename. This has priority over the caption
  • Save path - Use {.mermaid loc=img} default loc=inline which will encode the image in a data uri scheme.
    • Possible values for loc
      • loc=inline - default; encode image to data uri on img tag.
        • For widest compatibility, use png (default)
        • SVG has trouble on IE11
      • loc=imgur - upload png to imgur and link to it.
      • loc=<anythingelse> -treat as folder name to place images into

Note that to specify options, you need to use the curly braces syntax and have the .mermaid class attached. Admittedly, this is uglier than the earlier syntax on top - but that's how Pandoc wants it.

It's also possible to override global defaults by using environment variables. The name for these environment variables are the same as the attributes prefixed with a MERMAID_FILTER_ so that width would be MERMAID_FILTER_WIDTH.

You can also specify an ID to be applied to the rendered image. This may be useful to use pandoc-crossref or similar packages to reference your diagrams, for example:

```{.mermaid #fig:example}
// Your diagram code here
```

This text has a reference @fig:example which is automatically inserted.

(Note that pandoc-crossref will automatically find and use the caption= option. Also note that the order of applying the filters matters - you must apply mermaid-filter before pandoc-crossref so that pandoc-crossref can find the images.)

JSON and CSS configuration

Mermaid cli allows you to specify additional options in a json configuration file and a css file. mermaid-filter will look in the current working directory for .mermaid-config.json and .mermaid.css and if found, pass them in to mermaid cli.

Puppeteer Configuration - mermaid-filter will look in the current working directory for a .puppeteer.json and pass it on to mermaid cli (-p option of mmdc)if found

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].