docx/double-strikethrough

Apply a double-line strikethrough to a run of text.

Library verdicts: python-docx: — docxjs: pass

Metadata

Feature iddocx/double-strikethrough
Formatdocx
Categorytext-formatting
Spececma-376-5-part-1 § 17.3.2.9 w:dstrike

XPath assertions

ID / partPredicateXPathpython-docxdocxjs
dstrike-element-present
word/document.xml
exist
The 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-false
word/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

Render assertions

IDPredicateSelectorpython-docxdocxjs
dstrike-text-renderedcss_selector/ match-text = Double strikethrough text
A 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-visiblecomputed_style = line-through style=text-decoration-line
The computed text-decoration-line on the double-strikethrough run must include line-through.
.docx-wrapper span:not(:has(*)), .docx-wrapper [data-dstrike]pass

Generator source

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())

Manifest (expanded)

{
  "$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."
    }
  ]
}

Fixture

Download double-strikethrough.docx (18.6 KB)

Reference preview

Reference (machine, page 1 PNG)

docx/double-strikethrough page 1 reference

Reference PDF


Download PDF Open in PDF.js

Spec 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.