docs for muutils v0.6.17
View Source on GitHub

# muutils.nbutils.mermaid

display mermaid.js diagrams in jupyter notebooks by the `mermaid.ink/img` service

View Source
View on GitHub

     1"""display mermaid.js diagrams in jupyter notebooks by the `mermaid.ink/img` service"""
     2
     3import base64
     4
     5try:
     6    from IPython.display import Image, display
     7except ImportError:
     8    import warnings
     9
    10    warnings.warn(
    11        "IPython.display could not be imported, mermaid will not work", ImportWarning
    12    )
    13
    14
    15def mm(graph):
    16    """for plotting mermaid.js diagrams"""
    17    graphbytes = graph.encode("ascii")
    18    base64_bytes = base64.b64encode(graphbytes)
    19    base64_string = base64_bytes.decode("ascii")
    20    display(Image(url="https://mermaid.ink/img/" + base64_string))

def mm(graph):
View Source
View on GitHub

    16def mm(graph):
    17    """for plotting mermaid.js diagrams"""
    18    graphbytes = graph.encode("ascii")
    19    base64_bytes = base64.b64encode(graphbytes)
    20    base64_string = base64_bytes.decode("ascii")
    21    display(Image(url="https://mermaid.ink/img/" + base64_string))

for plotting mermaid.js diagrams