docx/bulleted-list

Three consecutive paragraphs styled with the built-in List Bullet style to form an unordered list.

Library verdicts: python-docx: — docxjs: pass

Metadata

Feature iddocx/bulleted-list
Formatdocx
Categorylists
Spececma-376-5-part-1 § 17.3.1.19 w:numPr

XPath assertions

ID / partPredicateXPathpython-docxdocxjs
bulleted-list-item-one-present
word/document.xml
exist
The first bullet paragraph must carry pStyle='ListBullet' and contain the fixture text 'Bullet item one'.
//w:p[w:pPr/w:pStyle[@w:val='ListBullet']][w:r/w:t[normalize-space()='Bullet item one']]
bulleted-list-item-two-present
word/document.xml
exist
The second bullet paragraph must carry pStyle='ListBullet' and contain the fixture text 'Bullet item two'.
//w:p[w:pPr/w:pStyle[@w:val='ListBullet']][w:r/w:t[normalize-space()='Bullet item two']]
bulleted-list-item-three-present
word/document.xml
exist
The third bullet paragraph must carry pStyle='ListBullet' and contain the fixture text 'Bullet item three'.
//w:p[w:pPr/w:pStyle[@w:val='ListBullet']][w:r/w:t[normalize-space()='Bullet item three']]
bulleted-list-item-count
word/document.xml
match = ^3(\.0)?$
Exactly three paragraphs must use the ListBullet style.
count(//w:p[w:pPr/w:pStyle[@w:val='ListBullet']])

Render assertions

IDPredicateSelectorpython-docxdocxjs
bulleted-list-item-one-renderedcss_selector/ match-text = Bullet item one
A list-item DOM node (ul > li, or a paragraph carrying the List Bullet style) must contain the first fixture item. Falls back to any paragraph since renderer conventions vary.
.docx-wrapper ul li, .docx-wrapper [data-style='List Bullet'], .docx-wrapper [class*='list-bullet'], .docx-wrapper [class*='ListBullet'], .docx-wrapper ppass
bulleted-list-item-countcss_selector/ equal-count
Exactly three list-item DOM nodes must be rendered — one per fixture bullet. Catches phantom or dropped items the match-text assertion can't see. Includes docxjs's `p.docx-num-<id>-<lvl>` list-item markup in the selector fallback chain.
.docx-wrapper ul li, .docx-wrapper [data-style='List Bullet'], .docx-wrapper [class*='list-bullet'], .docx-wrapper [class*='ListBullet'], .docx-wrapper p[class*='-num-']
bulleted-list-item-two-renderedcss_selector/ match-text = Bullet item two
The second list-item must contain 'Bullet item two'. Catches renderers that repeat item-one content across siblings (content leak between <li> nodes).
.docx-wrapper ul li:nth-of-type(2), .docx-wrapper [data-style='List Bullet']:nth-of-type(2), .docx-wrapper [class*='ListBullet']:nth-of-type(2), .docx-wrapper p:nth-of-type(2)
bulleted-list-item-three-renderedcss_selector/ match-text = Bullet item three
The third list-item must contain 'Bullet item three'. Catches content leaks and dropped-sibling bugs.
.docx-wrapper ul li:nth-of-type(3), .docx-wrapper [data-style='List Bullet']:nth-of-type(3), .docx-wrapper [class*='ListBullet']:nth-of-type(3), .docx-wrapper p:nth-of-type(3)

Generator source

scripts/gen_bulleted_list.py

#!/usr/bin/env python3
"""Generate ``fixtures/docx/bulleted-list.docx``.

A minimal document exercising the built-in ``List Bullet`` paragraph
style. Three consecutive paragraphs form an unordered list. Designed
to satisfy the assertions in ``features/docx/bulleted-list.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" / "bulleted-list.docx"


def main() -> int:
    doc = Document()
    doc.add_paragraph("Bullet item one", style="List Bullet")
    doc.add_paragraph("Bullet item two", style="List Bullet")
    doc.add_paragraph("Bullet item three", style="List Bullet")
    _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/bulleted-list",
  "title": "Bulleted list",
  "format": "docx",
  "category": "lists",
  "summary": "Three consecutive paragraphs styled with the built-in List Bullet style to form an unordered list.",
  "spec": {
    "source": "ecma-376-5-part-1",
    "clause": "17.3.1.19",
    "element": "w:numPr",
    "rnc_reference": "spec/ecma-376-5/part-1/rnc/WordprocessingML.rnc",
    "xsd_reference": "spec/ecma-376-5/part-1/xsd/wml.xsd",
    "notes": "List membership is expressed via the paragraph's pStyle pointing at a list style (e.g. 'ListBullet') or directly via <w:pPr><w:numPr><w:numId w:val='n'/><w:ilvl w:val='0'/></w:numPr></w:pPr>. Word collapses whitespace in style names, so the 'List Bullet' built-in style appears as pStyle w:val='ListBullet' in the XML, not 'List Bullet'."
  },
  "fixtures": {
    "machine": "docx/bulleted-list",
    "office": "docx/bulleted-list"
  },
  "generator": {
    "python": "scripts/gen_bulleted_list.py"
  },
  "assertions": [
    {
      "id": "bulleted-list-item-one-present",
      "part": "word/document.xml",
      "namespaces": {
        "w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
      },
      "xpath": "//w:p[w:pPr/w:pStyle[@w:val='ListBullet']][w:r/w:t[normalize-space()='Bullet item one']]",
      "must": "exist",
      "description": "The first bullet paragraph must carry pStyle='ListBullet' and contain the fixture text 'Bullet item one'."
    },
    {
      "id": "bulleted-list-item-two-present",
      "part": "word/document.xml",
      "namespaces": {
        "w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
      },
      "xpath": "//w:p[w:pPr/w:pStyle[@w:val='ListBullet']][w:r/w:t[normalize-space()='Bullet item two']]",
      "must": "exist",
      "description": "The second bullet paragraph must carry pStyle='ListBullet' and contain the fixture text 'Bullet item two'."
    },
    {
      "id": "bulleted-list-item-three-present",
      "part": "word/document.xml",
      "namespaces": {
        "w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
      },
      "xpath": "//w:p[w:pPr/w:pStyle[@w:val='ListBullet']][w:r/w:t[normalize-space()='Bullet item three']]",
      "must": "exist",
      "description": "The third bullet paragraph must carry pStyle='ListBullet' and contain the fixture text 'Bullet item three'."
    },
    {
      "id": "bulleted-list-item-count",
      "part": "word/document.xml",
      "namespaces": {
        "w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"
      },
      "xpath": "count(//w:p[w:pPr/w:pStyle[@w:val='ListBullet']])",
      "must": "match",
      "value": "^3(\\.0)?$",
      "description": "Exactly three paragraphs must use the ListBullet style."
    }
  ],
  "render_assertions": [
    {
      "id": "bulleted-list-item-one-rendered",
      "kind": "css_selector",
      "selector": ".docx-wrapper ul li, .docx-wrapper [data-style='List Bullet'], .docx-wrapper [class*='list-bullet'], .docx-wrapper [class*='ListBullet'], .docx-wrapper p",
      "must": "match-text",
      "value": "Bullet item one",
      "description": "A list-item DOM node (ul > li, or a paragraph carrying the List Bullet style) must contain the first fixture item. Falls back to any paragraph since renderer conventions vary."
    },
    {
      "id": "bulleted-list-item-count",
      "kind": "css_selector",
      "selector": ".docx-wrapper ul li, .docx-wrapper [data-style='List Bullet'], .docx-wrapper [class*='list-bullet'], .docx-wrapper [class*='ListBullet'], .docx-wrapper p[class*='-num-']",
      "must": "equal-count",
      "count": 3,
      "description": "Exactly three list-item DOM nodes must be rendered — one per fixture bullet. Catches phantom or dropped items the match-text assertion can't see. Includes docxjs's `p.docx-num-<id>-<lvl>` list-item markup in the selector fallback chain."
    },
    {
      "id": "bulleted-list-item-two-rendered",
      "kind": "css_selector",
      "selector": ".docx-wrapper ul li:nth-of-type(2), .docx-wrapper [data-style='List Bullet']:nth-of-type(2), .docx-wrapper [class*='ListBullet']:nth-of-type(2), .docx-wrapper p:nth-of-type(2)",
      "must": "match-text",
      "value": "Bullet item two",
      "description": "The second list-item must contain 'Bullet item two'. Catches renderers that repeat item-one content across siblings (content leak between <li> nodes)."
    },
    {
      "id": "bulleted-list-item-three-rendered",
      "kind": "css_selector",
      "selector": ".docx-wrapper ul li:nth-of-type(3), .docx-wrapper [data-style='List Bullet']:nth-of-type(3), .docx-wrapper [class*='ListBullet']:nth-of-type(3), .docx-wrapper p:nth-of-type(3)",
      "must": "match-text",
      "value": "Bullet item three",
      "description": "The third list-item must contain 'Bullet item three'. Catches content leaks and dropped-sibling bugs."
    }
  ]
}

Fixture

Download bulleted-list.docx (19.6 KB)

Reference preview

Reference (machine, page 1 PNG)

docx/bulleted-list page 1 reference

Reference PDF


Download PDF Open in PDF.js

Spec notes

List membership is expressed via the paragraph's pStyle pointing at a list style (e.g. 'ListBullet') or directly via <w:pPr><w:numPr><w:numId w:val='n'/><w:ilvl w:val='0'/></w:numPr></w:pPr>. Word collapses whitespace in style names, so the 'List Bullet' built-in style appears as pStyle w:val='ListBullet' in the XML, not 'List Bullet'.