Fix Markdown parser, the table should be inside chunk (#17477)

This commit is contained in:
Wang Qi
2026-07-28 16:00:52 +08:00
committed by GitHub
parent 675c35a2de
commit b8bb2297f9
3 changed files with 12 additions and 11 deletions

View File

@@ -899,7 +899,7 @@ class Markdown(MarkdownParser):
txt = f.read()
remainder, tables = self.extract_tables_and_remainder(f"{txt}\n", separate_tables=separate_tables)
parsing_text = remainder if separate_tables else txt
parsing_text = remainder
extractor = MarkdownElementExtractor(parsing_text)
image_refs = self.extract_image_urls_with_lines(parsing_text)
element_sections = extractor.extract_elements(delimiter, include_meta=True)
@@ -922,8 +922,9 @@ class Markdown(MarkdownParser):
section_images.append(combined_image)
tbls = []
for table in tables:
tbls.append(((None, markdown(table, extensions=["markdown.extensions.tables"])), ""))
if separate_tables:
for table in tables:
tbls.append(((None, markdown(table, extensions=["markdown.extensions.tables"])), ""))
if return_section_images:
return sections, tbls, section_images
return sections, tbls
@@ -1128,7 +1129,7 @@ def chunk(filename, binary=None, from_page=0, to_page=MAXIMUM_PAGE_NUMBER, lang=
sections, tables, section_images = markdown_parser(
filename,
binary,
separate_tables=True,
separate_tables=False,
delimiter=parser_config.get("delimiter", "\n!?;。;!?"),
return_section_images=True,
)

View File

@@ -1074,7 +1074,7 @@ class Parser(ProcessBase):
sections, tables, section_images = markdown_parser(
name,
blob,
separate_tables=True,
separate_tables=False,
delimiter=conf.get("delimiter"),
return_section_images=True,
)