Skip to content

Handle cyclic w references#169

Open
Isopach wants to merge 1 commit into
mwilliamson:masterfrom
Isopach:handle-cyclic-w-references
Open

Handle cyclic w references#169
Isopach wants to merge 1 commit into
mwilliamson:masterfrom
Isopach:handle-cyclic-w-references

Conversation

@Isopach

@Isopach Isopach commented Jun 16, 2026

Copy link
Copy Markdown

Numbering.find_level resolves w:numStyleLink by following the referenced numbering style to another w:num. If those references form a cycle, the lookup currently recurses until Python raises RecursionError.

This change tracks num IDs visited during a single lookup and returns None when a num ID is seen twice. A cyclic chain is therefore treated as having no resolvable level.

No behaviour change for valid documents; existing numbering tests pass unchanged.

Adds one regression test covering a two-entry w:numStyleLink cycle.

Track the num IDs visited during a single find_level lookup and return None when a num ID repeats, so a cyclic w:numStyleLink chain is treated as having no resolvable level instead of recursing without bound. Adds a regression test covering a two-entry cycle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant