Skip to content

Phase D.9: Numbering style control (restart, custom lists, nested lists) #22

@loadfix

Description

@loadfix

Add comprehensive numbering/list control. Most requested upstream feature (python-openxml#582: 83 comments, #25: 37 comments, python-openxml#122: 27 comments).

API Design

Restart numbering:

  • paragraph.restart_numbering() — restarts the numbered list counter at 1
  • Sets w:numPr > w:numId to a new abstract num with restart override

Custom list styles:

  • document.numbering.add_numbering_definition(levels) — create a custom multi-level list
  • Each level: number format (decimal, lowerAlpha, upperRoman, bullet), text pattern ("%1.", "%1.%2"), indent, font
  • Returns a NumberingDefinition that can be applied to paragraphs

Nested lists:

  • paragraph.list_level — get/set the indent level (0-8)
  • paragraph.list_format — get/set the numbering definition and level
  • Support multi-level lists: applying level 1 under a level 0 creates nesting

Access existing numbering:

  • document.numbering.definitions — iterate all numbering definitions
  • paragraph.numbering_format — read the current list style

XML

  • w:numPr > w:numId (which numbering definition), w:ilvl (indent level)
  • w:numbering > w:abstractNum (definition), w:num (instance with overrides)
  • w:lvlOverride > w:startOverride for restart

Upstream issues: python-openxml#582, #25, python-openxml#122

Metadata

Metadata

Assignees

No one assigned

    Labels

    agentTriggers the developer agentenhancementNew feature or requestphase-dQuality of Life

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions