Apply a double-line strikethrough to a run of text.
Library verdicts: python-docx: — docxjs: pass
| Feature id | docx/double-strikethrough |
|---|---|
| Format | docx |
| Category | text-formatting |
| Spec | ecma-376-5-part-1 § 17.3.2.9 w:dstrike |
| ID / part | Predicate | XPath | python-docx | docxjs |
|---|---|---|---|---|
dstrike-element-presentword/document.xml | existThe run carrying the double-strikethrough text must have a <w:dstrike> child inside <w:rPr>. | //w:r[w:t[normalize-space()='Double strikethrough text']]/w:rPr/w:dstrike | — | — |
dstrike-val-not-falseword/document.xml | not-match = ^(0|false|off)$If w:val is present it must not explicitly disable double-strike. | //w:r[w:t[normalize-space()='Double strikethrough text']]/w:rPr/w:dstrike/@w:val | — | — |
| ID | Predicate | Selector | python-docx | docxjs |
|---|---|---|---|---|
dstrike-text-rendered | css_selector/ match-text = Double strikethrough textA DOM node marked with double-line strikethrough (via text-decoration shorthand, text-decoration-style: double, or [data-dstrike]) must contain the fixture text. | .docx-wrapper [style*='text-decoration: line-through double'], .docx-wrapper [style*='text-decoration:line-through double'], .docx-wrapper [style*='text-decoration-style: double'], .docx-wrapper [style*='text-decoration-style:double'], .docx-wrapper [data-dstrike] | — | pass |
dstrike-text-visible | computed_style = line-through style=text-decoration-lineThe computed text-decoration-line on the double-strikethrough run must include line-through. | .docx-wrapper span:not(:has(*)), .docx-wrapper [data-dstrike] | — | pass |
scripts/gen_double_strikethrough.py
#!/usr/bin/env python3
"""Generate ``fixtures/docx/double-strikethrough.docx``.
A minimal document exercising the ``w:dstrike`` double-strikethrough
element. One paragraph containing one run with double-strike enabled.
Uses the python-docx fork's high-level ``Font.double_strike`` API.
Satisfies the assertions in ``features/docx/double-strikethrough.json``.
"""
from __future__ import annotations
from pathlib import Path
from docx import Document
_REPO_ROOT = Path(__file__).resolve().parent.parent
_OUT = _REPO_ROOT / "fixtures" / "docx" / "double-strikethrough.docx"
def main() -> int:
doc = Document()
paragraph = doc.add_paragraph()
run = paragraph.add_run("Double strikethrough text")
run.font.double_strike = True
_OUT.parent.mkdir(parents=True, exist_ok=True)
doc.save(_OUT, reproducible=True)
print(_OUT)
return 0
if __name__ == "__main__":
raise SystemExit(main())
{
"$schema": "../manifest.schema.json",
"id": "docx/double-strikethrough",
"title": "Double strikethrough text",
"format": "docx",
"category": "text-formatting",
"summary": "Apply a double-line strikethrough to a run of text.",
"spec": {
"source": "ecma-376-5-part-1",
"clause": "17.3.2.9",
"element": "w:dstrike",
"rnc_reference": "spec/ecma-376-5/part-1/rnc/WordprocessingML.rnc",
"xsd_reference": "spec/ecma-376-5/part-1/xsd/wml.xsd",
"notes": "Word emits <w:dstrike/> to draw two parallel lines through the run's glyphs. Empty element means true. w:val is optional; if present it must not be 0/false/off (those explicitly disable dstrike in a toggled style chain). <w:dstrike> is the double-line counterpart to <w:strike> and the two are mutually exclusive in practice."
},
"fixtures": {
"machine": "docx/double-strikethrough",
"office": "docx/double-strikethrough"
},
"generator": {
"python": "scripts/gen_double_strikethrough.py"
},
"assertions": [
{
"id": "dstrike-element-present",
"part": "word/document.xml",
"namespaces": {
"w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
},
"xpath": "//w:r[w:t[normalize-space()='Double strikethrough text']]/w:rPr/w:dstrike",
"must": "exist",
"description": "The run carrying the double-strikethrough text must have a <w:dstrike> child inside <w:rPr>."
},
{
"id": "dstrike-val-not-false",
"part": "word/document.xml",
"namespaces": {
"w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
},
"xpath": "//w:r[w:t[normalize-space()='Double strikethrough text']]/w:rPr/w:dstrike/@w:val",
"must": "not-match",
"value": "^(0|false|off)$",
"description": "If w:val is present it must not explicitly disable double-strike."
}
],
"render_assertions": [
{
"id": "dstrike-text-rendered",
"kind": "css_selector",
"selector": ".docx-wrapper [style*='text-decoration: line-through double'], .docx-wrapper [style*='text-decoration:line-through double'], .docx-wrapper [style*='text-decoration-style: double'], .docx-wrapper [style*='text-decoration-style:double'], .docx-wrapper [data-dstrike]",
"must": "match-text",
"value": "Double strikethrough text",
"description": "A DOM node marked with double-line strikethrough (via text-decoration shorthand, text-decoration-style: double, or [data-dstrike]) must contain the fixture text."
},
{
"id": "dstrike-text-visible",
"kind": "computed_style",
"selector": ".docx-wrapper span:not(:has(*)), .docx-wrapper [data-dstrike]",
"style_property": "text-decoration-line",
"value": "line-through",
"description": "The computed text-decoration-line on the double-strikethrough run must include line-through."
}
]
}
