Skip to content

fix(md): keep the hyperlink of autolinks outside table cells - #4791

Merged
dolfim-ibm merged 1 commit into
docling-project:mainfrom
LindseyZ1205:fix/md-autolinks
Oct 14, 2026
Merged

dolfim-ibm merged 1 commit into
docling-project:mainfrom
LindseyZ1205:fix/md-autolinks

Conversation

@LindseyZ1205

Copy link
Copy Markdown
Contributor

The inline walker of the Markdown backend handles marko.inline.Link, but not marko.inline.AutoLink. AutoLink is not a subclass of Link. So an angle-bracket autolink (<https://url>) and a GFM bare URL (gfm_el.Url, a subclass of AutoLink) lose their hyperlink in paragraphs, list items and headings, and export as plain text. The table cell walker already handles Link | AutoLink since #4488. This change uses the same check in the inline walker.

Issue resolved by this Pull Request:
Resolves #4790

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

Review evidence:

  • Before: in a paragraph, a list item and a heading, <https://example.com>, https://example.com and www.example.com gave a TextItem without hyperlink, and the export had no link.
  • After: these items have the hyperlink, and the export is [https://example.com](https://example.com/). www.example.com gets http://www.example.com/, as the GFM spec defines for this form. Explicit links and table cells give the same output as before.
  • Document tree: only the hyperlink field of the text items that come from autolinks changes.
  • Reference data: no change. The Markdown ground truth files do not contain autolinks, and all tests in tests/test_backend_markdown.py pass with the existing ground truth.
  • New test: test_autolinks_outside_table_cells checks the hyperlinks of autolinks in a heading, a paragraph and a list item. It fails on main and passes with this change.
  • Commands and results:
    • 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).
  • Not run: the full test suite.

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>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @LindseyZ1205, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working markdown issue related to markdown backend labels Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit ca815d24e8. The analysis read the diff only. It did not run code from this pull request.

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: bug, markdown.

CI safety: no concern found. A maintainer must still approve CI.

1 related pull request(s) in the same code
PR State Signal Assessment
#4488 merged referenced as #4488 related: PR 4488 is already merged. It added autolink handling in table cells. This PR applies the same check to the inline walker. The candidate diff file is empty, so this verdict uses the PR description.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Oct 13, 2026
@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dolfim-ibm dolfim-ibm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dolfim-ibm
dolfim-ibm merged commit 4757220 into docling-project:main Oct 14, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) bug Something isn't working markdown issue related to markdown backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown: autolinks outside table cells lose their hyperlink

2 participants