feat: export editable named Word styles and release 0.5.0

This commit is contained in:
2026-10-30 10:58:37 +08:00
parent 117e6b65f1
commit 151b176c1a
20 changed files with 818 additions and 169 deletions
+2
View File
@@ -80,6 +80,8 @@ def test_word_export_preserves_cjk_bold_and_body_boundaries(tmp_path, engine):
path = export_markdown_to_docx(SCREENSHOT_SOURCE, tmp_path / (engine + '.docx'), engine=engine)
with zipfile.ZipFile(path) as package:
root = ET.fromstring(package.read('word/document.xml'))
from docx_assertions import effective_document
root = effective_document(root, ET.fromstring(package.read('word/styles.xml')))
ns = {'w': 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'}
all_text = ''.join(root.xpath('//w:t/text()', namespaces=ns))
bold_text = ''.join(root.xpath('//w:r[w:rPr/w:b[not(@w:val="0")]]/w:t/text()', namespaces=ns))