Repository navigation
fix(parser): align HTML Parser to Python (nested-table fix; alignment golden) - #7
Closed
xugangqiang wants to merge 1 commit into
Closed
xugangqiang wants to merge 1 commit into
xugangqiang wants to merge 1 commit into
Conversation
… golden)
Root cause: walkHTMLLeaf recursed into <table> children as plain leaf text
and concatenated every cell into one string ("NameAge\nAlice30…"), i.e. the
nested-table 塌方. The Python RAGFlowHtmlParser keeps each cell/tag on its
own line, so the two engines diverged on any table containing a nested table
or a table inside other block content.
Fix (surgical, preserves per-block granularity):
- htmlLeafText / walkHTMLLeaf now take a *[]map[string]any tableItems sink.
- walkHTMLLeaf gained a table-aware branch: a <table> is rendered to its
inline markup, written as text, and appended as a structured
doc_type_kwd:"table" item — mirroring the top-level (non-leaf) table path.
- renderTableHTML returns "" on render error instead of recursing through the
leaf extractor (avoids a render loop).
Tests (TDD: RED before fix, GREEN after):
- TestHTMLParser_NestedTableProducesStructuredItems: the original 塌方 case.
- TestHTMLParser_NestedListItemsPreserved: nested <ul>/<ol> items stay
separate, in document order, top-level list tagged ck_type:"list".
- TestHTMLParser_PrePreservesVerbatim: <pre>/<textarea> keep indentation and
internal newlines verbatim (one leading newline dropped per spec).
- TestHTMLParser_AlignmentGolden: content-equivalence against the Python
RAGFlowHtmlParser baseline via the shared align_test.go tool.
Align tooling:
- align_test.go: add StripHTMLHeadingMarker + HTMLAlignOptions preset.
- testdata/html.python.golden.json: Python baseline as a {meta, items}
document (meta records how to regenerate; no committed generator script,
matching the markdown golden convention).
- testdata/html.sample.html: shared input sample.
No chunker/wiring change was needed: the HTML parser already emits
OutputFormat:"json", and the chunker's table path preserves ck_type, so the
structured table item flows through unchanged.
Owner
Author
|
Superseded: reopening against upstream infiniflow/ragflow (base main, stacks on merged infiniflow#18014). |
xugangqiang
added a commit
that referenced
this pull request
Oct 30, 2026
- prefer worker-claim time (doc.ProcessBeginAt) for wait duration (#2) - omit zero-value times from the JSON log line instead of emitting 0001-01-01, and guard the logger with atomic.Pointer for a safe swap (#8, #7) - populate DurationMS from ParseDurationS so consumers need not recompute (#11) - drop the unused IngestLog.Code field (#Nit) - thread the failure reason through MarkFailed into the emitted event's ErrorInfo, so failed runs are no longer logged with an empty reason (#4) - persist process_end_at idempotently (WHERE process_end_at IS NULL) so overlapping terminal events cannot rewrite the recorded completion instant (#12) All changes covered by unit tests in internal/common, internal/observability and internal/service.
xugangqiang
added a commit
that referenced
this pull request
Nov 2, 2026
- prefer worker-claim time (doc.ProcessBeginAt) for wait duration (#2) - omit zero-value times from the JSON log line instead of emitting 0001-01-01, and guard the logger with atomic.Pointer for a safe swap (#8, #7) - populate DurationMS from ParseDurationS so consumers need not recompute (#11) - drop the unused IngestLog.Code field (#Nit) - thread the failure reason through MarkFailed into the emitted event's ErrorInfo, so failed runs are no longer logged with an empty reason (#4) - persist process_end_at idempotently (WHERE process_end_at IS NULL) so overlapping terminal events cannot rewrite the recorded completion instant (#12) - emit the running lifecycle event from PrepareValidatedRun AFTER the worker-claim time is stamped, so BeginTime and wait_duration_s reflect this run instead of a zero or previous-run value (#A) - only emit user_name when set, so the always-empty key is not logged and the JSON field uses omitempty (#C) - correct the ingestor.log sink docs: it always writes to stdout; ingestor.log.path only adds an optional rotated file on top (#B) - drop the redundant SetIngestLog/SyncIngestLog calls from admin and syncer, which never emit ingestion events (#D) All changes covered by unit tests in internal/common, internal/observability and internal/service.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Aligns the Go HTML parser (
internal/parser/parser/html_parser.go) with the PythonRAGFlowHtmlParserand adds a reusable alignment test harness so the two engines can be diffed content-wise, not just line-wise.This fixes a real divergence — nested-table 塌方 — where a
<table>nested inside other block content (or containing another table) was collapsed into a single concatenated string on the Go side while Python kept each cell/tag on its own line.Root cause
walkHTMLLeafrecursed into<table>children as plain leaf text and concatenated every cell ("NameAge\nAlice30…"). Python keeps each cell/tag on its own line, so the engines diverged whenever a table appeared inside a list, blockquote, or another table.Fix (surgical; preserves per-block granularity)
htmlLeafText/walkHTMLLeafnow take a*[]map[string]anysink for structured table items.walkHTMLLeafgained a table-aware branch: a<table>is rendered to its inline markup, written as text, and appended as a structureddoc_type_kwd:"table"item — mirroring the existing top-level (non-leaf) table path.renderTableHTMLreturns""on render error instead of recursing through the leaf extractor (avoids a render loop).Tests (TDD: RED before fix, GREEN after)
TestHTMLParser_NestedTableProducesStructuredItems— the original 塌方 case.TestHTMLParser_NestedListItemsPreserved— nested<ul>/<ol>items stay separate, in document order; top-level list taggedck_type:"list".TestHTMLParser_PrePreservesVerbatim—<pre>/<textarea>keep indentation and internal newlines verbatim (one leading newline dropped per spec).TestHTMLParser_AlignmentGolden— content-equivalence against the PythonRAGFlowHtmlParserbaseline via the sharedalign_test.gotool.Alignment tooling
align_test.go:StripHTMLHeadingMarker+HTMLAlignOptionspreset.testdata/html.python.golden.json: Python baseline as a{meta, items}document (meta records how to regenerate; no committed generator script, matching the markdown-golden convention introduced in Fix(parser): don't collapse markdown doc into one item when a table is present infiniflow/ragflow#18014).testdata/html.sample.html: shared input sample.No chunker/wiring change was needed: the HTML parser already emits
OutputFormat:"json", and the chunker's table path preservesck_type, so the structured table item flows through unchanged.Test plan
bash build.sh --test ./internal/parser/parser/...→ok(full package, ~20s), including the four new tests.Base / stacking
This PR stacks on
fix/markdown-parser-align(PR infiniflow#18014) because it reuses thealign_test.goframework (HTMLAlignOptions,LoadGolden{meta, items}contract) introduced there.origin/maindoes not yet contain that framework, so this is not based onmain.Follow-up
The branch name includes
epub; EPUB parser alignment is a separate follow-up and is intentionally not part of this PR.