Skip to content

Commit

Permalink
fix: fixed selection logic for a slice of the document (#66)
Browse files Browse the repository at this point in the history
Signed-off-by: Michele Dolfi <[email protected]>
  • Loading branch information
dolfim-ibm authored Nov 11, 2024
1 parent eb4c2ab commit dfdc76b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions docling_core/types/doc/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,8 +1284,8 @@ def export_to_markdown( # noqa: C901
) -> str:
r"""Serialize to Markdown.
Operates on a slice of the document's main_text as defined through arguments
main_text_start and main_text_stop; defaulting to the whole main_text.
Operates on a slice of the document's body as defined through arguments
from_element and to_element; defaulting to the whole document.
:param delim: Delimiter to use when concatenating the various
Markdown parts. Defaults to "\n\n".
Expand All @@ -1294,19 +1294,16 @@ def export_to_markdown( # noqa: C901
Defaults to 0.
:type from_element: int
:param to_element: Body slicing stop index
(exclusive). Defaults to None.
:type to_element: Optional[int]
(exclusive). Defaults to 0maxint.
:type to_element: int
:param delim: str: (Default value = "\n\n")
:param from_element: int: (Default value = 0)
:param to_element: Optional[int]: (Default value = None)
:param labels: set[DocItemLabel]
:param "subtitle-level-1":
:param "paragraph":
:param "caption":
:param "table":
:param "Text":
:param "text":
:param ]:
:param strict_text: bool: (Default value = False)
:param image_placeholder str: (Default value = "<!-- image -->")
the placeholder to include to position images in the markdown.
Expand All @@ -1331,7 +1328,7 @@ def export_to_markdown( # noqa: C901

previous_level = level # Update previous_level for next iteration

if ix < from_element and to_element <= ix:
if ix < from_element or to_element <= ix:
continue # skip as many items as you want

# Handle newlines between different types of content
Expand Down

0 comments on commit dfdc76b

Please sign in to comment.