docling-core 2.12.1__py3-none-any.whl → 2.13.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of docling-core might be problematic. Click here for more details.

@@ -14,7 +14,7 @@ import warnings
14
14
  from io import BytesIO
15
15
  from pathlib import Path
16
16
  from typing import Any, Dict, Final, List, Literal, Optional, Tuple, Union
17
- from urllib.parse import unquote
17
+ from urllib.parse import quote, unquote
18
18
 
19
19
  import pandas as pd
20
20
  import yaml
@@ -830,7 +830,7 @@ class PictureItem(FloatingItem):
830
830
  ):
831
831
  return default_response
832
832
 
833
- text = f"\n![Image]({str(self.image.uri)})\n"
833
+ text = f"\n![Image]({quote(str(self.image.uri))})\n"
834
834
  return text
835
835
 
836
836
  else:
@@ -884,7 +884,7 @@ class PictureItem(FloatingItem):
884
884
  ):
885
885
  return default_response
886
886
 
887
- img_text = f'<img src="{str(self.image.uri)}">'
887
+ img_text = f'<img src="{quote(str(self.image.uri))}">'
888
888
  return f"<figure>{caption_text}{img_text}</figure>"
889
889
 
890
890
  else:
@@ -1,12 +1,12 @@
1
1
  """Models for the labels types."""
2
2
 
3
3
  from enum import Enum
4
+ from typing import Tuple
4
5
 
5
6
 
6
7
  class DocItemLabel(str, Enum):
7
8
  """DocItemLabel."""
8
9
 
9
- # DocLayNet v2
10
10
  CAPTION = "caption"
11
11
  FOOTNOTE = "footnote"
12
12
  FORMULA = "formula"
@@ -26,13 +26,39 @@ class DocItemLabel(str, Enum):
26
26
  KEY_VALUE_REGION = "key_value_region"
27
27
 
28
28
  # Additional labels for markup-based formats (e.g. HTML, Word)
29
- PARAGRAPH = "paragraph" # explicitly a paragraph and not arbitrary text
29
+ PARAGRAPH = "paragraph"
30
30
  REFERENCE = "reference"
31
31
 
32
32
  def __str__(self):
33
33
  """Get string value."""
34
34
  return str(self.value)
35
35
 
36
+ @staticmethod
37
+ def get_color(label: "DocItemLabel") -> Tuple[int, int, int]:
38
+ """Return the RGB color associated with a given label."""
39
+ color_map = {
40
+ DocItemLabel.CAPTION: (255, 204, 153),
41
+ DocItemLabel.FOOTNOTE: (200, 200, 255),
42
+ DocItemLabel.FORMULA: (192, 192, 192),
43
+ DocItemLabel.LIST_ITEM: (153, 153, 255),
44
+ DocItemLabel.PAGE_FOOTER: (204, 255, 204),
45
+ DocItemLabel.PAGE_HEADER: (204, 255, 204),
46
+ DocItemLabel.PICTURE: (255, 204, 164),
47
+ DocItemLabel.SECTION_HEADER: (255, 153, 153),
48
+ DocItemLabel.TABLE: (255, 204, 204),
49
+ DocItemLabel.TEXT: (255, 255, 153),
50
+ DocItemLabel.TITLE: (255, 153, 153),
51
+ DocItemLabel.DOCUMENT_INDEX: (220, 220, 220),
52
+ DocItemLabel.CODE: (125, 125, 125),
53
+ DocItemLabel.CHECKBOX_SELECTED: (255, 182, 193),
54
+ DocItemLabel.CHECKBOX_UNSELECTED: (255, 182, 193),
55
+ DocItemLabel.FORM: (200, 255, 255),
56
+ DocItemLabel.KEY_VALUE_REGION: (183, 65, 14),
57
+ DocItemLabel.PARAGRAPH: (255, 255, 153),
58
+ DocItemLabel.REFERENCE: (176, 224, 230),
59
+ }
60
+ return color_map[label]
61
+
36
62
 
37
63
  class GroupLabel(str, Enum):
38
64
  """GroupLabel."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: docling-core
3
- Version: 2.12.1
3
+ Version: 2.13.1
4
4
  Summary: A python library to define and validate data types in Docling.
5
5
  Home-page: https://ds4sd.github.io/
6
6
  License: MIT
@@ -24,8 +24,8 @@ docling_core/types/__init__.py,sha256=MVRSgsk5focwGyAplh_TRR3dEecIXpd98g_u3zZ5HX
24
24
  docling_core/types/base.py,sha256=PusJskRVL19y-hq0BgXr5e8--QEqSqLnFNJ8UbOqW88,8318
25
25
  docling_core/types/doc/__init__.py,sha256=bEL4zKVOG7Wxm6xQrgF58mu-Teds9aSavuEAKVNhrTU,639
26
26
  docling_core/types/doc/base.py,sha256=_ttU8QI8wXDTQRUnN5n7L6D9wYFVLSAibxlFoMbgAsk,4557
27
- docling_core/types/doc/document.py,sha256=2W4wZunI0K_EOxNtY5jbKeyw7bYWKKNLiljxfN8anHc,91844
28
- docling_core/types/doc/labels.py,sha256=Pc5avKtGM2fv-w7mXinoxs9BkhktmFaJ6ACsgFiAAm4,1702
27
+ docling_core/types/doc/document.py,sha256=ZHQBozH4-85p0YNBjzpTFURmTOenUrOwRyNr67shVcs,91865
28
+ docling_core/types/doc/labels.py,sha256=7fzopzvUhnSUalKumQvxSUCutbvEh9aUIKvJ1WKA_lU,2888
29
29
  docling_core/types/doc/tokens.py,sha256=uU_MYW_p7ypf7eYICFBvxdnVaPZ7CQnvZmbJ6oPrtEA,6134
30
30
  docling_core/types/doc/utils.py,sha256=YDOh_ZD1Y7OmCEDdCLJ_MO5K3HA67nc_acfhOK6WztU,1439
31
31
  docling_core/types/gen/__init__.py,sha256=C6TuCfvpSnSL5XDOFMcYHUY2-i08vvfOGRcdu6Af0pI,124
@@ -56,8 +56,8 @@ docling_core/utils/generate_jsonschema.py,sha256=uNX1O5XnjyB5nA66XqZXTt3YbGuR2ty
56
56
  docling_core/utils/legacy.py,sha256=xfp7U0JqjI60K3loWiNTk8w08_KfCUzTb2MNULBOIz4,24396
57
57
  docling_core/utils/validate.py,sha256=aQ11UbFyl8iD_N7yTTZmm_VVeXz8KcCyn3GLXgkfYRM,2049
58
58
  docling_core/utils/validators.py,sha256=azcrndLzhNkTWnbFSu9shJ5D3j_znnLrIFA5R8hzmGU,2798
59
- docling_core-2.12.1.dist-info/LICENSE,sha256=2M9-6EoQ1sxFztTOkXGAtwUDJvnWaAHdB9BYWVwGkIw,1087
60
- docling_core-2.12.1.dist-info/METADATA,sha256=7GQuAsiJL6EGBIEjeiX-XQs7gELqhCGWsNeSrsGm5Kk,5744
61
- docling_core-2.12.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
62
- docling_core-2.12.1.dist-info/entry_points.txt,sha256=oClcdb2L2RKx4jdqUykY16Kum_f0_whwWhGzIodyidc,216
63
- docling_core-2.12.1.dist-info/RECORD,,
59
+ docling_core-2.13.1.dist-info/LICENSE,sha256=2M9-6EoQ1sxFztTOkXGAtwUDJvnWaAHdB9BYWVwGkIw,1087
60
+ docling_core-2.13.1.dist-info/METADATA,sha256=xKJXvKHpi2TIOxxghWq6wxlg-U7QcAoF9WPZ1U0c0EU,5744
61
+ docling_core-2.13.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
62
+ docling_core-2.13.1.dist-info/entry_points.txt,sha256=oClcdb2L2RKx4jdqUykY16Kum_f0_whwWhGzIodyidc,216
63
+ docling_core-2.13.1.dist-info/RECORD,,