Hi,

another thing which surfaced during my review is that we still ship
check for pre-2020 inkscape which add complexity to the code.

I think it's time to kill it. Any objections?

Pavel
diff --git a/lib/configure.py b/lib/configure.py
index 5f53d135c7..fbbbca51ef 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -651,19 +651,6 @@ def checkInkscape():
                 return 'inkscape'
 
 
-def checkInkscapeStable():
-    ''' Check whether we use Inkscape >= 1.0 '''
-    inkscape_bin = inkscape_cl
-    if os.name == 'nt':
-        # Windows needs the full path, quoted if it contains spaces
-        inkscape_bin = quoteIfSpace(os.path.join(inkscape_path, inkscape_cl))
-    version_string = cmdOutput(inkscape_bin + " --version")
-    if version_string.find(' 0.') > 0:
-        return False
-    else:
-        return True
-
-
 def checkDrawIO(progName, WinLMkey):
     # Returns a list of additional paths to search for binary draw.io
     # (draw.io inside of draw.io.app contents in the case of MacOS)
@@ -1170,22 +1157,13 @@ def checkConverterEntries():
 \converter fig        pdftex     "$${python} $$s/scripts/fig2pdftex.py $$i $$o"	""
 \converter fig        pstex      "$${python} $$s/scripts/fig2pstex.py $$i $$o"	""''')
     #
-    if inkscape_stable:
-        checkProg('a SVG -> PDFTeX converter', [inkscape_cl],
-            rc_entry = [ r'\converter svg        pdftex     "$${python} $$s/scripts/svg2pdftex.py %% $$p$$i $$p$$o" ""'],
-            path = [inkscape_path])
-        #
-        checkProg('a SVG -> PSTeX converter', [inkscape_cl],
-            rc_entry = [ r'\converter svg        pstex     "$${python} $$s/scripts/svg2pstex.py %% $$p$$i $$p$$o" ""'],
-            path = [inkscape_path])
-    else:
-        checkProg('a SVG -> PDFTeX converter', [inkscape_cl],
-            rc_entry = [ r'\converter svg        pdftex     "$${python} $$s/scripts/svg2pdftex.py --unstable %% $$p$$i $$p$$o" ""'],
-            path = [inkscape_path])
-        #
-        checkProg('a SVG -> PSTeX converter', [inkscape_cl],
-            rc_entry = [ r'\converter svg        pstex     "$${python} $$s/scripts/svg2pstex.py --unstable %% $$p$$i $$p$$o" ""'],
-            path = [inkscape_path])
+    checkProg('a SVG -> PDFTeX converter', [inkscape_cl],
+        rc_entry = [ r'\converter svg        pdftex     "$${python} $$s/scripts/svg2pdftex.py %% $$p$$i $$p$$o" ""'],
+        path = [inkscape_path])
+    #
+    checkProg('a SVG -> PSTeX converter', [inkscape_cl],
+        rc_entry = [ r'\converter svg        pstex     "$${python} $$s/scripts/svg2pstex.py %% $$p$$i $$p$$o" ""'],
+        path = [inkscape_path])
     #
     checkProg('a TIFF -> PS converter', ['tiff2ps $$i > $$o'],
         rc_entry = [ r'\converter tiff       eps        "%%"	""'])
@@ -1196,31 +1174,18 @@ def checkConverterEntries():
 \converter tgif       png        "tgif -print -color -png -o $$d $$i"	""
 \converter tgif       pdf6       "tgif -print -color -pdf -stdout $$i > $$o"	""'''])
     #
-    # inkscape 1.0 has changed cl options
-    if inkscape_stable:
-        checkProg('a WMF -> EPS converter', ['metafile2eps $$i $$o', 'wmf2eps -o $$o $$i', inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
-            rc_entry = [ r'\converter wmf        eps        "%%"	""'])
-        #
-        checkProg('an EMF -> EPS converter', ['metafile2eps $$i $$o', inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
-            rc_entry = [ r'\converter emf        eps        "%%"	""'])
-        #
-        checkProg('a WMF -> PDF converter', [inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
-            rc_entry = [ r'\converter wmf        pdf6        "%%"	""'])
-        #
-        checkProg('an EMF -> PDF converter', [inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
-            rc_entry = [ r'\converter emf        pdf6        "%%"	""'])
-    else:
-        checkProg('a WMF -> EPS converter', ['metafile2eps $$i $$o', 'wmf2eps -o $$o $$i', inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-eps=$$o'],
-            rc_entry = [ r'\converter wmf        eps        "%%"	""'])
-        #
-        checkProg('an EMF -> EPS converter', ['metafile2eps $$i $$o', inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-eps=$$o'],
-            rc_entry = [ r'\converter emf        eps        "%%"	""'])
-        #
-        checkProg('a WMF -> PDF converter', [inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-pdf=$$o'],
-            rc_entry = [ r'\converter wmf        pdf6        "%%"	""'])
-        #
-        checkProg('an EMF -> PDF converter', [inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-pdf=$$o'],
-            rc_entry = [ r'\converter emf        pdf6        "%%"	""'])
+    # inkscape 1.0 changed the cl options (LyX now requires >= 1.0)
+    checkProg('a WMF -> EPS converter', ['metafile2eps $$i $$o', 'wmf2eps -o $$o $$i', inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
+        rc_entry = [ r'\converter wmf        eps        "%%"	""'])
+    #
+    checkProg('an EMF -> EPS converter', ['metafile2eps $$i $$o', inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
+        rc_entry = [ r'\converter emf        eps        "%%"	""'])
+    #
+    checkProg('a WMF -> PDF converter', [inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
+        rc_entry = [ r'\converter wmf        pdf6        "%%"	""'])
+    #
+    checkProg('an EMF -> PDF converter', [inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
+        rc_entry = [ r'\converter emf        pdf6        "%%"	""'])
     # Only define a converter to pdf6 for graphics
     checkProg('an EPS -> PDF converter', ['epstopdf'],
         rc_entry = [ r'\converter eps        pdf6       "epstopdf --outfile=$$o $$i"	""'])
@@ -1276,12 +1241,8 @@ def checkConverterEntries():
 
     if not have_png2eps:
         #try inkscape instead.
-        if inkscape_stable:
-            checkProg('an alternative PNG -> EPS converter', [inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
-                rc_entry = [ r'\converter png        eps        "%%"	""'])
-        else:
-            checkProg('an alternative PNG -> EPS converter', [inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-eps=$$o'],
-                rc_entry = [ r'\converter png        eps        "%%"	""'])
+        checkProg('an alternative PNG -> EPS converter', [inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
+            rc_entry = [ r'\converter png        eps        "%%"	""'])
     #
     # PDF -> PNG: sips (mac), IM convert (windows, linux), pdftoppm (linux with IM ban)
     # sips:Define a converter from pdf6 to png for Macs where pdftops is missing.
@@ -1347,37 +1308,21 @@ def checkConverterEntries():
         rc_entry = [ r'\converter svg        svgz       "%%"	""'])
     # Only define a converter to pdf6 for graphics
     # Prefer rsvg-convert over inkscape since it is faster (see http://www.lyx.org/trac/ticket/9891)
-    # inkscape 1.0 has changed cl options
-    if inkscape_stable:
-        checkProg('a SVG -> PDF converter', ['rsvg-convert -f pdf -o $$o $$i', inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
-            rc_entry = [ r'''\converter svg        pdf6       "%%"    ""
+    # inkscape 1.0 changed the cl options (LyX now requires >= 1.0)
+    checkProg('a SVG -> PDF converter', ['rsvg-convert -f pdf -o $$o $$i', inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
+        rc_entry = [ r'''\converter svg        pdf6       "%%"    ""
 \converter svgz       pdf6       "%%"    ""'''],
-            path = ['', inkscape_path])
-        #
-        checkProg('a SVG -> EPS converter', ['rsvg-convert -f ps -o $$o $$i', inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
-            rc_entry = [ r'''\converter svg        eps        "%%"    ""
+        path = ['', inkscape_path])
+    #
+    checkProg('a SVG -> EPS converter', ['rsvg-convert -f ps -o $$o $$i', inkscape_cl + ' $$i --export-area-drawing --export-filename=$$o'],
+        rc_entry = [ r'''\converter svg        eps        "%%"    ""
 \converter svgz       eps        "%%"    ""'''],
-            path = ['', inkscape_path])
-        #
-        checkProg('a SVG -> PNG converter', ['rsvg-convert -f png -o $$o $$i', inkscape_cl + ' $$i --export-filename=$$o'],
-            rc_entry = [ r'''\converter svg        png        "%%"    "",
+        path = ['', inkscape_path])
+    #
+    checkProg('a SVG -> PNG converter', ['rsvg-convert -f png -o $$o $$i', inkscape_cl + ' $$i --export-filename=$$o'],
+        rc_entry = [ r'''\converter svg        png        "%%"    "",
 \converter svgz       png        "%%"    ""'''],
-            path = ['', inkscape_path])
-    else:
-        checkProg('a SVG -> PDF converter', ['rsvg-convert -f pdf -o $$o $$i', inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-pdf=$$o'],
-            rc_entry = [ r'''\converter svg        pdf6       "%%"    ""
-\converter svgz       pdf6       "%%"    ""'''],
-            path = ['', inkscape_path])
-        #
-        checkProg('a SVG -> EPS converter', ['rsvg-convert -f ps -o $$o $$i', inkscape_cl + ' --file=$$i --export-area-drawing --without-gui --export-eps=$$o'],
-            rc_entry = [ r'''\converter svg        eps        "%%"    ""
-\converter svgz       eps        "%%"    ""'''],
-            path = ['', inkscape_path])
-        #
-        checkProg('a SVG -> PNG converter', ['rsvg-convert -f png -o $$o $$i', inkscape_cl + ' --without-gui --file=$$i --export-png=$$o'],
-            rc_entry = [ r'''\converter svg        png        "%%"    "",
-\converter svgz       png        "%%"    ""'''],
-            path = ['', inkscape_path])
+        path = ['', inkscape_path])
     #
     checkProg('Gnuplot', ['gnuplot'],
         rc_entry = [ r'''\Format gnuplot     "gp, gnuplot, plt"    "Gnuplot"     "" "" ""  "vector"	"text/plain"
@@ -2182,7 +2127,6 @@ Format %i
     inkscape_cl = inkscape_gui
     if os.name == 'nt':
         inkscape_cl = inkscape_gui.replace('.exe', '.com')
-    inkscape_stable = checkInkscapeStable()
     checkFormatEntries(dtl_tools)
     checkConverterEntries()
     checkTeXAllowSpaces()
diff --git a/lib/scripts/svg2pdftex.py b/lib/scripts/svg2pdftex.py
index aad6d0b321..bfc6c0fa23 100644
--- a/lib/scripts/svg2pdftex.py
+++ b/lib/scripts/svg2pdftex.py
@@ -14,12 +14,11 @@
 # with pdflatex into high quality PDF. It requires Inkscape.
 
 # Usage:
-#   python svg2pdftex.py [--unstable] [inkscape_command] inputfile.svg outputfile.pdf_tex
+#   python svg2pdftex.py [inkscape_command] inputfile.svg outputfile.pdf_tex
 # This command generates
 #   1. outputfile.pdf     -- the converted PDF file (text from SVG stripped)
 #   2. outputfile.pdf_tex -- a TeX file that can be included in your
 #                             LaTeX document using '\input{outputfile.pdf_text}'
-# use --unstable for inkscape < 1.0
 #
 # Note:
 #   Do not use this command as
@@ -42,29 +41,16 @@ def runCommand(cmd):
 InkscapeCmd = "inkscape"
 InputFile = ""
 OutputFile = ""
-unstable = False
 
-# We expect two to four args: the names of the input and output files
-# and optionally the inkscape command (with path if needed) and --unstable.
+# We expect two or three args: the names of the input and output files
+# and optionally the inkscape command (with path if needed).
 args = len(sys.argv)
 if args == 3:
     # Two args: input and output file only
     InputFile, OutputFile = sys.argv[1:]
 elif args == 4:
-    # Three args: check whether we have --unstable as first arg
-    if sys.argv[1] == "--unstable":
-        unstable = True
-        InputFile, OutputFile = sys.argv[2:]
-    else:
-        InkscapeCmd, InputFile, OutputFile = sys.argv[1:]
-elif args == 5:
-    # Four args: check whether we have --unstable as first arg
-    if sys.argv[1] != "--unstable":
-        # Invalid number of args. Exit with error.
-        sys.exit(1)
-    else:
-        unstable = True
-        InkscapeCmd, InputFile, OutputFile = sys.argv[2:]
+    # Three args: inkscape command, input and output file
+    InkscapeCmd, InputFile, OutputFile = sys.argv[1:]
 else:
     # Invalid number of args. Exit with error.
     sys.exit(1)
@@ -80,10 +66,7 @@ OutBase = os.path.splitext(OutputFile)[0]
 # while outsourcing the text to a LaTeX file ${OutBase}.pdf_tex which includes and overlays
 # the PDF image and can be \input to LaTeX files. We rename the latter file to ${OutputFile}
 # (although this is probably the name it already has).
-if unstable:
-    runCommand([r'%s' % InkscapeCmd, '--file=%s' % InputFile, '--export-pdf=%s.pdf' % OutBase, '--export-latex'])
-else:
-    runCommand([r'%s' % InkscapeCmd, '%s' % InputFile, '--export-filename=%s.pdf' % OutBase, '--export-latex'])
+runCommand([r'%s' % InkscapeCmd, '%s' % InputFile, '--export-filename=%s.pdf' % OutBase, '--export-latex'])
 
 os.rename('%s.pdf_tex' % OutBase, OutputFile)
 
diff --git a/lib/scripts/svg2pstex.py b/lib/scripts/svg2pstex.py
index 33aedc226a..f4d085ef1f 100644
--- a/lib/scripts/svg2pstex.py
+++ b/lib/scripts/svg2pstex.py
@@ -14,12 +14,11 @@
 # with latex into high quality DVI/PostScript. It requires Inkscape.
 
 # Usage:
-#   python svg2pstex.py [--unstable] [inkscape_command] inputfile.svg outputfile.eps_tex
+#   python svg2pstex.py [inkscape_command] inputfile.svg outputfile.eps_tex
 # This command generates
 #   1. outputfile.eps     -- the converted EPS file (text from SVG stripped)
 #   2. outputfile.eps_tex -- a TeX file that can be included in your
 #                             LaTeX document using '\input{outputfile.eps_text}'
-# use --unstable for inkscape < 1.0
 #
 # Note:
 #   Do not use this command as
@@ -45,29 +44,16 @@ def runCommand(cmd):
 InkscapeCmd = "inkscape"
 InputFile = ""
 OutputFile = ""
-unstable = False
 
-# We expect two to four args: the names of the input and output files
-# and optionally the inkscape command (with path if needed) and --unstable.
+# We expect two or three args: the names of the input and output files
+# and optionally the inkscape command (with path if needed).
 args = len(sys.argv)
 if args == 3:
     # Two args: input and output file only
     InputFile, OutputFile = sys.argv[1:]
 elif args == 4:
-    # Three args: check whether we have --unstable as first arg
-    if sys.argv[1] == "--unstable":
-        unstable = True
-        InputFile, OutputFile = sys.argv[2:]
-    else:
-        InkscapeCmd, InputFile, OutputFile = sys.argv[1:]
-elif args == 5:
-    # Four args: check whether we have --unstable as first arg
-    if sys.argv[1] != "--unstable":
-        # Invalid number of args. Exit with error.
-        sys.exit(1)
-    else:
-        unstable = True
-        InkscapeCmd, InputFile, OutputFile = sys.argv[2:]
+    # Three args: inkscape command, input and output file
+    InkscapeCmd, InputFile, OutputFile = sys.argv[1:]
 else:
     # Invalid number of args. Exit with error.
     sys.exit(1)
@@ -83,10 +69,7 @@ OutBase = os.path.splitext(OutputFile)[0]
 # while outsourcing the text to a LaTeX file ${OutBase}.eps_tex which includes and overlays
 # the EPS image and can be \input to LaTeX files. We rename the latter file to ${OutputFile}
 # (although this is probably the name it already has).
-if unstable:
-    runCommand([r'%s' % InkscapeCmd, '--file=%s' % InputFile, '--export-eps=%s.eps' % OutBase, '--export-latex'])
-else:
-    runCommand([r'%s' % InkscapeCmd, '%s' % InputFile, '--export-filename=%s.eps' % OutBase, '--export-latex'])
+runCommand([r'%s' % InkscapeCmd, '%s' % InputFile, '--export-filename=%s.eps' % OutBase, '--export-latex'])
 
 os.rename('%s.eps_tex' % OutBase, OutputFile)
 
-- 
lyx-devel mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to