python-docx-oss 0.5.1__py3-none-any.whl → 0.5.2__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.
docx/__init__.py CHANGED
@@ -15,7 +15,7 @@ from docx.transforms import normalize, repair
15
15
  if TYPE_CHECKING:
16
16
  from docx.opc.part import Part
17
17
 
18
- __version__ = "0.5.1"
18
+ __version__ = "0.5.2"
19
19
 
20
20
 
21
21
  __all__ = [
@@ -17,6 +17,8 @@ W = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
17
17
  R = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
18
18
  XML_SPACE = "{http://www.w3.org/XML/1998/namespace}space"
19
19
  Selector = Callable[[HyperlinkTarget], bool]
20
+ _ARGUMENT_SWITCHES = frozenset((r"\l", r"\o", r"\t", r"\*"))
21
+ _SUPPORTED_SWITCHES = _ARGUMENT_SWITCHES | {r"\h"}
20
22
 
21
23
 
22
24
  def w(name: str) -> str:
@@ -29,6 +31,7 @@ class _Instruction:
29
31
  anchor: str | None
30
32
  tooltip: str | None = None
31
33
  frame: str | None = None
34
+ has_h_switch: bool = False
32
35
 
33
36
 
34
37
  def _instruction(text: str) -> _Instruction | None:
@@ -41,13 +44,19 @@ def _instruction(text: str) -> _Instruction | None:
41
44
  address = tokens[index][0]
42
45
  index += 1
43
46
  options: dict[str, str] = {}
47
+ has_h_switch = False
44
48
  while index < len(tokens):
45
49
  key, quoted = tokens[index]
46
50
  key = key.lower()
47
51
  index += 1
52
+ if key == "\\h" and not quoted:
53
+ if has_h_switch:
54
+ return None
55
+ has_h_switch = True
56
+ continue
48
57
  if (
49
58
  quoted
50
- or key not in ("\\l", "\\o", "\\t", "\\*")
59
+ or key not in _ARGUMENT_SWITCHES
51
60
  or index == len(tokens)
52
61
  or not tokens[index][1]
53
62
  and tokens[index][0].startswith("\\")
@@ -61,7 +70,13 @@ def _instruction(text: str) -> _Instruction | None:
61
70
  anchor = options.get("\\l")
62
71
  if not address and not anchor:
63
72
  return None
64
- return _Instruction(address or None, anchor, options.get("\\o"), options.get("\\t"))
73
+ return _Instruction(
74
+ address or None,
75
+ anchor,
76
+ options.get("\\o"),
77
+ options.get("\\t"),
78
+ has_h_switch=has_h_switch,
79
+ )
65
80
 
66
81
 
67
82
  def _field_tokens(text: str) -> list[tuple[str, bool]] | None:
@@ -96,7 +111,7 @@ def _field_tokens(text: str) -> list[tuple[str, bool]] | None:
96
111
  while index < len(text) and not text[index].isspace():
97
112
  index += 1
98
113
  token = text[start:index]
99
- if '"' in token or "\\" in token and token.lower() not in ("\\l", "\\o", "\\t", "\\*"):
114
+ if '"' in token or "\\" in token and token.lower() not in _SUPPORTED_SWITCHES:
100
115
  return None
101
116
  tokens.append((token, False))
102
117
  return tokens
@@ -176,6 +191,8 @@ class HyperlinkNormalizer:
176
191
  ):
177
192
  if value is not None:
178
193
  link.set(w(name), value)
194
+ if instruction.has_h_switch:
195
+ link.set(w("history"), "false")
179
196
  return link
180
197
 
181
198
  def _protected(self, element: etree_Element) -> bool:
@@ -0,0 +1,135 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-docx-oss
3
+ Version: 0.5.2
4
+ Summary: Create, read, and update Microsoft Word .docx files.
5
+ Author: Ethan St Lee
6
+ License-Expression: MIT
7
+ Project-URL: Changelog, https://github.com/lsaint/python-docx-oss/blob/master/HISTORY.md
8
+ Project-URL: Documentation, https://python-docx-oss.readthedocs.io/en/latest/
9
+ Project-URL: Issues, https://github.com/lsaint/python-docx-oss/issues
10
+ Project-URL: Repository, https://github.com/lsaint/python-docx-oss
11
+ Keywords: docx,office,openxml,word
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: Office/Business :: Office Suites
22
+ Classifier: Topic :: Software Development :: Libraries
23
+ Requires-Python: >=3.12
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: lxml>=6.1.0
27
+ Requires-Dist: typing_extensions>=4.9.0
28
+ Dynamic: license-file
29
+
30
+ <p align="center">
31
+ <img src="https://raw.githubusercontent.com/lsaint/python-docx-oss/master/docs/_static/img/oss.png" width="400" alt="python-docx-oss"/>
32
+ </p>
33
+
34
+ <p align="center">
35
+ <strong>A Python SDK for advanced creation and manipulation of Microsoft Word <code>.docx</code> files.</strong>
36
+ </p>
37
+
38
+ <p align="center">
39
+ <a href="https://pypi.org/project/python-docx-oss/"><img alt="PyPI" src="https://img.shields.io/pypi/v/python-docx-oss"></a>
40
+ <a href="https://pypi.org/project/python-docx-oss/"><img alt="Python versions" src="https://img.shields.io/pypi/pyversions/python-docx-oss.svg"></a>
41
+ <a href="https://github.com/astral-sh/ruff"><img alt="Code style: Ruff" src="https://img.shields.io/badge/code%20style-ruff-FF6B6B.svg?logo=ruff&logoColor=white"></a>
42
+ <a href="https://github.com/lsaint/python-docx-oss/blob/master/LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg"></a>
43
+ </p>
44
+
45
+ ## Overview
46
+
47
+ `python-docx-oss` is an independently evolving DOCX SDK built on the proven API
48
+ foundation of [`python-docx`](https://github.com/python-openxml/python-docx). It keeps
49
+ the familiar `docx` programming model while extending it for advanced OOXML and Open
50
+ Packaging Convention (OPC) workflows.
51
+
52
+ Use it when an application needs more than basic paragraphs and tables: custom document
53
+ metadata, application-owned XML, vector images, floating pictures, East Asian fonts,
54
+ package inspection, configurable fingerprints, repair, or low-level package and relationship access.
55
+
56
+ [Documentation](https://python-docx-oss.readthedocs.io/en/latest/) · [API Reference](docs/index.rst#api-documentation) · [Release History](HISTORY.md)
57
+
58
+ ## Capability Matrix
59
+
60
+ | Capability | Primary API / Behavior |
61
+ | --- | --- |
62
+ | **Major additions** | |
63
+ | [Custom document properties](docs/user/custom-properties.rst) | `document.custom_properties` |
64
+ | [Custom XML lifecycle](docs/user/custom-xml.rst) | `add_custom_xml_part()`, `delete_custom_xml_part()` |
65
+ | [SVG and EMF images](docs/user/shapes.rst) | `add_picture()` |
66
+ | [Floating pictures](docs/user/shapes.rst) | `add_float_picture()` |
67
+ | [Latin and East Asian font controls](docs/user/text.rst) | `run.font.name`, `run.font.hAnsi`, `run.font.eastAsia` |
68
+ | [Low-level OPC parts and relationships](docs/user/api-concepts.rst) | `document.part.package`, `part.rels` |
69
+ | [In-memory read, export, and independent copies](docs/user/documents.rst) | `Document(bytes)`, `to_bytes()`, `copy()` |
70
+ | [Document sanitization](docs/user/sanitization.rst) | `document.sanitize()` |
71
+ | [Read-only package inspection and streaming feature scanning](docs/user/inspection.rst) | `inspect()`, `ScanEvent` |
72
+ | [Configurable package-content fingerprints](docs/user/inspection.rst#content-fingerprints) | `fingerprint()`, `FingerprintPolicy`, `serialize_xml` |
73
+ | [Explicit empty Custom XML repair and hyperlink normalization](docs/user/transformations.rst) | `repair()`, `normalize()` |
74
+ | **Major fixes and compatibility** | |
75
+ | [Strict Open XML compatibility](HISTORY.md#release-history) | Open Strict documents through `Document()` with transparent package normalization |
76
+ | [Table width and logical layout compatibility](HISTORY.md#release-history) | Read measurement and percentage widths, logical indentation, and `start` / `end` alignment |
77
+ | [lxml text extraction](docs/user/compatibility.rst#preservation-of-lxml-element-text-and-itertext-semantics) | Prevent duplicate `itertext()` output; preserve public `.text` APIs |
78
+
79
+ ## Installation
80
+
81
+ ```bash
82
+ python -m pip install python-docx-oss
83
+ ```
84
+
85
+ The distribution name is `python-docx-oss`, but the Python import namespace remains
86
+ `docx`:
87
+
88
+ ```python
89
+ from docx import Document
90
+ ```
91
+
92
+ > [!WARNING]
93
+ > `python-docx` and `python-docx-oss` provide the same `docx` import namespace. Do not
94
+ > install both distributions in the same Python environment.
95
+
96
+ ## Quick Start
97
+
98
+ Prepare a sharing copy with custom metadata, East Asian fonts, and a content fingerprint:
99
+
100
+ ```python
101
+ from docx import Document, fingerprint
102
+
103
+ internal = Document("internal-report.docx")
104
+ public = internal.copy() # Keep the original unchanged.
105
+
106
+ public.custom_properties["distribution"] = "public" # Set document metadata.
107
+ public.part.add_custom_xml_part('<report xmlns="urn:example:reports" id="Q4"/>')
108
+ public.add_paragraph().add_run("中文内容").font.eastAsia = "Microsoft YaHei"
109
+
110
+ public.sanitize(personal_metadata=True, comments=True) # Remove private info.
111
+ content = public.to_bytes() # Export without temporary files.
112
+ digest = fingerprint(content) # Compute a normalized package-content fingerprint.
113
+ ```
114
+
115
+ ## Compatibility and Scope
116
+
117
+ - The project maintains broad compatibility with the public `python-docx` API while
118
+ following its own versioning and product roadmap.
119
+ - Compatibility does not extend to every private or internal `python-docx` API. Test
120
+ those integrations before migrating production systems.
121
+ - The SDK focuses exclusively on DOCX. It is not a general XLSX/PPTX Office suite.
122
+ - It edits document structure but does not implement Word's page-layout rendering
123
+ engine.
124
+ - CLI, MCP, web, desktop, and Agent runtimes belong in separate packages that consume
125
+ this SDK.
126
+
127
+ ## Why “OSS”?
128
+
129
+ In Brazilian jiu-jitsu, “oss” is a greeting and an expression of respect. It reflects
130
+ the same spirit of discipline and collaboration behind this project.
131
+
132
+ ## Support
133
+
134
+ If this project is useful to you, you can support its continued development through
135
+ the [donation page](https://lsaint.github.io/donation/?utm_source=github&utm_medium=readme&utm_campaign=python-docx-oss).
@@ -1,4 +1,4 @@
1
- docx/__init__.py,sha256=T_j0EnG8oArUghKZI6ywWjUDHyp2OXFrRsuL5k4Hfd4,2389
1
+ docx/__init__.py,sha256=nN-TGDFrKx5bxPep8otvrWNZgnj6hFT7AtMi-5NyzkU,2389
2
2
  docx/api.py,sha256=jIojXW4IRDEXQqaqvmOZbzBvNeyRXv9ntHByxd-Kb0M,1518
3
3
  docx/blkcntnr.py,sha256=_xe7Uz3RBCz4TPKXpIzRxtGg-1YPb3gAG9YvsSUyoLU,3525
4
4
  docx/comments.py,sha256=MmaP7U9mZOUFsRhaZNIbXatqOOA8-pOC6UlqWAuTHsc,6385
@@ -136,13 +136,13 @@ docx/text/parfmt.py,sha256=PHv4-k1zAd1kFGXAFlDn4Sl4K5kJQ8Pz9F9M-TVmfhA,10419
136
136
  docx/text/run.py,sha256=QtIRn3mW_MMLgbRIfJhRmnKpDfcq7VnJEQKn1pfsY78,10802
137
137
  docx/text/tabstops.py,sha256=bJN98GWW22f4Sqg0dQbyUcnuOn65fHsNZuCGswI03_c,3896
138
138
  docx/transforms/__init__.py,sha256=_hwIWF2o_Q2SA3GSyjRtObgOlComR36qNdDAsv18nIg,426
139
- docx/transforms/hyperlinks.py,sha256=a0PwM16c26Y1L6w_UdWDuZgGP4AbVg810ssoTjyMpTI,15746
139
+ docx/transforms/hyperlinks.py,sha256=onLHvZwi0ms0YG-WwaEfvkHzbUibtFZfLoTmVhuwXrc,16200
140
140
  docx/transforms/normalize.py,sha256=zfTU6aCZGmdhB1bnK-njhgPQPYmFVdN8KKhQ5VbT3QQ,4012
141
141
  docx/transforms/package.py,sha256=QFNG0vfqVCr8itO7la4IfSY8rDS5A1cMnYNgMT7SKag,3637
142
142
  docx/transforms/repair.py,sha256=ajBgbi7OtET-wugWw315OrLsFrY0z7_rocJWNHPtGas,1989
143
143
  docx/transforms/result.py,sha256=vteKga-spWOMW0blpoF9tER4vb5tdZH_iXmN61vB-0c,1058
144
- python_docx_oss-0.5.1.dist-info/licenses/LICENSE,sha256=lf2yZv-riPwFeah3IMDeG0zqI6fXcV9T9YOToeG54NM,1164
145
- python_docx_oss-0.5.1.dist-info/METADATA,sha256=3-XJuk7O_jQB_Xr6kLIvE9T3dA0BkkDnXtKxNBQAml0,11037
146
- python_docx_oss-0.5.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
147
- python_docx_oss-0.5.1.dist-info/top_level.txt,sha256=zkbrD3gmyqHpD_XhHe7lCbr2M5vT229nJ4UFqF5VjIs,5
148
- python_docx_oss-0.5.1.dist-info/RECORD,,
144
+ python_docx_oss-0.5.2.dist-info/licenses/LICENSE,sha256=lf2yZv-riPwFeah3IMDeG0zqI6fXcV9T9YOToeG54NM,1164
145
+ python_docx_oss-0.5.2.dist-info/METADATA,sha256=Bvx2Pwwcky5YfwUeUKHS-EZ3Dk8X1qeItUHpgs2YXC8,6769
146
+ python_docx_oss-0.5.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
147
+ python_docx_oss-0.5.2.dist-info/top_level.txt,sha256=zkbrD3gmyqHpD_XhHe7lCbr2M5vT229nJ4UFqF5VjIs,5
148
+ python_docx_oss-0.5.2.dist-info/RECORD,,
@@ -1,272 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: python-docx-oss
3
- Version: 0.5.1
4
- Summary: Create, read, and update Microsoft Word .docx files.
5
- Author: Ethan St Lee
6
- License-Expression: MIT
7
- Project-URL: Changelog, https://github.com/lsaint/python-docx-oss/blob/master/HISTORY.md
8
- Project-URL: Documentation, https://python-docx-oss.readthedocs.io/en/latest/
9
- Project-URL: Issues, https://github.com/lsaint/python-docx-oss/issues
10
- Project-URL: Repository, https://github.com/lsaint/python-docx-oss
11
- Keywords: docx,office,openxml,word
12
- Classifier: Development Status :: 5 - Production/Stable
13
- Classifier: Environment :: Console
14
- Classifier: Intended Audience :: Developers
15
- Classifier: Operating System :: OS Independent
16
- Classifier: Programming Language :: Python
17
- Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3.12
19
- Classifier: Programming Language :: Python :: 3.13
20
- Classifier: Programming Language :: Python :: 3.14
21
- Classifier: Topic :: Office/Business :: Office Suites
22
- Classifier: Topic :: Software Development :: Libraries
23
- Requires-Python: >=3.12
24
- Description-Content-Type: text/markdown
25
- License-File: LICENSE
26
- Requires-Dist: lxml>=6.1.0
27
- Requires-Dist: typing_extensions>=4.9.0
28
- Dynamic: license-file
29
-
30
- <p align="center">
31
- <img src="https://raw.githubusercontent.com/lsaint/python-docx-oss/master/docs/_static/img/oss.png" width="400" alt="python-docx-oss"/>
32
- </p>
33
-
34
- <p align="center">
35
- <strong>A Python SDK for advanced creation and manipulation of Microsoft Word <code>.docx</code> files.</strong>
36
- </p>
37
-
38
- <p align="center">
39
- <a href="https://pypi.org/project/python-docx-oss/"><img alt="PyPI" src="https://img.shields.io/pypi/v/python-docx-oss"></a>
40
- <a href="https://pypi.org/project/python-docx-oss/"><img alt="Python versions" src="https://img.shields.io/pypi/pyversions/python-docx-oss.svg"></a>
41
- <a href="https://github.com/astral-sh/ruff"><img alt="Code style: Ruff" src="https://img.shields.io/badge/code%20style-ruff-FF6B6B.svg?logo=ruff&logoColor=white"></a>
42
- <a href="https://github.com/lsaint/python-docx-oss/blob/master/LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg"></a>
43
- </p>
44
-
45
- ## Overview
46
-
47
- `python-docx-oss` is an independently evolving DOCX SDK built on the proven API
48
- foundation of [`python-docx`](https://github.com/python-openxml/python-docx). It keeps
49
- the familiar `docx` programming model while extending it for advanced OOXML and Open
50
- Packaging Convention (OPC) workflows.
51
-
52
- Use it when an application needs more than basic paragraphs and tables: custom document
53
- metadata, application-owned XML, vector images, floating pictures, East Asian fonts,
54
- package inspection, configurable fingerprints, repair, or low-level package and relationship access.
55
-
56
- ## Capability Matrix
57
-
58
- | Capability | Status | Primary API |
59
- | --- | --- | --- |
60
- | [Documents, paragraphs, tables, styles, sections, headers, and footers](docs/user/quickstart.rst) | Stable | `Document()` and document object APIs |
61
- | [Custom document properties](docs/user/custom-properties.rst) | Stable | `document.custom_properties` |
62
- | [Custom XML lifecycle](docs/user/custom-xml.rst) | Stable | `add_custom_xml_part()`, `delete_custom_xml_part()` |
63
- | [SVG and EMF images](docs/user/shapes.rst) | Stable | `add_picture()` |
64
- | [Inline and floating pictures](docs/user/shapes.rst) | Stable | `add_picture()`, `add_float_picture()` |
65
- | [Latin and East Asian font controls](docs/user/text.rst) | Stable | `run.font.name`, `run.font.hAnsi`, `run.font.eastAsia` |
66
- | [Low-level OPC parts and relationships](docs/user/api-concepts.rst) | Stable | `document.part.package`, `part.rels` |
67
- | [In-memory read, export, and independent copies](docs/user/documents.rst) | Stable | `Document()`, `to_bytes()`, `copy()` |
68
- | [Document sanitization](docs/user/sanitization.rst) | Stable | `document.sanitize()` |
69
- | [Read-only package inspection and streaming feature scanning](docs/user/inspection.rst) | Stable | `inspect()`, `ScanEvent` |
70
- | [Configurable package-content fingerprints](docs/user/inspection.rst#content-fingerprints) | Stable | `fingerprint()`, `FingerprintPolicy`, `serialize_xml` |
71
- | [Explicit empty Custom XML repair and hyperlink normalization](docs/user/transformations.rst) | Stable | `repair()`, `normalize()` |
72
- | Package and semantic diff | Planned | — |
73
-
74
- ## Installation
75
-
76
- ```bash
77
- python -m pip install python-docx-oss
78
- ```
79
-
80
- The distribution name is `python-docx-oss`, but the Python import namespace remains
81
- `docx`:
82
-
83
- ```python
84
- from docx import Document
85
- ```
86
-
87
- > [!WARNING]
88
- > `python-docx` and `python-docx-oss` provide the same `docx` import namespace. Do not
89
- > install both distributions in the same Python environment.
90
-
91
- `python-docx-oss` currently supports Python 3.12, 3.13, and 3.14.
92
-
93
- ## Quick Start
94
-
95
- Create a document entirely in memory:
96
-
97
- ```python
98
- from io import BytesIO
99
-
100
- from docx import Document
101
-
102
- document = Document()
103
- document.add_heading("Quarterly Report", level=1)
104
- document.add_paragraph("Generated entirely in memory.")
105
-
106
- output = BytesIO()
107
- document.save(output)
108
-
109
- docx_bytes = output.getvalue()
110
- ```
111
-
112
- The same APIs also accept filesystem paths:
113
-
114
- ```python
115
- document = Document("input.docx")
116
- document.add_paragraph("Appended by python-docx-oss.")
117
- document.save("output.docx")
118
- ```
119
-
120
- ## Advanced Capabilities
121
-
122
- ### Package inspection and fingerprints
123
-
124
- Inspect damaged documents before opening them, and compute reproducible content fingerprints
125
- without loading media payloads:
126
-
127
- ```python
128
- from docx import FingerprintPolicy, fingerprint, inspect
129
-
130
- report = inspect("input.docx")
131
- for finding in report.findings:
132
- print(finding.code, finding.partname)
133
-
134
- digest = fingerprint("input.docx", policy=FingerprintPolicy(exclude_parts=("docProps/*",)))
135
- ```
136
-
137
- These APIs leave inputs unchanged and restore seekable stream positions without loading
138
- media payloads. `inspect()` supports structural inventory, damage detection, and streaming
139
- story XML queries with caller-defined predicates. `fingerprint()` normalizes structural
140
- indentation (C14N 2.0 / fingerprint v3) and supports selective exclusions. See
141
- [Package inspection and fingerprints](docs/user/inspection.rst) for finding codes, streaming
142
- queries, and policy rules.
143
-
144
- ### Explicit repair and normalization
145
-
146
- ```python
147
- from docx import normalize, repair
148
-
149
- repaired = repair(source_bytes, empty_custom_xml=True)
150
- if repaired.report.succeeded:
151
- normalized = normalize(repaired.content, hyperlink_fields=True, hyperlink_runs=True)
152
- if normalized.report.succeeded:
153
- output_bytes = normalized.content
154
- ```
155
-
156
- Operations are disabled by default and transactional: validation failures return the
157
- original bytes. Hyperlink normalization converts field codes into native `w:hyperlink`
158
- elements while preserving text box boundaries and proofing markers. See
159
- [Repair and normalization](docs/user/transformations.rst) for supported structures,
160
- selection callbacks, and preservation rules.
161
-
162
- ### Custom properties
163
-
164
- ```python
165
- document = Document()
166
- document.custom_properties["workflow_status"] = "approved"
167
- document.custom_properties["revision"] = 3
168
- ```
169
-
170
- Custom properties are visible in Microsoft Word and stored in
171
- `/docProps/custom.xml`. See [Working with custom
172
- properties](docs/user/custom-properties.rst).
173
-
174
- ### Custom XML
175
-
176
- ```python
177
- custom_xml = document.part.add_custom_xml_part(
178
- '<order xmlns="urn:example:orders" id="A-001"/>',
179
- )
180
- custom_xml.add_item("status", "ready")
181
- ```
182
-
183
- See [Working with Custom XML](docs/user/custom-xml.rst) for lifecycle and compatibility
184
- considerations.
185
-
186
- ### East Asian fonts
187
-
188
- ```python
189
- run = document.add_paragraph().add_run("English 与中文")
190
- run.font.name = "Open Sans"
191
- run.font.eastAsia = "Microsoft YaHei"
192
- ```
193
-
194
- SVG and EMF streams can be passed to the standard picture APIs. Floating pictures are
195
- available through `Document.add_float_picture()` and `Run.add_float_picture()`.
196
-
197
- ## Compatibility and Scope
198
-
199
- - The project maintains broad compatibility with the public `python-docx` API while
200
- following its own versioning and product roadmap.
201
- - Clean lxml integration: Low-level OXML elements avoid shadowing lxml's Cython
202
- `_Element.text` descriptor (using `.texts` internally). This guarantees that standard
203
- `element.itertext()` on parent elements and untyped revision nodes (`w:ins`, `w:del`,
204
- `w:txbxContent`) never duplicates text, while high-level proxy APIs (`paragraph.text`,
205
- `run.text`) remain fully compatible with `python-docx`.
206
- - Compatibility does not extend to every private or internal `python-docx` API. Test
207
- those integrations before migrating production systems.
208
- - The SDK focuses exclusively on DOCX. It is not a general XLSX/PPTX Office suite.
209
- - It edits document structure but does not implement Word's page-layout rendering
210
- engine.
211
- - CLI, MCP, web, desktop, and Agent runtimes belong in separate packages that consume
212
- this SDK.
213
-
214
- ## Documentation
215
-
216
- - [Documentation site](https://python-docx-oss.readthedocs.io/en/latest/)
217
- - [Installation guide](docs/user/install.rst)
218
- - [Quickstart](docs/user/quickstart.rst)
219
- - [User guide](docs/index.rst)
220
- - [API reference](docs/index.rst#api-documentation)
221
- - [Custom properties](docs/user/custom-properties.rst)
222
- - [Custom XML](docs/user/custom-xml.rst)
223
- - [Package inspection and fingerprints](docs/user/inspection.rst)
224
- - [Package repair and normalization](docs/user/transformations.rst)
225
- - [Package sanitization](docs/user/sanitization.rst)
226
- - [python-docx compatibility](docs/user/compatibility.rst)
227
- - [Upstream maintenance](docs/dev/upstream-maintenance.rst)
228
- - [Release history](HISTORY.md)
229
-
230
- ## Quality and Testing
231
-
232
- The test suite combines unit and acceptance coverage with in-memory round-trip tests
233
- using documents created by Microsoft Word. The integration fixtures cover floating
234
- pictures, SVG fallback relationships, East Asian fonts, Custom XML parts, and core OPC
235
- package preservation.
236
-
237
- For local development:
238
-
239
- ```bash
240
- uv sync
241
- uv run pytest
242
- uv run behave
243
- uv run ruff check tests/integration tests/fixtures/customxml/generate_fixture.py
244
- uv run pyright tests/integration tests/fixtures/customxml/generate_fixture.py
245
- ```
246
-
247
- ## Project Status
248
-
249
- With version 0.5.0, the independent SDK baseline, in-memory workflows, package
250
- sanitization, streaming inspection, content fingerprinting (v3), and explicit package
251
- repairs are stabilized. Upcoming milestones focus on package and semantic diffing,
252
- composition, and schema-guided validation.
253
-
254
- ## Credits
255
-
256
- This project builds on the original work of
257
- [`python-docx`](https://github.com/python-openxml/python-docx) creator Steve Canny and
258
- its contributors. `python-docx-oss` is maintained by Ethan St Lee and its contributors.
259
-
260
- ## Why “OSS”?
261
-
262
- In Brazilian jiu-jitsu, “oss” is a greeting and an expression of respect. It reflects
263
- the same spirit of discipline and collaboration behind this project.
264
-
265
- ## License
266
-
267
- `python-docx-oss` is released under the [MIT License](LICENSE).
268
-
269
- ## Support
270
-
271
- If this project is useful to you, you can support its continued development through
272
- the [donation page](https://lsaint.github.io/donation/?utm_source=github&utm_medium=readme&utm_campaign=python-docx-oss).