Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/PlutoUI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ include("./Resource.jl")
include("./Terminal.jl")
include("./RangeSlider.jl")
include("./DisplayTricks.jl")
include("./UML.jl")

@reexport module TableOfContentsNotebook
include("./TableOfContents.jl")
Expand Down
34 changes: 34 additions & 0 deletions src/UML.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export UML

"""
Creates an UML diagram using [Mermaid.js](https://mermaid-js.github.io/mermaid/#/)

Diagrams are specified using Markdown code following the syntax described [here](https://mermaid-js.github.io/mermaid/#/).

Example:

UML(\"\"\"
graph LR
A --- B
B-->C[fa:fa-ban forbidden]
B-->D(fa:fa-spinner)
B-->E-->F---G
\"\"\")
"""
struct UML
code:: String
end

function show(io::IO, ::MIME"text/html", uml::UML)
print(io, """
<!DOCTYPE html>
<body>
<div class="mermaid">
$(uml.code)
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js"></script>
<script>mermaid.initialize({startOnLoad:true});</script>
</body>
</html>
""")
end