Repository navigation
feat(calendar): add an iCalendar (.ics) backend - #4880
Conversation
Read RFC 5545 content lines into a component tree with the standard library only, make dates, durations and recurrence rules readable, and add events, tasks, journal entries and free/busy times to a DoclingDocument. The renderer takes a parent and a heading level, so another backend can reuse it. Signed-off-by: Daniel Nguyen <[email protected]>
Add InputFormat.CALENDAR for .ics, .ical, .icalendar and .ifb files, CalendarDocumentBackend with its format and backend options, and a content check on the first line, so a calendar without a known extension is recognized. Folded lines are joined on the bytes before decoding, because a fold may split a UTF-8 character. Signed-off-by: Daniel Nguyen <[email protected]>
Synthetic Google, Outlook and Apple style calendars with reference outputs, plus tests for folding, line endings, encodings, recovery from a missing END, all-day and duration handling, recurrence rules, alarms and format detection. Signed-off-by: Daniel Nguyen <[email protected]>
Signed-off-by: Daniel Nguyen <[email protected]>
|
✅ DCO Check Passed Thanks @DanielNg0729, all your commits are properly signed off. 🎉 |
Merge Protections🟢 All 2 merge protections satisfied — ready to merge. Show 2 satisfied protections🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 Require two reviewer for test updatesWhen test data is updated, we require two reviewers
|
AI triage (advisory)Checked commit Adds a new CI safety: no concern found. A maintainer must still approve CI. Reference data changes
Assessment: expected. The 12 added groundtruth files (JSON, Markdown, and indented-text exports for 4 new source The |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at 56d534767e. It read the code and did not run it.
The pull request adds an iCalendar backend that parses .ics and .ifb files into DoclingDocument structures with standard library tools. We checked format detection, line unfolding across multi-byte character boundaries, date and recurrence rendering, and error handling for malformed components. The implementation integrates correctly with DocumentConverter and includes comprehensive regression tests.
A maintainer makes the merge decision. This review never approves the pull request.
…ackend Signed-off-by: Daniel Nguyen <[email protected]>
docling-core 2.103.0 accepts text/calendar in DocumentOrigin without a system MIME table. Raise the minimum in the three pins and lock 2.103.1; only the docling-core entries of uv.lock change. Signed-off-by: Daniel Nguyen <[email protected]>
Signed-off-by: Daniel Nguyen <[email protected]>
…ackend Signed-off-by: Daniel Nguyen <[email protected]>
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the changes since 56d534767e at 7b3cbef1fb. It read the code and did not run it.
We checked the incremental changes from the rebase onto the main branch for regressions and integration conflicts with the calendar backend.
A maintainer makes the merge decision. This review never approves the pull request.
|
Hi @PeterStaar-IBM, @dolfim-ibm and @cau-git, as docling-project/docling-core#892 is merged and released in docling-core 2.103.0. I have raised the docling-core minimum here and updated |
docling-core 2.103.0 no longer reads local image files unless the caller opts in, so a JSON input converted with enable_local_fetch=True kept its file references but failed on the first image export. Load them with DoclingDocument.load_local_images(), the opt-in docling-core provides. Signed-off-by: Daniel Nguyen <[email protected]>
docling-core 2.103.0 puts formatting tags inside the <p> element instead of around it (docling-project/docling-core#879). Signed-off-by: Daniel Nguyen <[email protected]>
|
Hi @PeterStaar-IBM, thank you very much, Both failures came from the docling-core 2.103 upgrade that this PR needs, not from the calendar code: The test_local_image_uri_is_embedded_with_enable_local_fetch: docling-core 2.103.0 reads local image files only after an explicit opt-in (docling-project/docling-core#900). The JSON backend now calls DoclingDocument.load_local_images() when enable_local_fetch is set. Another thing is that test_e2e_docx_conversions: docling-core 2.103.0 puts formatting tags inside (docling-project/docling-core#879), so I updated 9 lines of docx_rich_cells.docx.html. CI is green now. Thank you very much! |
…ackend Signed-off-by: Daniel Nguyen <[email protected]>
ceberam
left a comment
There was a problem hiding this comment.
Thanks @DanielNg0729 for this new feature!
The new backend implementation looks very robust and aligned to the other declarative backends. The amount and type of examples provided is just fine.
Not major concerns. Just minor observations about the code style.
Use `X | None` and `A | B` instead of typing.Optional and typing.Union in the new calendar modules, annotate CalendarDocumentBackend.unload, and add Google-style docstrings to the public classes and functions. Signed-off-by: Daniel Nguyen <[email protected]>
Signed-off-by: Daniel Nguyen <[email protected]>
|
Thank you very much @ceberam for your review! I applied all your suggestions. Could you please have another look when you have time? Thank you! |
|
Hi @ceberam @PeterStaar-IBM! Just following up on this PR. I've addressed all the suggestions from your previous review. When you have a chance, could you please take another look? Thank you very much! |
Summary
Hi maintainers, Issue #327 asked for email and calendar formats. Email (
.eml,.msg) is already supported, so this PR adds the calendar half, starting with iCalendar files.No new dependency! The parser uses only the Python standard library.
Changes
InputFormat.CALENDARfor.ics,.ical,.icalendarand.ifb(free/busy) files, with thetext/calendarMIME type.BEGIN:VCALENDAR. A.txtfile stays Markdown, as with the LaTeX check.CalendarDocumentBackend,CalendarFormatOptionandCalendarBackendOptions. The options class extendsTextBackendOptions, so theencodingoverride works as it does for Markdown, CSV and AsciiDoc.docling/backend/calendar/package:parser.pyreads content lines into a component tree. It handles quoted parameters, RFC 6868 caret escapes and TEXT escapes.values.pymakes dates, durations and recurrence rules readable.render.pyadds the tree to aDoclingDocument. It takes a parent and a heading level, so the email backend can reuse it later for meeting invitations.X-properties are not rendered.Usage
A calendar file converts like any other input. The format is detected from the extension, or from the first line when there is no extension:
For a file in an encoding that docling cannot detect, set the encoding as for Markdown or CSV files:
Output
The body is flat, like the email backend's output: a heading for each entry,
Key: valueparagraphs, the description, and then lists. This is a shortened example fromtests/data/calendar/sources/outlook_invite.ics:I used plain paragraphs instead of key-value or field items, because the Markdown serializer and the chunkers output nothing for field regions.
Decisions you may want to change
DTENDis exclusive. Thus a one-day event shows one date, and an event from 24 December to 27 December shows "Start: 2026-12-24 (all day)" and "End: 2026-12-26 (all day)".ENDdoes not hide the next entry. ABEGINthat the open component cannot contain closes that component first. Truncated files and strayENDlines still convert.Depends on docling-core
DocumentOriginaccepts only MIME types from the host table or from its own list, and CPython's built-in table has notext/calendar. CI passes without the core change, because Ubuntu has/etc/mime.typesand importing the converter loads it. A host without that file rejects every calendar conversion. Code that loads the saved JSON with docling-core only, in a new process, also rejects it, even on a host that has the type. docling-project/docling-core#<CORE_PR> adds the type. Please merge this PR after that change is released. I will then raise the docling-core pin here.docling-serveand the remote CLI default tolist(InputFormat), so a server that runs an older docling rejects the newcalendarvalue. The same thing happened when AFP and EBCDIC were added.I'll make a follow up after this. Thank you!
Issue resolved by this Pull Request:
Resolves #327
Checklist: