mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
feat(image): added support for mermaid diagrams in markdown
This commit is contained in:
parent
5a37d83897
commit
f8e7942d6c
5 changed files with 54 additions and 1 deletions
|
@ -129,6 +129,23 @@ function M.convert(src, opts)
|
|||
args = { "-density", 300, "src", "-trim" },
|
||||
})
|
||||
return png, Spawn.multi(procs, opts)
|
||||
elseif ext == "mmd" then
|
||||
return png,
|
||||
M.generate(png, vim.deepcopy(opts), {
|
||||
cmd = "mmdc",
|
||||
args = {
|
||||
"-i",
|
||||
src,
|
||||
"-o",
|
||||
png,
|
||||
"-b",
|
||||
"transparent",
|
||||
"-t",
|
||||
vim.o.background,
|
||||
"-s",
|
||||
Snacks.image.terminal.size().scale,
|
||||
},
|
||||
})
|
||||
end
|
||||
end
|
||||
opts.args = {
|
||||
|
@ -150,7 +167,7 @@ function M.convert(src, opts)
|
|||
"-trim",
|
||||
}
|
||||
end
|
||||
return png, Spawn.multi({ M.magick(src, png, opts) }, opts)
|
||||
return png, M.magick(src, png, opts)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -261,6 +261,12 @@ function M.health()
|
|||
Snacks.health.warn("`tectonic` or `pdflatex` is required to render LaTeX math equations")
|
||||
end
|
||||
|
||||
if Snacks.health.have_tool("mmdc") then
|
||||
Snacks.health.ok("Mermaid diagrams are supported")
|
||||
else
|
||||
Snacks.health.warn("`mmdc` is required to render Mermaid diagrams")
|
||||
end
|
||||
|
||||
if env.supported then
|
||||
Snacks.health.ok("your terminal supports the kitty graphics protocol")
|
||||
elseif M.config.force then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue