|
25 | 25 | ) |
26 | 26 | from docling_core.transforms.visualizer.layout_visualizer import LayoutVisualizer |
27 | 27 | from docling_core.types.doc.base import ImageRefMode |
28 | | -from docling_core.types.doc.document import DoclingDocument, MiscAnnotation, TableItem |
| 28 | +from docling_core.types.doc.document import ( |
| 29 | + DoclingDocument, |
| 30 | + MiscAnnotation, |
| 31 | + TableCell, |
| 32 | + TableData, |
| 33 | + TableItem, |
| 34 | +) |
29 | 35 | from docling_core.types.doc.labels import DocItemLabel |
30 | 36 |
|
31 | 37 | from .test_data_gen_flag import GEN_TEST_DATA |
@@ -317,6 +323,29 @@ def test_md_rich_table(): |
317 | 323 | verify(exp_file=exp_file, actual=actual) |
318 | 324 |
|
319 | 325 |
|
| 326 | +def test_md_single_row_table(): |
| 327 | + exp_file = Path("./test/data/doc/single_row_table.gt.md") |
| 328 | + words = ["foo", "bar"] |
| 329 | + doc = DoclingDocument(name="") |
| 330 | + row_idx = 0 |
| 331 | + table = doc.add_table(data=TableData(num_rows=1, num_cols=len(words))) |
| 332 | + for col_idx, word in enumerate(words): |
| 333 | + doc.add_table_cell( |
| 334 | + table_item=table, |
| 335 | + cell=TableCell( |
| 336 | + start_row_offset_idx=row_idx, |
| 337 | + end_row_offset_idx=row_idx + 1, |
| 338 | + start_col_offset_idx=col_idx, |
| 339 | + end_col_offset_idx=col_idx + 1, |
| 340 | + text=word, |
| 341 | + ), |
| 342 | + ) |
| 343 | + |
| 344 | + ser = MarkdownDocSerializer(doc=doc) |
| 345 | + actual = ser.serialize().text |
| 346 | + verify(exp_file=exp_file, actual=actual) |
| 347 | + |
| 348 | + |
320 | 349 | # =============================== |
321 | 350 | # HTML tests |
322 | 351 | # =============================== |
|
0 commit comments