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
+5 -1
View File
@@ -86,8 +86,10 @@ def test_dialog_legacy_px_and_no_duplicate_generated_css(app):
def read_xml(path):
from docx_assertions import effective_document
with zipfile.ZipFile(path) as package:
return ET.fromstring(package.read("word/document.xml")), ET.fromstring(package.read("word/styles.xml"))
document, styles = ET.fromstring(package.read("word/document.xml")), ET.fromstring(package.read("word/styles.xml"))
return effective_document(document, styles), styles
@pytest.mark.parametrize("engine", ["builtin", "python-docx", "pandoc"])
@@ -168,6 +170,8 @@ def test_pandoc_style_processing_preserves_math_links_and_numbering(tmp_path):
path = export_markdown_to_docx(source, tmp_path / "semantic.docx", engine="pandoc", style_rules={"paragraph": RULE})
with zipfile.ZipFile(path) as package:
xml = ET.fromstring(package.read("word/document.xml"))
from docx_assertions import effective_document
xml = effective_document(xml, ET.fromstring(package.read('word/styles.xml')))
rels = package.read("word/_rels/document.xml.rels").decode()
assert xml.find(".//w:hyperlink", NS) is not None
assert "https://openai.com" in rels