Commit ca21e472 authored by Florian Rhiem's avatar Florian Rhiem

Allow tikz_directive to write into different build_directory for PDF output

parent 97250f54
......@@ -49,6 +49,7 @@ TMP_PNG_FILENAME = "tikz_picture.png"
OUT_PNG_FILENAME = "_tikz_rendered{:04d}.png"
TMP_SVG_FILENAME = "tikz_picture.svg"
OUT_SVG_FILENAME = "_tikz_rendered{:04d}.svg"
BUILD_DIRECTORY = '.'
class TemporaryDirectory(object):
......@@ -194,6 +195,7 @@ class Tikz(Directive):
if is_output_mode_html:
reference = directives.uri(convert_image_to_html_base64(rendered_tikz_filename))
else:
shutil.copy(rendered_tikz_filename, os.path.join(BUILD_DIRECTORY, os.path.basename(rendered_tikz_filename)))
reference = directives.uri(rendered_tikz_filename)
self.options["uri"] = reference
if is_output_mode_html and not any(attr in self.options for attr in ("height", "width", "scale")):
......
from . import directives
from .directives import tikz_directive
def setup(app):
app.add_directive("embedded-image", directives.EmbeddedImage)
app.add_directive("embedded-figure", directives.EmbeddedFigure)
app.add_directive("jupyter-outbox", directives.ParsedLiteral)
tikz_directive.BUILD_DIRECTORY = app.outdir
app.add_directive('tikz', directives.Tikz)
app.add_directive("tikz-figure", directives.TikzFigure)
app.connect('builder-inited', lambda app: directives.set_output_mode(app.builder.format))
return {'version': '0.1'}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment