Skip to content

fix: escape HTML-like tags in plain Markdown text - #5364

Open
lylelllll wants to merge 1 commit into
opendatalab:masterfrom
lylelllll:codex/fix-markdown-address-escaping
Open

lylelllll wants to merge 1 commit into
opendatalab:masterfrom
lylelllll:codex/fix-markdown-address-escaping

Conversation

@lylelllll

@lylelllll lylelllll commented Aug 6, 2026

Copy link
Copy Markdown

Motivation

Plain extracted text such as -a <address> currently passes through unchanged. Markdown renderers interpret <address> as raw HTML, so the placeholder is hidden or removed from rendered output.

Fixes #5360.

Modification

  • Treat an unescaped < as a conservative Markdown special character, producing \< in plain-text output.
  • Preserve the existing odd/even backslash behavior so already escaped placeholders are not double-escaped.
  • Add focused regression tests for repeated placeholders, existing escapes, even backslashes, and the existing conservative special-character set.
  • Leave code blocks and intentional table/algorithm HTML on their existing rendering paths.

BC-breaking

No public API changes. The generated Markdown source gains a backslash before unescaped < characters in plain text; rendered text remains the same literal content.

Tests

  • PYTHONPATH=. uv run --python 3.12 --with pytest --no-project pytest -q -o addopts='' tests/unittest/test_markdown_utils.py (4 passed)
  • uvx ruff check --ignore ANN001 mineru/backend/utils/markdown_utils.py tests/unittest/test_markdown_utils.py (passed; ANN001 is an existing annotation warning in the touched source file)
  • CommonMark rendering smoke test confirmed \<address> renders as literal &lt;address&gt;, not an HTML element.
  • Full model/GPU end-to-end parsing was not run because this change is isolated to the pure Markdown escaping utility.

Checklist

Before PR:

  • Ruff was run on the modified files.
  • The reported bug is covered by focused unit tests.
  • Existing conservative escaping behavior is covered by a regression test.
  • No documentation change is required for this narrowly scoped bug fix.

After PR:

  • The behavior was verified with a CommonMark renderer.
  • CLA has been signed and all committers have signed the CLA in this PR.

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@lylelllll

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDF中含有的“<address>”没有被转义导致解析出现的问题

1 participant