From: Jacob Lifshay Date: Tue, 4 Apr 2023 02:15:53 +0000 (-0700) Subject: fix pandoc_img hack so source file is always an absolute path X-Git-Tag: opf_rfc_ls012_v1~139 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e6d667e5117ee7277b3844c7900e91809087481c;p=libreriscv.git fix pandoc_img hack so source file is always an absolute path --- diff --git a/openpower/pandoc_img.py b/openpower/pandoc_img.py index 7ecedaee2..d60fac533 100755 --- a/openpower/pandoc_img.py +++ b/openpower/pandoc_img.py @@ -2,6 +2,7 @@ import os import re +import sys import subprocess from pandocfilters import (toJSONFilter, RawInline, Space, Str, walk, Image, Link) @@ -36,12 +37,16 @@ def inlinenotes(k, v, f, meta): if k == u'Image' and f == 'latex': imgname = v[2][0] out.write(" image %s\n" % (imgname)) - # HACK! works only relative to openpower directory! if imgname.startswith("/"): - imgname = ".." + imgname + # use absolute paths so pandoc_img.py can be used in any directory + file_path = os.path.abspath(__file__) + openpower_path = os.path.split(file_path)[0] + wiki_path = os.path.split(openpower_path)[0] + imgname = os.path.join(wiki_path, imgname.lstrip('/')) png = imgname.replace(".svg", ".png") png = os.path.split(png)[1] png = "tex_out/%s" % png + print(f"converting {imgname} to {png}", file=sys.stderr) subprocess.run(["inkscape", "-z", "-C", imgname, "--export-png=%s" % png], stdout=subprocess.PIPE)