X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Fscripts%2Fsvg2pstex.py;h=09d8ac7183625bda2663a33e0af57d20d129ce9f;hb=0b56495e48437bec97117de8c6ac1825a8cf3fb1;hp=ef6ff1d92c22f26ca2c999230d8b97a144ba91ad;hpb=cac27076ead10684270520670adc6bd004793361;p=lyx.git diff --git a/lib/scripts/svg2pstex.py b/lib/scripts/svg2pstex.py index ef6ff1d92c..09d8ac7183 100644 --- a/lib/scripts/svg2pstex.py +++ b/lib/scripts/svg2pstex.py @@ -15,11 +15,12 @@ # with latex into high quality DVI/PostScript. It requires Inkscape. # Usage: -# python svg2pstex.py [inkscape_command] inputfile.svg outputfile.eps_tex +# python svg2pstex.py [--unstable] [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 @@ -46,16 +47,29 @@ def runCommand(cmd): InkscapeCmd = "inkscape" InputFile = "" OutputFile = "" +unstable = False -# We expect two or three args: the names of the input and output files -# and optionally the inkscape command (with path if needed). +# 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. args = len(sys.argv) if args == 3: # Two args: input and output file only InputFile, OutputFile = sys.argv[1:] elif args == 4: - # Three args: first arg is inkscape command - InkscapeCmd, InputFile, OutputFile = sys.argv[1:] + # 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:] else: # Invalid number of args. Exit with error. sys.exit(1) @@ -71,7 +85,10 @@ 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). -runCommand([r'%s' % InkscapeCmd, '--file=%s' % InputFile, '--export-eps=%s.eps' % OutBase, '--export-latex']) +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']) os.rename('%s.eps_tex' % OutBase, OutputFile)