Skip to content

Commit aa3fc36

Browse files
authored
diagram-generator: Avoid Inkscape 1.0 deprecation warnings (#227)
Update the arguments to Inkscape, to be in line with new current Inkscape argument formats (introduced in Inkscape 1.0, released May 2020). Updating these arguments avoids the following deprecation warnings (which are safe to ignore, but annoying): Warning: Option --without-gui= is deprecated Warning: Option --file= is deprecated and Warning: Option --export-plain-svg= is deprecated if the format is svg, or Warning: Option --export-png= is deprecated if the format is png.
1 parent 97f63d0 commit aa3fc36

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

diagram-generator/diagram-generator.lua

+14-3
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,27 @@ local tikz_template = [[
150150
local function convert_with_inkscape(filetype)
151151
-- Build the basic Inkscape command for the conversion
152152
local inkscape_output_args
153+
154+
-- Check inksape version.
155+
-- TODO: this can be removed if supporting older Inkscape is not important.
156+
local inkscape_v_string = io.popen(inkscape_path .. " --version"):read()
157+
local inkscape_v_major = inkscape_v_string:gmatch("([0-9]*)%.")()
158+
local isv1 = tonumber(inkscape_v_major) >= 1
159+
160+
local cmd_arg = isv1 and '"%s" "%s" -o "%s" ' or '"%s" --without-gui --file="%s" '
161+
153162
if filetype == 'png' then
154-
inkscape_output_args = '--export-png="%s" --export-dpi=300'
163+
local png_arg = isv1 and '--export-type=png' or '--export-png="%s"'
164+
output_args = png_arg .. '--export-dpi=300'
155165
elseif filetype == 'svg' then
156-
inkscape_output_args = '--export-plain-svg="%s"'
166+
output_args = isv1 and '--export-type=svg --export-plain-svg' or '--export-plain-svg="%s"'
157167
else
158168
return nil
159169
end
170+
160171
return function (pdf_file, outfile)
161172
local inkscape_command = string.format(
162-
'"%s" --without-gui --file="%s" ' .. inkscape_output_args,
173+
cmd_arg .. output_args,
163174
inkscape_path,
164175
pdf_file,
165176
outfile

0 commit comments

Comments
 (0)