Paragraph
Paragraph class for “text:p” tag and PageBreak().
Classes:
| Name | Description |
|---|---|
LineBreak |
Representation of a line break, “text:line-break”. |
Paragraph |
An ODF paragraph, “text:p”. |
Spacer |
Representation of several spaces, “text:s”. |
Span |
A span tag (styled text in paragraph), “text:span”. |
Tab |
Representation of a tabulation, “text:tab”. |
Functions:
| Name | Description |
|---|---|
PageBreak |
Create an empty paragraph configured for a manual page break. |
__all__
module-attribute
__all__ = [
"LineBreak",
"PageBreak",
"Paragraph",
"Spacer",
"Span",
"Tab",
]
LineBreak
Bases: MDLineBreak, Element
Representation of a line break, “text:line-break”.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize the LineBreak element. |
__str__ |
|
Attributes:
| Name | Type | Description |
|---|---|---|
text |
str
|
Get the textual representation of the line break. |
Source code in odfdo/line_break.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 | |
_tag
class-attribute
instance-attribute
_tag = 'text:line-break'
text
property
writable
text: str
Get the textual representation of the line break.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Always returns a newline character (“\n”). |
__init__
__init__(**kwargs: Any) -> None
Initialize the LineBreak element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional keyword arguments for the parent |
{}
|
Source code in odfdo/line_break.py
39 40 41 42 43 44 45 | |
__str__
__str__() -> str
Source code in odfdo/line_break.py
47 48 | |
Paragraph
Bases: MDParagraph, UserDefinedMixin, LinkMixin, ParaFormattedTextMixin, ParaMixin, NoteMixin, Element
An ODF paragraph, “text:p”.
The “text:p” element represents a paragraph, which is the basic unit of text in an OpenDocument file.
Methods:
| Name | Description |
|---|---|
__init__ |
Initialize a Paragraph element ( |
__str__ |
|
Attributes:
| Name | Type | Description |
|---|---|---|
style |
|
|
text |
|
Source code in odfdo/paragraph.py
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 | |
_properties
class-attribute
instance-attribute
_properties: tuple[PropDef | PropDefBool, ...] = (
PropDef("style", "text:style-name"),
)
_tag
class-attribute
instance-attribute
_tag = 'text:p'
style
instance-attribute
style = style
text
instance-attribute
text = ''
__init__
__init__(
text_or_element: str | bytes | Element | None = None,
style: str | None = None,
formatted: bool = True,
**kwargs: Any,
)
Initialize a Paragraph element (text:p).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text_or_element
|
str | bytes | Element | None
|
Initial content for the paragraph.
If a string/bytes, it’s treated as plain text. If an |
None
|
style
|
str | None
|
The name of the style to apply to the paragraph. |
None
|
formatted
|
bool
|
If True (default), special characters ( |
True
|
**kwargs
|
Any
|
Additional keyword arguments for the parent |
{}
|
Source code in odfdo/paragraph.py
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 | |
__str__
__str__() -> str
Source code in odfdo/paragraph.py
108 109 | |
Spacer
Bases: MDSpacer, Element
Representation of several spaces, “text:s”.
This element shall be used to represent the second and all following ” ” (U+0020, SPACE) characters in a sequence of ” ” (U+0020, SPACE) characters. It’s good practice to use this element only for the second and all following SPACE characters in a sequence, though it’s not an error if the preceding character is not a white space.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a Spacer element, “text:s”, representing several spaces. |
__str__ |
|
Attributes:
| Name | Type | Description |
|---|---|---|
length |
int
|
Get the number of spaces represented by the spacer. |
number |
str | None
|
|
text |
str
|
Get the string representation of the spacer. |
Source code in odfdo/spacer.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 | |
_properties
class-attribute
instance-attribute
_properties: tuple[PropDef | PropDefBool, ...] = (
PropDef("number", "text:c"),
)
_tag
class-attribute
instance-attribute
_tag = 'text:s'
length
property
writable
length: int
Get the number of spaces represented by the spacer.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The number of spaces. |
number
instance-attribute
number: str | None = str(number)
text
property
writable
text: str
Get the string representation of the spacer.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string composed of spaces, e.g., ” “. |
__init__
__init__(number: int | None = 1, **kwargs: Any) -> None
Create a Spacer element, “text:s”, representing several spaces.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
int | None
|
The number of spaces. Defaults to 1. |
1
|
Source code in odfdo/spacer.py
47 48 49 50 51 52 53 54 55 56 57 58 | |
__str__
__str__() -> str
Source code in odfdo/spacer.py
60 61 | |
Span
Bases: MDSpan, MDParagraph, UserDefinedMixin, LinkMixin, ParaFormattedTextMixin, ParaMixin, NoteMixin, Element
A span tag (styled text in paragraph), “text:span”.
This element is used for inline text styling within a paragraph. It can contain text content and is often associated with a text style.
Inherits from various mixins to provide markdown, paragraph, and note functionalities.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a span element “text:span” of the given style containing the |
__str__ |
|
Attributes:
| Name | Type | Description |
|---|---|---|
style |
|
|
text |
|
Source code in odfdo/span.py
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 | |
_properties
class-attribute
instance-attribute
_properties = (
PropDef("style", "text:style-name"),
PropDef("class_names", "text:class-names"),
)
_tag
class-attribute
instance-attribute
_tag = 'text:span'
style
instance-attribute
style = style
text
instance-attribute
text = ''
__init__
__init__(
text: str | None = None,
style: str | None = None,
formatted: bool = True,
**kwargs: Any,
) -> None
Create a span element “text:span” of the given style containing the optional given text.
If “formatted” is True (the default), the given text is appended with
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str | None
|
The text content for the span. |
None
|
style
|
str | None
|
The style name for the span. |
None
|
formatted
|
bool
|
If True, special characters in |
True
|
Source code in odfdo/span.py
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 | |
__str__
__str__() -> str
Source code in odfdo/span.py
98 99 | |
Tab
Bases: MDTab, Element
Representation of a tabulation, “text:tab”.
This element represents the [UNICODE] tab character (HORIZONTAL TABULATION, U+0009). The position attribute indicates the number of the tab-stop to which a tab character refers, where position 0 marks the start margin of a paragraph. Layout-oriented consumers should determine tab positions based on style information.
Methods:
| Name | Description |
|---|---|
__init__ |
Create a tabulation element “text:tab”. |
__str__ |
|
Attributes:
| Name | Type | Description |
|---|---|---|
position |
|
|
text |
str
|
Get the text content, which is always a tab character. |
Source code in odfdo/tab.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 | |
_properties
class-attribute
instance-attribute
_properties: tuple[PropDef | PropDefBool, ...] = (
PropDef("position", "text:tab-ref"),
)
_tag
class-attribute
instance-attribute
_tag = 'text:tab'
position
instance-attribute
position = str(position)
text
property
writable
text: str
Get the text content, which is always a tab character.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The tab character (” “). |
__init__
__init__(
position: int | None = None, **kwargs: Any
) -> None
Create a tabulation element “text:tab”.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
int | None
|
The position of the tab-stop. If provided, must be a non-negative integer. |
None
|
Source code in odfdo/tab.py
49 50 51 52 53 54 55 56 57 58 | |
__str__
__str__() -> str
Source code in odfdo/tab.py
60 61 | |
PageBreak
PageBreak() -> Paragraph
Create an empty paragraph configured for a manual page break.
To properly render this page break, the document must have the
“odfdopagebreak” style registered using document.add_page_break_style().
Returns:
| Name | Type | Description |
|---|---|---|
Paragraph |
Paragraph
|
An empty |
Source code in odfdo/paragraph.py
115 116 117 118 119 120 121 122 123 124 | |