mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-17 22:08:29 +08:00
refactor(parser): drop unreachable fallback in walkHTMLLeaf table case
renderTableHTML only fails on unsupported node kinds, which a parsed <table> never triggers, so the degenerate flatten-children branch in walkHTMLLeaf is unreachable. Remove it so the nested-table path matches the top-level walkHTMLBlocks case (both skip silently when the markup is empty). Also tighten the inaccurate 'mirrors Python's HtmlParser' inline comment in the same block (the two-item split is the markdown_parser.go model; Python keeps the table once, outside the inline flow).
This commit is contained in:
@@ -324,11 +324,11 @@ func walkHTMLLeaf(n *html.Node, w *leafWriter, tableItems *[]map[string]any) {
|
||||
// Keep the table as its full HTML markup (NOT flattened) so
|
||||
// row/column structure survives into the wrapper's text item,
|
||||
// embedding, retrieval, and LLM rendering. This mirrors the
|
||||
// top-level walkHTMLBlocks "table" case and Python's HtmlParser,
|
||||
// and covers tables nested in div/section/article/… (which the
|
||||
// walkHTMLBlocks case never reaches). The structured table item
|
||||
// is collected for the downstream chunker (appended after the
|
||||
// walk by the caller, same as the top-level path).
|
||||
// top-level walkHTMLBlocks "table" case, and covers tables nested
|
||||
// in div/section/article/… (which the walkHTMLBlocks case never
|
||||
// reaches). The structured table item is collected for the
|
||||
// downstream chunker (appended after the walk by the caller, same
|
||||
// as the top-level path).
|
||||
markup := renderTableHTML(n)
|
||||
if strings.TrimSpace(markup) != "" {
|
||||
w.writeText(markup)
|
||||
@@ -337,12 +337,6 @@ func walkHTMLLeaf(n *html.Node, w *leafWriter, tableItems *[]map[string]any) {
|
||||
"doc_type_kwd": "table",
|
||||
"ck_type": "table",
|
||||
})
|
||||
} else {
|
||||
// Degenerate: render failed; flatten children without markup
|
||||
// so we never drop the cell text entirely.
|
||||
for child := n.FirstChild; child != nil; child = child.NextSibling {
|
||||
walkHTMLLeaf(child, w, tableItems)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user