Repository navigation
fix(web-fetch): preserve table cells and preformatted code in Markdown output - #176263
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR separates HTML table cells and preserves preformatted code, literal links, and backticks in web_fetch output. Example: Fetch a minified HTML row containing EMEA, 120, and 15.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it fixes a verified current-main extraction bug, and the reviewed head has no actionable code findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe shared HTML renderer receives sanitized HTML from Readability or basic extraction and produces Markdown; text extraction subsequently removes Markdown formatting while preserving code literals. flowchart TD
A[web_fetch request] --> B[Fetch HTML]
B --> C[Sanitize and extract content]
C --> D[Shared HTML renderer]
D --> E[Markdown output]
D --> F[Markdown to text]
F --> G[Text output]
Technical reviewBest possible solution: Land the focused shared-renderer fix once the enforced checks permit merging. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the failure for adjacent td/th elements and indented pre content, and the supplied Gateway output demonstrates the same observable failure; no target code was executed during this review. Is this the best way to solve the issue? The patch repairs the existing shared owner, keeps code outside prose normalization, and extends the existing text converter for safe fences without introducing a competing extraction path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e4ac046c6446. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +95, Tests +59. Total +154 across 2 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 20, 2026, 10:32 AM ET / 14:32 UTC (Revision 5). |
a8aad1a to
604ada9
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
604ada9 to
5331637
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in e6afd9d. Thanks @sunlit-deng. web_fetch no longer merges table cells or flattens preformatted text. |
…n output (openclaw#176263) fix(web-fetch): keep HTML table cells and preformatted text intact web_fetch's HTML-to-Markdown rendering merged adjacent table cells, so separate values like "12" and "34" came out as a misleading "1234", and it flattened indentation in pre/code blocks. Cells now stay separated and preformatted blocks keep their indentation and the text that follows them. Proof: built Gateway, /tools/invoke web_fetch on a local page. On main, numeric cells merged and code indentation was lost (twice, separate URLs); a plain-prose page was unchanged. With this change cells stay separate, indentation is kept, and the following paragraph is intact. Production +95 (cut from the original proposal by 77 lines; reuses the code-whitespace handling from openclaw#172389). Fixes openclaw#176244. Thanks @sunlit-deng. Co-authored-by: Ayaan Zaidi <[email protected]>
What problem this solves
Fixes #176244. Minified HTML tables currently return
EMEA12015for the separate cellsEMEA,120, and15. HTML preformatted code loses indentation and runs into the following paragraph.Changes
Separate table cells, protect preformatted text during prose normalization, and wrap it in a fence longer than its literal backticks. Treat markup inside a pre block as presentation, so anchors contribute literal text without Markdown link syntax. Escape input NULs before restoring internal markers in one forward pass.
Reuse the fenced-code whitespace preservation from #172389; the text extractor only gains matching-length fence recognition. Remove the extra literal-anchor state and custom marker-restoration scanner from the original proposal.
Evidence
Built isolated Gateways, invoked
POST /tools/invokewithweb_fetchagainst a local HTTP page containing adjacent numeric cells and an indented pre block, twice with independent URLs plus an ordinary-prose control. Configuration was created through the shipped CLI.Baseline output:
Candidate output:
The ordinary-prose control passes on both artifacts. The focused suite has 44 passing tests on the candidate; six new regressions fail on the baseline. Coverage includes literal links, longer fences, decoded marker-like input, long NUL runs, and the existing adjacent-code-block boundary. Targeted formatting and lint pass.
Whole-change deltas against the merge base: production +121/-26 (net +95), tests +59/-0. This removes 77 net production lines from the original proposal. Remaining growth is needed to keep code out of prose normalization, separate cells, and recognize the longer safe fences without reimplementing whitespace extraction.
Thanks to @sunlit-deng for the report and original implementation; their commits are retained.
Merge danger: two-way door; reverting restores the old extraction without a state migration. Blast radius is HTML rendering in web_fetch's Markdown extraction, basic fallback, and HTML error summaries, plus matching-length fenced-code conversion in text extraction.