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
+3 -1
View File
@@ -156,6 +156,8 @@ def test_css_edits_reach_word_via_saved_rules(tmp_path, engine):
from lxml import etree
with zipfile.ZipFile(docx) as archive:
doc = etree.fromstring(archive.read("word/document.xml"))
from docx_assertions import effective_document
doc = effective_document(doc, etree.fromstring(archive.read('word/styles.xml')))
ns = {"w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"}
w = "{" + ns["w"] + "}"
assert doc.find(".//w:sz", ns).get(w + "val") == "28"
@@ -212,7 +214,7 @@ def test_style_file_roundtrip_reader_and_word_integration(app, tmp_path, monkeyp
window.current_file = markdown
docx_path = window.export_docx_to_path(tmp_path / 'test.docx')
with zipfile.ZipFile(docx_path) as archive:
xml = archive.read('word/document.xml').decode()
xml = archive.read('word/styles.xml').decode()
assert 'w:sz w:val="28"' in xml and 'w:color w:val="ff0000"' in xml
finally:
window.close()