Skip to content

Commit 7267c3f

Browse files
authored
fix: Fix inheritance of CodeItem for backward compatibility (#162)
* fix: Fix inheritance of CodeItem for backward compatibility Signed-off-by: Christoph Auer <[email protected]> * Update docs Signed-off-by: Christoph Auer <[email protected]> --------- Signed-off-by: Christoph Auer <[email protected]>
1 parent 916323f commit 7267c3f

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

docling_core/types/doc/document.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,14 +767,12 @@ def get_image(self, doc: "DoclingDocument") -> Optional[PILImage.Image]:
767767
return super().get_image(doc=doc)
768768

769769

770-
class CodeItem(FloatingItem):
770+
class CodeItem(FloatingItem, TextItem):
771771
"""CodeItem."""
772772

773773
label: typing.Literal[DocItemLabel.CODE] = (
774774
DocItemLabel.CODE # type: ignore[assignment]
775775
)
776-
orig: str # untreated representation
777-
text: str # sanitized representation
778776
code_language: CodeLanguageLabel = CodeLanguageLabel.UNKNOWN
779777

780778
def export_to_document_tokens(

docs/DoclingDocument.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,14 @@
208208
"title": "Prov",
209209
"type": "array"
210210
},
211+
"orig": {
212+
"title": "Orig",
213+
"type": "string"
214+
},
215+
"text": {
216+
"title": "Text",
217+
"type": "string"
218+
},
211219
"captions": {
212220
"default": [],
213221
"items": {
@@ -243,14 +251,6 @@
243251
],
244252
"default": null
245253
},
246-
"orig": {
247-
"title": "Orig",
248-
"type": "string"
249-
},
250-
"text": {
251-
"title": "Text",
252-
"type": "string"
253-
},
254254
"code_language": {
255255
"$ref": "#/$defs/CodeLanguageLabel",
256256
"default": "unknown"

0 commit comments

Comments
 (0)