Skip to content

Fold convert-aasvg.lua into convert-diagrams.lua #247

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

Merged
merged 1 commit into from
May 16, 2025
Merged
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
3 changes: 0 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,6 @@ do_latex() {
--highlight-style=${SYNTAX_HIGHLIGHT_STYLE}
--template=${TEMPLATE_PDF}
--lua-filter=convert-diagrams.lua
--lua-filter=convert-aasvg.lua
--lua-filter=convert-images.lua
--lua-filter=center-images.lua
--lua-filter=informative-sections.lua
Expand Down Expand Up @@ -883,7 +882,6 @@ do_docx() {
--embed-resources
--standalone
--lua-filter=convert-diagrams.lua
--lua-filter=convert-aasvg.lua
--lua-filter=convert-images.lua
--lua-filter=parse-html.lua
--lua-filter=apply-classes-to-tables.lua
Expand Down Expand Up @@ -927,7 +925,6 @@ do_html() {
--template=${TEMPLATE_HTML}
${HTML_STYLESHEET_ARGS}
--lua-filter=convert-diagrams.lua
--lua-filter=convert-aasvg.lua
--lua-filter=parse-html.lua
--lua-filter=apply-classes-to-tables.lua
--lua-filter=landscape-pages.lua
Expand Down
63 changes: 0 additions & 63 deletions filter/convert-aasvg.lua

This file was deleted.

13 changes: 10 additions & 3 deletions filter/convert-diagrams.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Turn mermaid and plantuml code blocks into figures, retaining other classes
-- on the code block as classes on the figure.
-- Turn aasvg, mermaid, or plantuml code blocks into figures, retaining
-- other classes on the code block as classes on the figure.

-- Patch the path to include the current script's directory.
package.path = package.path .. ";" .. debug.getinfo(1).source:match("@?(.*/)") .. "?.lua"
Expand Down Expand Up @@ -71,6 +71,10 @@ function convertFigure(code, caption, attrs, extension, convert_command)
return pandoc.Figure(img, caption, attrs)
end

function aasvgFigure(code, caption, attrs)
return convertFigure(code, caption, attrs, ".aasvg.svg", "aasvg --fill > %s 2>&1")
end

function mermaidFigure(code, caption, attrs)
return convertFigure(code, caption, attrs, mermaid_extension[FORMAT] or mermaid_extension["pdf"],
"mmdc --configFile /resources/filters/mermaid-config.json --puppeteerConfigFile ./.puppeteer.json --width 2000 --height 2000 --backgroundColor transparent --pdfFit --input - --output %s 2>&1")
Expand All @@ -86,7 +90,7 @@ function CodeBlock(el)

local figure_classes = pandoc.List({})
for i, class in ipairs(el.classes) do
if class == 'mermaid' or class == 'plantuml' then
if class == 'aasvg' or class == 'mermaid' or class == 'plantuml' then
diagramType = class
else
figure_classes:insert(class)
Expand All @@ -97,6 +101,9 @@ function CodeBlock(el)
local caption = {long = pandoc.Plain(pandoc.Str(el.attributes.caption))}
local attrs = pandoc.Attr(el.identifier, figure_classes)

if diagramType == 'aasvg' then
return aasvgFigure(el.text, caption, attrs)
end
if diagramType == 'mermaid' then
return mermaidFigure(el.text, caption, attrs)
end
Expand Down
2 changes: 1 addition & 1 deletion guide.tcg
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ Users are encouraged to use AES instead.

# Figures {#sec:figures}

There are various ways to include a figure in a document: as an image file checked into the repository, as a [Mermaid](http://mermaid.js.org) diagram, and as an [aasvg](https://github.com/martinthomson/aasvg) diagram.
There are various ways to include a figure in a document: as an image file checked into the repository, or as a [Mermaid](http://mermaid.js.org) or [PlantUML](https://plantuml.com) or [aasvg](https://github.com/martinthomson/aasvg) diagram.

## Images

Expand Down
Loading