import os
import re
+import sys
import subprocess
from pandocfilters import (toJSONFilter, RawInline, Space, Str, walk, Image,
Link)
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)