Enhance table title handling and improve heading detection logic

- Added logic to set `table_title` from `caption` if it is under 160 characters and not already set.
- Updated `_blocks_from_content_list` to assign `table_title` based on `caption` length.
- Introduced new regex patterns for better detection of TOC entries and noise.
- Enhanced heading detection to differentiate between numbered instructions and actual headings.
- Added tests to verify that table captions are correctly assigned as titles and that numbered instructions are treated as body text.
This commit is contained in:
陈辅元
2026-07-16 16:01:42 +08:00
parent 26461569c8
commit 8466ed2fbe
8 changed files with 275 additions and 22 deletions
+4
View File
@@ -184,6 +184,10 @@ def _bind_table_context(blocks: list[Block], index: int, meta: dict) -> None:
page = meta.get("page")
block = blocks[index]
caption = (meta.get("caption") or "").strip()
if caption and len(caption) <= 160 and not meta.get("table_title"):
meta["table_title"] = caption
for j in range(index - 1, -1, -1):
prev = blocks[j]
if prev.type == BlockType.TABLE: