Skip to content

Instantly share code, notes, and snippets.

@noamtamim
Last active April 24, 2026 05:49
Show Gist options
  • Select an option

  • Save noamtamim/f11982b28602bd7e604c233fbe9d910f to your computer and use it in GitHub Desktop.

Select an option

Save noamtamim/f11982b28602bd7e604c233fbe9d910f to your computer and use it in GitHub Desktop.

Revisions

  1. noamtamim revised this gist Jul 11, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions sample.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,14 @@
    Regular **Markdown** here.

    <div hidden>

    @startuml firstDiagram

    Alice -> Bob: Hello
    Bob -> Alice: Hi!

    @enduml

    </div>

    ![](firstDiagram.svg)
  2. noamtamim revised this gist Jul 11, 2019. 1 changed file with 4 additions and 6 deletions.
    10 changes: 4 additions & 6 deletions sample.md
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,12 @@
    Regular **Markdown** here.

    <div hidden>
    ```
    @startuml firstDiagram
    @startuml firstDiagram

    Alice -> Bob: Hello
    Bob -> Alice: Hi!
    Alice -> Bob: Hello
    Bob -> Alice: Hi!

    @enduml
    ```
    @enduml
    </div>

    ![](firstDiagram.svg)
  3. noamtamim created this gist Jul 11, 2019.
    57 changes: 57 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,57 @@
    # How to use PlantUML with Markdown

    [PlantUML](http://plantuml.com/) is a really awesome way to create diagrams by writing code instead of drawing and dragging visual elements. Markdown is a really nice documentation tool.

    Here's how I combine the two, to create docs with embedded diagrams.

    ## Step 0: Setup

    Get the command-line PlantUML from [the download page](http://plantuml.com/download) or your relevant package manager.

    ## Step 1: Create a Markdown file

    Use your favorite markdown or text editor. Most (if not all) developer-oriented text editors have some kind of markdown support.

    Remember that md files can contain html, and that html is passed-through to the generated html as-is.

    When you want to embed a diagram, create a hidden div: `<div hidden>`.

    Now start a code block by indenting or typing 3 backticks. The first line of the code block must be `@startuml` followed by a file name (with no extension). The following lines should be the actual diagram code, ending with `@enduml`. End the code block and close the div.

    Finally, to actually show the diagram in the document, add an image in markdown:
    ```![](firstDiagram.svg)```. The name must be the same name as in the `@startuml` command, with a `.svg` extension.

    ### All together now

    Regular **Markdown** here.

    <div hidden>
    ```
    @startuml firstDiagram

    Alice -> Bob: Hello
    Bob -> Alice: Hi!
    @enduml
    ```
    </div>

    ![](firstDiagram.svg)

    Some more markdown.

    ## Step 2: Run PlantUML on the Markdown file

    On the command line:

    plantuml -tsvg FILENAME

    Where FILENAME is the name of the markdown file.

    For every PlantUML block in the file, one svg diagram is generated. When the markdown to html converter is running, the html will contain image links to the generated images.

    ## Step 3: Convert locally to HTML or upload to GitHub

    If you host the files in GitHub (or other services that convert md to html on the fly), the last step is uploading or pushing the files. Make sure to include everything: the markdown and the generated diagrams.

    Otherwise, use your favorite tool for converting markdown to html - a markdown editor or a command line tool.
    19 changes: 19 additions & 0 deletions firstDiagram.svg
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
    16 changes: 16 additions & 0 deletions sample.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    Regular **Markdown** here.

    <div hidden>
    ```
    @startuml firstDiagram
    Alice -> Bob: Hello
    Bob -> Alice: Hi!
    @enduml
    ```
    </div>

    ![](firstDiagram.svg)

    Some more markdown.