Skip to content

Commit dfdc76b

Browse files
authored
fix: fixed selection logic for a slice of the document (#66)
Signed-off-by: Michele Dolfi <[email protected]>
1 parent eb4c2ab commit dfdc76b

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

docling_core/types/doc/document.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,8 +1284,8 @@ def export_to_markdown( # noqa: C901
12841284
) -> str:
12851285
r"""Serialize to Markdown.
12861286
1287-
Operates on a slice of the document's main_text as defined through arguments
1288-
main_text_start and main_text_stop; defaulting to the whole main_text.
1287+
Operates on a slice of the document's body as defined through arguments
1288+
from_element and to_element; defaulting to the whole document.
12891289
12901290
:param delim: Delimiter to use when concatenating the various
12911291
Markdown parts. Defaults to "\n\n".
@@ -1294,19 +1294,16 @@ def export_to_markdown( # noqa: C901
12941294
Defaults to 0.
12951295
:type from_element: int
12961296
:param to_element: Body slicing stop index
1297-
(exclusive). Defaults to None.
1298-
:type to_element: Optional[int]
1297+
(exclusive). Defaults to 0maxint.
1298+
:type to_element: int
12991299
:param delim: str: (Default value = "\n\n")
1300-
:param from_element: int: (Default value = 0)
1301-
:param to_element: Optional[int]: (Default value = None)
13021300
:param labels: set[DocItemLabel]
13031301
:param "subtitle-level-1":
13041302
:param "paragraph":
13051303
:param "caption":
13061304
:param "table":
13071305
:param "Text":
13081306
:param "text":
1309-
:param ]:
13101307
:param strict_text: bool: (Default value = False)
13111308
:param image_placeholder str: (Default value = "<!-- image -->")
13121309
the placeholder to include to position images in the markdown.
@@ -1331,7 +1328,7 @@ def export_to_markdown( # noqa: C901
13311328

13321329
previous_level = level # Update previous_level for next iteration
13331330

1334-
if ix < from_element and to_element <= ix:
1331+
if ix < from_element or to_element <= ix:
13351332
continue # skip as many items as you want
13361333

13371334
# Handle newlines between different types of content

0 commit comments

Comments
 (0)