Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for blockdiag actdiag nwdiag packetdiag rackdiag seqdiag #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
55 changes: 50 additions & 5 deletions _extensions/diagram/diagram.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,45 @@ local mermaid = {
end,
}

-- blockdiag engine
-- supports blockdiag actdiag nwdiag packetdiag rackdiag seqdiag
-- sudo pip install blockdiag actdiag nwdiag seqdiag
-- see http://blockdiag.com/
local blockdiag = {
line_comment_start = '//',
mime_types = mime_types_set{'pdf', 'png', 'svg'},
execpath = 'blockdiag',
compile = function (self, code)
local mime_type = self.mime_type or 'image/svg+xml'
local format = extension_for_mimetype[mime_type]
return with_temporary_directory("diagram", function (tmpdir)
return with_working_directory(tmpdir, function ()
local infile = 'diagram.diag'
local outfile = 'diagram.' .. format
write_file(infile, code)
pandoc.pipe(self.execpath, {"-T", format, infile, "-o", outfile}, '')
return read_file(outfile), mime_type
end)
end)
end,
}

local function newdiag(diag)
d = {}
for k, v in pairs(blockdiag) do
d[k] = v
end
d.execpath = diag
diag = d
return diag
end

local actdiag = newdiag('actdiag')
local nwdiag = newdiag('nwdiag')
local packetdiag = newdiag('packetdiag')
local rackdiag = newdiag('rackdiag')
local seqdiag = newdiag('seqdiag')

--- TikZ
--

Expand Down Expand Up @@ -223,11 +262,17 @@ local asymptote = {
}

local default_engines = {
asymptote = asymptote,
dot = graphviz,
mermaid = mermaid,
plantuml = plantuml,
tikz = tikz,
asymptote = asymptote,
dot = graphviz,
mermaid = mermaid,
plantuml = plantuml,
tikz = tikz,
blockdiag = blockdiag,
actdiag = actdiag,
nwdiag = nwdiag,
packetdiag = packetdiag,
rackdiag = rackdiag,
seqdiag = seqdiag,
}

--
Expand Down