fix(docparser): normalize PaddleOCR-VL HTML tables (#1725)
PaddleOCR-VL renders tables as HTML with per-cell text-align styles. These waste tokens on layout markup and bypass the chunker's table-protection logic (which only recognizes Markdown pipe tables), causing large tables to be split mid-row. Convert inline HTML <table> blocks to GFM Markdown tables when possible, and strip presentational attributes (style/class/align/...) for tables using rowspan/colspan that Markdown cannot express. Refs: https://github.com/Tencent/WeKnora/issues/1725
This commit is contained in:
@@ -58,6 +58,12 @@ func (c *PaddleOCRVLReader) Read(ctx context.Context, req *types.ReadRequest) (*
|
||||
return nil, fmt.Errorf("PaddleOCR-VL layout-parsing: %w", err)
|
||||
}
|
||||
|
||||
// PaddleOCR-VL renders tables as styled HTML (per-cell text-align), which
|
||||
// wastes tokens and defeats the chunker's table-protection logic. Convert
|
||||
// them to Markdown tables (or strip layout attributes when conversion is
|
||||
// not possible) before downstream processing.
|
||||
mdContent = normalizeHTMLTables(mdContent)
|
||||
|
||||
imageRefs, mdContent := c.processImages(mdContent, imagesB64)
|
||||
mdContent, imageRefs = ensureOriginalImageRef(req, mdContent, imageRefs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user