Skip to content

Bookmark

Bookmark class for “text:bookmark” tag and BookmarkStart, BookmarkEnd.

Classes:

Name Description
Bookmark

Bookmark class, “text:bookmark” tag.

BookmarkEnd

Bookmark end marker, “text:bookmark-end”.

BookmarkMixin

Mixin class for classes containing Bookmarks.

BookmarkStart

Bookmark start marker, “text:bookmark-start”.

Bookmark

Bases: Element

Bookmark class, “text:bookmark” tag.

Attributes:

Name Type Description
name str

The name of the bookmark (text:name attribute).

Methods:

Name Description
__init__

Bookmark class, “text:bookmark” tag.

Source code in odfdo/bookmark.py
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
class Bookmark(Element):
    """Bookmark class, "text:bookmark" tag.

    Attributes:
        name (str): The name of the bookmark (text:name attribute).
    """

    _tag = "text:bookmark"
    _properties = (PropDef("name", "text:name"),)

    def __init__(self, name: str = "", **kwargs: Any) -> None:
        """Bookmark class, "text:bookmark" tag.

        Args:
            name: The name of the bookmark.
        """
        super().__init__(**kwargs)
        if self._do_init:
            self.name = name

_properties class-attribute instance-attribute

_properties = (PropDef('name', 'text:name'),)

_tag class-attribute instance-attribute

_tag = 'text:bookmark'

name instance-attribute

name = name

__init__

__init__(name: str = '', **kwargs: Any) -> None

Bookmark class, “text:bookmark” tag.

Parameters:

Name Type Description Default
name str

The name of the bookmark.

''
Source code in odfdo/bookmark.py
151
152
153
154
155
156
157
158
159
def __init__(self, name: str = "", **kwargs: Any) -> None:
    """Bookmark class, "text:bookmark" tag.

    Args:
        name: The name of the bookmark.
    """
    super().__init__(**kwargs)
    if self._do_init:
        self.name = name

BookmarkEnd

Bases: Element

Bookmark end marker, “text:bookmark-end”.

Attributes:

Name Type Description
name str

The name of the bookmark range being ended (text:name attribute).

Methods:

Name Description
__init__

Bookmark end marker, “text:bookmark-end”.

Source code in odfdo/bookmark.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
class BookmarkEnd(Element):
    """Bookmark end marker, "text:bookmark-end".

    Attributes:
        name (str): The name of the bookmark range being ended (text:name attribute).
    """

    _tag = "text:bookmark-end"
    _properties = (PropDef("name", "text:name"),)

    def __init__(self, name: str = "", **kwargs: Any) -> None:
        """Bookmark end marker, "text:bookmark-end".

        Args:
            name: The name of the bookmark range being ended.
        """
        super().__init__(**kwargs)
        if self._do_init:
            self.name = name

_properties class-attribute instance-attribute

_properties = (PropDef('name', 'text:name'),)

_tag class-attribute instance-attribute

_tag = 'text:bookmark-end'

name instance-attribute

name = name

__init__

__init__(name: str = '', **kwargs: Any) -> None

Bookmark end marker, “text:bookmark-end”.

Parameters:

Name Type Description Default
name str

The name of the bookmark range being ended.

''
Source code in odfdo/bookmark.py
199
200
201
202
203
204
205
206
207
def __init__(self, name: str = "", **kwargs: Any) -> None:
    """Bookmark end marker, "text:bookmark-end".

    Args:
        name: The name of the bookmark range being ended.
    """
    super().__init__(**kwargs)
    if self._do_init:
        self.name = name

BookmarkMixin

Bases: Element

Mixin class for classes containing Bookmarks.

Used by the following classes: “text:a”, “text:h”, “text:meta”, “text:meta-field”, “text:p”, “text:ruby-base”, “text:span”. And with “office:text” for compatibility with previous versions.

Methods:

Name Description
get_bookmark

Return the bookmark that matches the criteria.

get_bookmark_end

Return the bookmark end that matches the criteria.

get_bookmark_ends

Return all the bookmark ends.

get_bookmark_start

Return the bookmark start that matches the criteria.

get_bookmark_starts

Return all the bookmark starts.

get_bookmarks

Return all the bookmarks.

Source code in odfdo/bookmark.py
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
class BookmarkMixin(Element):
    """Mixin class for classes containing Bookmarks.

    Used by the following classes: "text:a", "text:h", "text:meta", "text:meta-field",
    "text:p", "text:ruby-base", "text:span". And with "office:text" for compatibility
    with previous versions.
    """

    def get_bookmarks(self) -> list[Bookmark]:
        """Return all the bookmarks.

        Returns:
            list[Bookmark]: All bookmarks in the element's subtree.
        """
        return cast(
            list[Bookmark],
            self._filtered_elements(
                "descendant::text:bookmark",
            ),
        )

    def get_bookmark(
        self,
        position: int = 0,
        name: str | None = None,
    ) -> Bookmark | None:
        """Return the bookmark that matches the criteria.

        Args:
            position: The index of the bookmark to retrieve (0-based).
            name: The name attribute (text:name) of the bookmark to retrieve.

        Returns:
            Bookmark or None: The found Bookmark or None if not found.
        """
        return cast(
            None | Bookmark,
            self._filtered_element(
                "descendant::text:bookmark", position, text_name=name
            ),
        )

    def get_bookmark_starts(self) -> list[BookmarkStart]:
        """Return all the bookmark starts.

        Returns:
            list[BookmarkStart]: All bookmark start markers in the element's subtree.
        """
        return cast(
            list[BookmarkStart],
            self._filtered_elements(
                "descendant::text:bookmark-start",
            ),
        )

    def get_bookmark_start(
        self,
        position: int = 0,
        name: str | None = None,
    ) -> BookmarkStart | None:
        """Return the bookmark start that matches the criteria.

        Args:
            position: The index of the bookmark start to retrieve (0-based).
            name: The name attribute (text:name) of the bookmark start to retrieve.

        Returns:
            BookmarkStart or None: The found BookmarkStart or None if not found.
        """
        return cast(
            None | BookmarkStart,
            self._filtered_element(
                "descendant::text:bookmark-start", position, text_name=name
            ),
        )

    def get_bookmark_ends(self) -> list[BookmarkEnd]:
        """Return all the bookmark ends.

        Returns:
            list[BookmarkEnd]: All bookmark end markers in the element's subtree.
        """
        return cast(
            list[BookmarkEnd],
            self._filtered_elements(
                "descendant::text:bookmark-end",
            ),
        )

    def get_bookmark_end(
        self,
        position: int = 0,
        name: str | None = None,
    ) -> BookmarkEnd | None:
        """Return the bookmark end that matches the criteria.

        Args:
            position: The index of the bookmark end to retrieve (0-based).
            name: The name attribute (text:name) of the bookmark end to retrieve.

        Returns:
            BookmarkEnd or None: The found BookmarkEnd or None if not found.
        """
        return cast(
            None | BookmarkEnd,
            self._filtered_element(
                "descendant::text:bookmark-end", position, text_name=name
            ),
        )

get_bookmark

get_bookmark(
    position: int = 0, name: str | None = None
) -> Bookmark | None

Return the bookmark that matches the criteria.

Parameters:

Name Type Description Default
position int

The index of the bookmark to retrieve (0-based).

0
name str | None

The name attribute (text:name) of the bookmark to retrieve.

None

Returns:

Type Description
Bookmark | None

Bookmark or None: The found Bookmark or None if not found.

Source code in odfdo/bookmark.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def get_bookmark(
    self,
    position: int = 0,
    name: str | None = None,
) -> Bookmark | None:
    """Return the bookmark that matches the criteria.

    Args:
        position: The index of the bookmark to retrieve (0-based).
        name: The name attribute (text:name) of the bookmark to retrieve.

    Returns:
        Bookmark or None: The found Bookmark or None if not found.
    """
    return cast(
        None | Bookmark,
        self._filtered_element(
            "descendant::text:bookmark", position, text_name=name
        ),
    )

get_bookmark_end

get_bookmark_end(
    position: int = 0, name: str | None = None
) -> BookmarkEnd | None

Return the bookmark end that matches the criteria.

Parameters:

Name Type Description Default
position int

The index of the bookmark end to retrieve (0-based).

0
name str | None

The name attribute (text:name) of the bookmark end to retrieve.

None

Returns:

Type Description
BookmarkEnd | None

BookmarkEnd or None: The found BookmarkEnd or None if not found.

Source code in odfdo/bookmark.py
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
def get_bookmark_end(
    self,
    position: int = 0,
    name: str | None = None,
) -> BookmarkEnd | None:
    """Return the bookmark end that matches the criteria.

    Args:
        position: The index of the bookmark end to retrieve (0-based).
        name: The name attribute (text:name) of the bookmark end to retrieve.

    Returns:
        BookmarkEnd or None: The found BookmarkEnd or None if not found.
    """
    return cast(
        None | BookmarkEnd,
        self._filtered_element(
            "descendant::text:bookmark-end", position, text_name=name
        ),
    )

get_bookmark_ends

get_bookmark_ends() -> list[BookmarkEnd]

Return all the bookmark ends.

Returns:

Type Description
list[BookmarkEnd]

list[BookmarkEnd]: All bookmark end markers in the element’s subtree.

Source code in odfdo/bookmark.py
106
107
108
109
110
111
112
113
114
115
116
117
def get_bookmark_ends(self) -> list[BookmarkEnd]:
    """Return all the bookmark ends.

    Returns:
        list[BookmarkEnd]: All bookmark end markers in the element's subtree.
    """
    return cast(
        list[BookmarkEnd],
        self._filtered_elements(
            "descendant::text:bookmark-end",
        ),
    )

get_bookmark_start

get_bookmark_start(
    position: int = 0, name: str | None = None
) -> BookmarkStart | None

Return the bookmark start that matches the criteria.

Parameters:

Name Type Description Default
position int

The index of the bookmark start to retrieve (0-based).

0
name str | None

The name attribute (text:name) of the bookmark start to retrieve.

None

Returns:

Type Description
BookmarkStart | None

BookmarkStart or None: The found BookmarkStart or None if not found.

Source code in odfdo/bookmark.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
def get_bookmark_start(
    self,
    position: int = 0,
    name: str | None = None,
) -> BookmarkStart | None:
    """Return the bookmark start that matches the criteria.

    Args:
        position: The index of the bookmark start to retrieve (0-based).
        name: The name attribute (text:name) of the bookmark start to retrieve.

    Returns:
        BookmarkStart or None: The found BookmarkStart or None if not found.
    """
    return cast(
        None | BookmarkStart,
        self._filtered_element(
            "descendant::text:bookmark-start", position, text_name=name
        ),
    )

get_bookmark_starts

get_bookmark_starts() -> list[BookmarkStart]

Return all the bookmark starts.

Returns:

Type Description
list[BookmarkStart]

list[BookmarkStart]: All bookmark start markers in the element’s subtree.

Source code in odfdo/bookmark.py
72
73
74
75
76
77
78
79
80
81
82
83
def get_bookmark_starts(self) -> list[BookmarkStart]:
    """Return all the bookmark starts.

    Returns:
        list[BookmarkStart]: All bookmark start markers in the element's subtree.
    """
    return cast(
        list[BookmarkStart],
        self._filtered_elements(
            "descendant::text:bookmark-start",
        ),
    )

get_bookmarks

get_bookmarks() -> list[Bookmark]

Return all the bookmarks.

Returns:

Type Description
list[Bookmark]

list[Bookmark]: All bookmarks in the element’s subtree.

Source code in odfdo/bookmark.py
38
39
40
41
42
43
44
45
46
47
48
49
def get_bookmarks(self) -> list[Bookmark]:
    """Return all the bookmarks.

    Returns:
        list[Bookmark]: All bookmarks in the element's subtree.
    """
    return cast(
        list[Bookmark],
        self._filtered_elements(
            "descendant::text:bookmark",
        ),
    )

BookmarkStart

Bases: Element

Bookmark start marker, “text:bookmark-start”.

Attributes:

Name Type Description
name str

The name of the bookmark range being started (text:name attribute).

Methods:

Name Description
__init__

Bookmark start marker, “text:bookmark-start”.

Source code in odfdo/bookmark.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
class BookmarkStart(Element):
    """Bookmark start marker, "text:bookmark-start".

    Attributes:
        name (str): The name of the bookmark range being started (text:name attribute).
    """

    _tag = "text:bookmark-start"
    _properties = (PropDef("name", "text:name"),)

    def __init__(self, name: str = "", **kwargs: Any) -> None:
        """Bookmark start marker, "text:bookmark-start".

        Args:
            name: The name of the bookmark range being started.
        """
        super().__init__(**kwargs)
        if self._do_init:
            self.name = name

_properties class-attribute instance-attribute

_properties = (PropDef('name', 'text:name'),)

_tag class-attribute instance-attribute

_tag = 'text:bookmark-start'

name instance-attribute

name = name

__init__

__init__(name: str = '', **kwargs: Any) -> None

Bookmark start marker, “text:bookmark-start”.

Parameters:

Name Type Description Default
name str

The name of the bookmark range being started.

''
Source code in odfdo/bookmark.py
175
176
177
178
179
180
181
182
183
def __init__(self, name: str = "", **kwargs: Any) -> None:
    """Bookmark start marker, "text:bookmark-start".

    Args:
        name: The name of the bookmark range being started.
    """
    super().__init__(**kwargs)
    if self._do_init:
        self.name = name