Skip to content

Commit 53f6d09

Browse files
authored
fix(doctags): fix code export (#181)
Signed-off-by: Panos Vagenas <[email protected]>
1 parent 834db4b commit 53f6d09

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

docling_core/types/doc/document.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ def export_to_document_tokens(
800800
:param add_content: bool: (Default value = True)
801801
802802
"""
803-
body = f"<{self.label.value}{new_line}"
803+
body = f"<{self.label.value}>{new_line}"
804804

805805
if add_location:
806806
body += self.get_location_tokens(
@@ -813,7 +813,7 @@ def export_to_document_tokens(
813813
if add_content and self.text is not None:
814814
body += f"<_{self.code_language.value}_>{self.text}{new_line}"
815815

816-
body += f"</{self.label.value}\n"
816+
body += f"</{self.label.value}>\n"
817817

818818
return body
819819

test/data/doc/constructed_doc.dt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Affiliation 2</text>
3030
<list_item>item 2 of neighboring list</list_item>
3131
<unordered_list><list_item>item 1 of sub list</list_item>
3232
<paragraph>Here a code snippet:</paragraph>
33-
<code<_unknown_><p>Hello world</p></code
33+
<code><_unknown_><p>Hello world</p></code>
3434
<paragraph>(to be displayed inline)</paragraph>
3535
</unordered_list>
3636
<paragraph>Here a formula:</paragraph>
@@ -39,7 +39,7 @@ Affiliation 2</text>
3939
</unordered_list>
4040
</unordered_list>
4141
<paragraph>Here a code block:</paragraph>
42-
<code<_unknown_>print("Hello world")</code
42+
<code><_unknown_>print("Hello world")</code>
4343
<paragraph>Here a formula block:</paragraph>
4444
<formula>E=mc^2</formula>
4545
<paragraph>The end.</paragraph>

test/data/doc/constructed_doc.dt.gt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Affiliation 2</text>
3030
<list_item>item 2 of neighboring list</list_item>
3131
<unordered_list><list_item>item 1 of sub list</list_item>
3232
<paragraph>Here a code snippet:</paragraph>
33-
<code<_unknown_><p>Hello world</p></code
33+
<code><_unknown_><p>Hello world</p></code>
3434
<paragraph>(to be displayed inline)</paragraph>
3535
</unordered_list>
3636
<paragraph>Here a formula:</paragraph>
@@ -39,7 +39,7 @@ Affiliation 2</text>
3939
</unordered_list>
4040
</unordered_list>
4141
<paragraph>Here a code block:</paragraph>
42-
<code<_unknown_>print("Hello world")</code
42+
<code><_unknown_>print("Hello world")</code>
4343
<paragraph>Here a formula block:</paragraph>
4444
<formula>E=mc^2</formula>
4545
<paragraph>The end.</paragraph>

test/data/doc/constructed_document.yaml.dt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Affiliation 2</text>
3030
<list_item>item 2 of neighboring list</list_item>
3131
<unordered_list><list_item>item 1 of sub list</list_item>
3232
<paragraph>Here a code snippet:</paragraph>
33-
<code<_unknown_><p>Hello world</p></code
33+
<code><_unknown_><p>Hello world</p></code>
3434
<paragraph>(to be displayed inline)</paragraph>
3535
</unordered_list>
3636
<paragraph>Here a formula:</paragraph>
@@ -39,7 +39,7 @@ Affiliation 2</text>
3939
</unordered_list>
4040
</unordered_list>
4141
<paragraph>Here a code block:</paragraph>
42-
<code<_unknown_>print("Hello world")</code
42+
<code><_unknown_>print("Hello world")</code>
4343
<paragraph>Here a formula block:</paragraph>
4444
<formula>E=mc^2</formula>
4545
<paragraph>The end.</paragraph>

0 commit comments

Comments
 (0)