Newer
Older
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mermaid.R
\name{mermaid}
\alias{mermaid}
\alias{mermaid_gen_link}
\title{Generate a file from a mermaid diagram}
\usage{
mermaid(
diagram,
format = "png",
theme = "default",
file.dest = file.path(tempdir(), paste0(rlang::hash(link), ".", format)),
link = mermaid_gen_link(diagram, theme = theme, format = format)
mermaid_gen_link(
diagram,
theme = "default",
format = "png",
server = "https://mermaid.ink"
)
}
\arguments{
\item{diagram}{Diagram in mermaid markdown-like language or file (as a connection or file name) containing a diagram specification}
\item{format}{Image format (either \code{"jpg"}, or \code{"png"}, or \code{"svg"})}
\item{theme}{Mermaid theme (See https://mermaid.js.org/config/theming.html#available-themes)}
\item{file.dest}{Path to the downloaded image}
\item{link}{Link generated by \link{mermaid_gen_link}}
\item{server}{URL of the server used to generate the link}
}
\value{
The path to the downloaded image.
}
\description{
This function download the file from https://mermaid.ink which generates the image.
The file is downloaded only if it does not already exist.
}
\details{
Use this function with \link[knitr:include_graphics]{knitr::include_graphics} to display a mermaid diagram
in a Rmarkdown document. Compared to the \code{diagrammeR::mermaid} function, the
generated image is not a HTMLwidget and can be knit in pdf through latex and
moreover, its size can be controlled with \code{fig.width} and \code{fig.height}.
}
\examples{
diagram <- "flowchart LR\n A --> B"
mermaid_gen_link(diagram)
f <- mermaid(diagram)
f
\dontrun{
# For displaying the diagram in Rmarkdown document
knitr::include_graphics(mermaid(diagram))
}
# Clean temporary folder
unlink(f)
}