Section
Section class for “text:section” tag.
Classes:
| Name | Description |
|---|---|
Section |
Represents a section within a text document, “text:section”. |
SectionMixin |
Mixin class for elements that can contain sections. |
Section
Bases: ListMixin, TocMixin, LinkMixin, SectionMixin
Represents a section within a text document, “text:section”.
A section is a container for document content, often used for organization or to apply specific formatting or attributes.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a Section element. |
get_formatted_text |
Return the formatted text content of the section. |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
|
|
style |
|
Source code in odfdo/section.py
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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
_properties
class-attribute
instance-attribute
_properties = (
PropDef("style", "text:style-name"),
PropDef("name", "text:name"),
)
_tag
class-attribute
instance-attribute
_tag = 'text:section'
name
instance-attribute
name = name
style
instance-attribute
style = style
__init__
__init__(
style: str | None = None,
name: str | None = None,
**kwargs: Any,
) -> None
Create a Section element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
style
|
str | None
|
The style name for the section. |
None
|
name
|
str | None
|
The name of the section. |
None
|
Source code in odfdo/section.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
get_formatted_text
get_formatted_text(context: dict | None = None) -> str
Return the formatted text content of the section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict | None
|
A dictionary of context variables. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The formatted text content. |
Source code in odfdo/section.py
141 142 143 144 145 146 147 148 149 150 151 152 | |
SectionMixin
Bases: Element
Mixin class for elements that can contain sections.
This mixin provides methods to access and manipulate “text:section” elements within a parent element.
Used by the following classes
- “draw:text-box”
- “office:text”
- “style:footer”
- “style:footer-left”
- “style:header”
- “style:header-left”
- “table:covered-table-cell”
- “table:table-cell”
- “text:deletion”
- “text:index-body”
- “text:index-title”
- “text:note-body”
- “text:section”
Methods:
| Name | Description |
|---|---|
get_section |
Return the section that matches the criteria. |
get_sections |
Return all sections that match the criteria. |
Attributes:
| Name | Type | Description |
|---|---|---|
sections |
list[Section]
|
Return all sections within the element. |
Source code in odfdo/section.py
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 | |
sections
property
sections: list[Section]
get_section
get_section(
position: int = 0, content: str | None = None
) -> Section | None
Return the section that matches the criteria.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
int
|
The index of the section to return. Defaults to 0 (first section). |
0
|
content
|
str | None
|
A regex to match in the section content. |
None
|
Returns:
| Type | Description |
|---|---|
Section | None
|
Section or None: The matching Section element, or None if not found. |
Source code in odfdo/section.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
get_sections
get_sections(
style: str | None = None, content: str | None = None
) -> list[Section]
Return all sections that match the criteria.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
style
|
str | None
|
The style name to filter by. |
None
|
content
|
str | None
|
A regex to match in the section content. |
None
|
Returns:
| Type | Description |
|---|---|
list[Section]
|
list[Section]: A list of matching Section elements. |
Source code in odfdo/section.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |