Repository navigation
Fix MinerU table option sanitization - #16118
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@deepdoc/parser/mineru_parser.py`:
- Around line 694-695: The condition `if not table_enable:` incorrectly bypasses
`_sanitize_section_text` for all block types instead of just tables, because
`table_enable` is true by default. Replace this condition with a check that
specifically verifies whether the current section is a TABLE block type before
skipping sanitization. This ensures non-table blocks (text, code, lists, images)
are properly sanitized while preserving raw HTML only for TABLE sections.
Additionally, add a logging statement in this branch to document when
sanitization is bypassed, following the coding guideline to log new flows.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ad037d6d-6bec-488e-8ff7-4abcfa436f5c
📒 Files selected for processing (1)
deepdoc/parser/mineru_parser.py
| if not table_enable: | ||
| section = self._sanitize_section_text(section) |
There was a problem hiding this comment.
Scope the sanitizer bypass to table blocks.
table_enable is true by default, so this skips _sanitize_section_text for every block type, not just tables. Non-table text/code/list/image chunks can now retain tag noise, and empty image captions like "\n" can be appended instead of stripped/skipped. Preserve raw HTML only for TABLE sections and log that new branch.
🐛 Proposed fix
- if not table_enable:
+ preserve_table_html = table_enable and output.get("type") == MinerUContentType.TABLE
+ if preserve_table_html:
+ self.logger.debug("[MinerU] Preserve table HTML section without sanitization.")
+ else:
section = self._sanitize_section_text(section)
- if not section:
+ if not section.strip():
self.logger.debug("[MinerU] Skip section after sanitization: type=%s", output.get("type"))
continueAs per coding guidelines, "**/*.py: Add logging for new flows." This also keeps the behavior scoped to the PR objective of preserving HTML during table processing.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@deepdoc/parser/mineru_parser.py` around lines 694 - 695, The condition `if
not table_enable:` incorrectly bypasses `_sanitize_section_text` for all block
types instead of just tables, because `table_enable` is true by default. Replace
this condition with a check that specifically verifies whether the current
section is a TABLE block type before skipping sanitization. This ensures
non-table blocks (text, code, lists, images) are properly sanitized while
preserving raw HTML only for TABLE sections. Additionally, add a logging
statement in this branch to document when sanitization is bypassed, following
the coding guideline to log new flows.
Source: Coding guidelines
|
good. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16118 +/- ##
==========================================
- Coverage 94.56% 93.16% -1.40%
==========================================
Files 10 10
Lines 717 717
Branches 118 118
==========================================
- Hits 678 668 -10
- Misses 25 29 +4
- Partials 14 20 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Follow on issue: #14831 and PR: #14920 to fix the table options, with table recognition enabled, do not sanitize html tags.