From 9777f411378dca2273167aae6c755b7b7b596c62 Mon Sep 17 00:00:00 2001 From: Christoph Auer Date: Wed, 27 Nov 2024 10:13:18 +0100 Subject: [PATCH] Add export with referenced images to export_figures example Signed-off-by: Christoph Auer --- docs/examples/export_figures.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/examples/export_figures.py b/docs/examples/export_figures.py index f910753d..b2ecc43f 100644 --- a/docs/examples/export_figures.py +++ b/docs/examples/export_figures.py @@ -71,10 +71,16 @@ def main(): element.get_image(conv_res.document).save(fp, "PNG") # Save markdown with embedded pictures - content_md = conv_res.document.export_to_markdown(image_mode=ImageRefMode.EMBEDDED) md_filename = output_dir / f"{doc_filename}-with-images.md" - with md_filename.open("w") as fp: - fp.write(content_md) + conv_res.document.save_as_markdown(md_filename, image_mode=ImageRefMode.EMBEDDED) + + # Save markdown with externally referenced pictures + md_filename = output_dir / f"{doc_filename}-with-image-refs.md" + conv_res.document.save_as_markdown(md_filename, image_mode=ImageRefMode.REFERENCED) + + # Save HTML with externally referenced pictures + html_filename = output_dir / f"{doc_filename}-with-image-refs.html" + conv_res.document.save_as_html(html_filename, image_mode=ImageRefMode.REFERENCED) end_time = time.time() - start_time