From: Vladimír Vondruš Date: Thu, 2 Mar 2023 12:34:20 +0000 (+0100) Subject: latex2svg: more robust handling of libgs not being found. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=8cb6a76dac482b01e365507b0f350e0fc1c849a2;p=blog.git latex2svg: more robust handling of libgs not being found. Instead of just looking it up upfront and then hoping for the best, verify also that dvisvgm actually detected and used it. Because it not always does, in particular with versions < 3.0 and ghostscript 10. --- diff --git a/plugins/latex2svg.py b/plugins/latex2svg.py index ea6d3ab5..95a56122 100755 --- a/plugins/latex2svg.py +++ b/plugins/latex2svg.py @@ -143,6 +143,13 @@ def latex2svg(code, params=default_params, working_directory=None): return None output = ret.stderr.decode('utf-8') + + # Since we rely on Ghostscript to give us a "depth" (= vertical alignment) + # value, dvisvgm not using it means the output would be broken and it makes + # no sense to continue. + if 'Ghostscript not found' in output: + raise RuntimeError('libgs not detected by dvisvgm, point the LIBGS environment variable to its location') + width, height = get_size(output) depth = get_measure(output, 'depth') return {'svg': svg, 'depth': depth, 'width': width, 'height': height}