Skip to content

Commit 88ce4cf

Browse files
Matteo-OmenettiMatteo-Omenetti
authored andcommitted
added code item
1 parent 00d3b0a commit 88ce4cf

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

docling_core/types/doc/document.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,7 +2134,7 @@ def export_to_markdown( # noqa: C901
21342134
text = f"{marker} {item.text}\n"
21352135
mdtexts.append(text.strip() + "\n")
21362136

2137-
elif isinstance(item, TextItem) and item.label in [DocItemLabel.CODE]:
2137+
elif isinstance(item, CodeItem) and item.label in labels:
21382138
in_list = False
21392139
text = f"```\n{item.text}\n```\n"
21402140
mdtexts.append(text)
@@ -2440,11 +2440,14 @@ def close_lists(
24402440
text = f"<li>{item.text}</li>"
24412441
html_texts.append(text)
24422442

2443+
elif isinstance(item, CodeItem) and item.label in labels:
2444+
text = f"<pre><code>{item.text}</code></pre>"
2445+
html_texts.append(text.strip())
2446+
24432447
elif isinstance(item, TextItem) and item.label in labels:
24442448

24452449
text = f"<p>{item.text}</p>"
24462450
html_texts.append(text.strip())
2447-
24482451
elif isinstance(item, TableItem):
24492452

24502453
text = item.export_to_html(doc=self, add_caption=True)
@@ -2642,6 +2645,17 @@ def close_lists(
26422645
add_content=add_content,
26432646
add_page_index=add_page_index,
26442647
)
2648+
elif isinstance(item, CodeItem) and (item.label in labels):
2649+
2650+
result += item.export_to_document_tokens(
2651+
doc=self,
2652+
new_line=delim,
2653+
xsize=xsize,
2654+
ysize=ysize,
2655+
add_location=add_location,
2656+
add_content=add_content,
2657+
add_page_index=add_page_index,
2658+
)
26452659

26462660
elif isinstance(item, TextItem) and (item.label in labels):
26472661

0 commit comments

Comments
 (0)