Skip to content

Commit

Permalink
added the strict-text in the to-md method
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Staar <[email protected]>
  • Loading branch information
PeterStaar-IBM committed Sep 9, 2024
1 parent 3999028 commit be49711
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions docling_core/types/doc/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ def export_to_markdown(
"caption",
"table",
],
strict_text: bool = False,
) -> str:
r"""Serialize to Markdown.
Expand Down Expand Up @@ -562,14 +563,20 @@ def export_to_markdown(

# first title match
if item_type == "title" and not has_title:
markdown_text = f"# {text}"
if strict_text:
markdown_text = f"{text}"
else:
markdown_text = f"# {text}"
has_title = True

# secondary titles
elif item_type in {"title", "subtitle-level-1"} or (
has_title and item_type == "title"
):
markdown_text = f"## {text}"
if strict_text:
markdown_text = f"{text}"
else:
markdown_text = f"## {text}"

# normal text
else:
Expand All @@ -579,6 +586,7 @@ def export_to_markdown(
isinstance(item, Table)
and item.data
and item_type in main_text_labels
and not strict_text
):
table = []
for row in item.data:
Expand Down

0 comments on commit be49711

Please sign in to comment.