Skip to content

Commit dd52913

Browse files
authored
Fix: markdown table double extraction in parser (#13892)
### What problem does this PR solve? Fixes markdown tables being parsed twice (once as markdown and again as generated HTML), which caused duplicate table chunks in the chunk list UI. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
1 parent 1c2c4b3 commit dd52913

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

deepdoc/parser/markdown_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def replace_tables_with_rendered_html(pattern, table_list, render=True):
5656
""",
5757
re.VERBOSE,
5858
)
59-
working_text = replace_tables_with_rendered_html(border_table_pattern, tables)
59+
working_text = replace_tables_with_rendered_html(border_table_pattern, tables, render=separate_tables)
6060

6161
# Borderless Markdown table
6262
no_border_table_pattern = re.compile(
@@ -68,7 +68,7 @@ def replace_tables_with_rendered_html(pattern, table_list, render=True):
6868
""",
6969
re.VERBOSE,
7070
)
71-
working_text = replace_tables_with_rendered_html(no_border_table_pattern, tables)
71+
working_text = replace_tables_with_rendered_html(no_border_table_pattern, tables, render=separate_tables)
7272

7373
# Replace any TAGS e.g. <table ...> to <table>
7474
TAGS = ["table", "td", "tr", "th", "tbody", "thead", "div"]

test/testcases/test_sdk_api/test_chunk_management_within_dataset/conftest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#
1616

1717

18-
from time import sleep
1918

2019
import pytest
2120
from common import batch_add_chunks, delete_all_chunks
@@ -32,6 +31,10 @@ def condition(_dataset: DataSet):
3231
return False
3332
return True
3433

34+
@wait_for(30, 1, "Chunk indexing timeout")
35+
def chunks_visible(_document: Document, _chunk_ids: list[str]):
36+
visible_ids = {chunk.id for chunk in _document.list_chunks(page_size=1000)}
37+
return set(_chunk_ids).issubset(visible_ids)
3538

3639
@pytest.fixture(scope="function")
3740
def add_chunks_func(request: FixtureRequest, add_document: tuple[DataSet, Document]) -> tuple[DataSet, Document, list[Chunk]]:
@@ -47,6 +50,5 @@ def cleanup():
4750
dataset.async_parse_documents([document.id])
4851
condition(dataset)
4952
chunks = batch_add_chunks(document, 4)
50-
# issues/6487
51-
sleep(1)
53+
chunks_visible(document, [chunk.id for chunk in chunks])
5254
return dataset, document, chunks

0 commit comments

Comments
 (0)