Skip to content

docx_plus.bookmarks.registry

Per-document registry of issued bookmark w:id values. Bookmark ids live in their own uniqueness namespace, separate from SDT, comment, and note ids. Body-side <w:bookmarkStart> / <w:bookmarkEnd> elements both carry the id on a direct @w:id attribute, so the seeder uses the attribute-form collector inherited from _IdRegistryBase.

docx_plus.bookmarks.registry

Bookmark-id registry.

Bookmark w:id is its own uniqueness namespace, separate from SDT, comment, and note ids. The body-side <w:bookmarkStart> / <w:bookmarkEnd> elements both carry the id on a direct @w:id attribute (not as a <w:id w:val=...> child like SDTs), so the seeder uses :meth:_collect_id_attrs.

This module imports only from docx_plus.core (SPEC §9.1).

BookmarkIdRegistry

BookmarkIdRegistry(doc: Document)

Bases: _IdRegistryBase

Tracks issued bookmark w:id values for one document-edit session.

Source code in docx_plus/core/ids.py
def __init__(self, doc: Document) -> None:
    """Scan ``doc`` for IDs already issued in this namespace.

    Args:
        doc: A python-docx :class:`~docx.document.Document`.
    """
    self._issued: set[int] = set()
    self._seed_from_document(doc)