Repository navigation
fix(md): keep the hyperlink of autolinks outside table cells - #4791
Conversation
The inline walker handled marko.inline.Link but not marko.inline.AutoLink, which is not a subclass of Link. So an angle-bracket autolink such as <https://example.com>, and a GFM bare URL (gfm_el.Url subclasses AutoLink), lost its hyperlink in paragraphs, list items and headings, and exported as plain text. Table cells already handle both classes. Handle AutoLink the same way in the inline walker. Signed-off-by: LindseyZ1205 <yingzizhang1205@gmail.com>
|
✅ DCO Check Passed Thanks @LindseyZ1205, all your commits are properly signed off. 🎉 |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
AI triage (advisory)Checked commit The Markdown backend now keeps the hyperlink of angle-bracket autolinks and GFM bare URLs in paragraphs, list items and headings. The PR adds one test for this. Topic labels added: CI safety: no concern found. A maintainer must still approve CI. 1 related pull request(s) in the same code
The |
There was a problem hiding this comment.
AI first review (advisory): no blocker found
This review covers the full diff at ca815d24e8. It read the code and did not run it.
No blocking problem found. The base code already handles marko.inline.AutoLink in table cells (line 517) with the same check. gfm_el.Url subclasses AutoLink in the installed marko, and both classes set dest. The regression test would fail on base because no hyperlink would be set.
A maintainer makes the merge decision. This review never approves the pull request.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The inline walker of the Markdown backend handles
marko.inline.Link, but notmarko.inline.AutoLink.AutoLinkis not a subclass ofLink. So an angle-bracket autolink (<https://url>) and a GFM bare URL (gfm_el.Url, a subclass ofAutoLink) lose their hyperlink in paragraphs, list items and headings, and export as plain text. The table cell walker already handlesLink | AutoLinksince #4488. This change uses the same check in the inline walker.Issue resolved by this Pull Request:
Resolves #4790
Checklist:
Review evidence:
<https://example.com>,https://example.comandwww.example.comgave aTextItemwithouthyperlink, and the export had no link.[https://example.com](https://example.com/).www.example.comgetshttp://www.example.com/, as the GFM spec defines for this form. Explicit links and table cells give the same output as before.hyperlinkfield of the text items that come from autolinks changes.tests/test_backend_markdown.pypass with the existing ground truth.test_autolinks_outside_table_cellschecks the hyperlinks of autolinks in a heading, a paragraph and a list item. It fails onmainand passes with this change.uv run --frozen pytest tests/test_backend_markdown.py: 35 passed.uv run --frozen pytest tests/test_backend_markdown.py tests/test_backend_text_encoding.py tests/test_backend_optional_dependencies.py tests/test_input_doc.py tests/test_invalid_input.py tests/test_pr_topic_labels.py: the results are the same before and after this change, apart from the new test. 8 tests fail in my environment in both runs, because some optional packages (docling-parse,python-docx,pylatexenc) are not installed.uvx prek run --files docling/backend/md_backend.py tests/test_backend_markdown.py: all hooks pass (Ruff, ty, Tach, max lines).