feat(document): add artifacts_dir param to export_to_markdown#585
feat(document): add artifacts_dir param to export_to_markdown#585Smeet23 wants to merge 2 commits into
Conversation
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 Require two reviewer for test updatesWaiting for
This rule is failing.When test data is updated, we require two reviewers
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
|
Related Documentation 1 document(s) may need updating based on files changed in this PR: Docling What are the differences between
|
|
✅ DCO Check Passed Thanks @Smeet23, all your commits are properly signed off. 🎉 |
When image_mode=ImageRefMode.REFERENCED, users previously had to manually iterate over pictures and save them to disk before calling export_to_markdown(). This adds an optional artifacts_dir parameter that, when provided, automatically saves images to that directory and returns markdown with relative paths referencing the saved files. Resolves docling-project/docling#3094 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Smeet Agrawal <smeetagrawal23@gmail.com>
9404ba1 to
87ff805
Compare
|
Hi @PeterStaar-IBM and @dolfim-ibm — could you take a look at this PR when you get a chance? Mergify requires 2 approvals since test data was updated. DCO and all other checks are passing. Would really appreciate a review! |
Signed-off-by: Smeet23 <smeetagrawal2003@gmail.com>
|
Hi @PeterStaar-IBM — thanks for the approval! I've pushed a small follow-up fix: |
|
Hi @PeterStaar-IBM and @dolfim-ibm — just a gentle ping on this one. DCO ✅ is passing and all checks are green. Would appreciate a re-approval so Mergify can proceed. Happy to address any feedback. Thanks! |
Summary
artifacts_dir: Optional[Path]parameter toDoclingDocument.export_to_markdown()image_mode=ImageRefMode.REFERENCEDandartifacts_diris provided, images are automatically saved to that directory and the returned markdown contains relative paths referencing themartifacts_dirisNone(default) orimage_modeis notREFERENCED, behaviour is unchanged — fully backwards-compatibleBefore:
After:
Relation to upstream issue
Resolves docling-project/docling#3094
Test plan
test_export_to_markdown_with_artifacts_dir— verifies images are saved and referenced in markdowntest_export_to_markdown_referenced_without_artifacts_dir— verifies fallback whenartifacts_diris omittedtest_export_to_markdown_artifacts_dir_ignored_for_non_referenced— verifies no side-effects forPLACEHOLDER/EMBEDDEDmodestest_save_to_disk,test_construct_doc,test_save_picturesall still pass