From b3f9bed8a026a152e2f1bf0b3151c842e5861fe3 Mon Sep 17 00:00:00 2001 From: xugangqiang Date: Tue, 11 Aug 2026 15:48:24 +0800 Subject: [PATCH] refactor(parser): preserve HTML structure (inline + structured item) Stop flattening
into a single text blob. A
now emits: 1. an inlined doc_type_kwd:"text" item keeping the
...
markup (row/column structure survives for embedding/retrieval/LLM rendering), and 2. a structured doc_type_kwd:"table" / ck_type:"table" item appended after the walk, consumed by the downstream chunker. Covers both top-level tables (walkHTMLBlocks) and tables nested in div/section/article (via walkHTMLLeaf). Mirrors markdown_parser.go table handling and Python's RAGFlowHtmlParser. Tests: - TestHTMLParser_TableProducesStructuredItems - TestHTMLParser_NestedTableProducesStructuredItems - TestHTMLParser_NestedListItemsPreserved - TestHTMLParser_PrePreservesVerbatim - TestHTMLParser_AlignmentGolden (compares vs html.python.golden.json, ignores "table" via meta.accepted_divergences) Depends on #18014 and the foundation helpers PR (align_test.go). Files: internal/parser/parser/html_parser.go internal/parser/parser/html_parser_align_test.go (new) internal/parser/parser/testdata/html.python.golden.json (new) internal/parser/parser/testdata/html.sample.html (new) --- internal/parser/parser/html_parser.go | 90 ++++- .../parser/parser/html_parser_align_test.go | 368 ++++++++++++++++++ .../parser/testdata/html.python.golden.json | 33 ++ .../parser/parser/testdata/html.sample.html | 11 + 4 files changed, 495 insertions(+), 7 deletions(-) create mode 100644 internal/parser/parser/html_parser_align_test.go create mode 100644 internal/parser/parser/testdata/html.python.golden.json create mode 100644 internal/parser/parser/testdata/html.sample.html diff --git a/internal/parser/parser/html_parser.go b/internal/parser/parser/html_parser.go index 313f080843..3704f0b9da 100644 --- a/internal/parser/parser/html_parser.go +++ b/internal/parser/parser/html_parser.go @@ -107,6 +107,10 @@ func (p *HTMLParser) ParseWithResult(ctx context.Context, filename string, data //