Skip to content

Span

Span class for “text:span” tag.

Classes:

Name Description
Span

A span tag (styled text in paragraph), “text:span”.

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
100
101
class Span(
    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.
    """

    _tag = "text:span"
    _properties = (
        PropDef("style", "text:style-name"),
        PropDef("class_names", "text:class-names"),
    )

    def __init__(
        self,
        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 <CR>,
        <TAB> and multiple spaces replaced by ODF corresponding tags.

        Args:
            text: The text content for the span.
            style: The style name for the span.
            formatted: If True, special characters in `text` are
                replaced by ODF corresponding tags. Defaults to True.
            kwargs: Arbitrary keyword arguments for the Element base class.

        """
        super().__init__(**kwargs)
        if self._do_init:
            if text:
                if formatted:
                    self.text = ""
                    self.append_plain_text(text)
                else:
                    self.text = self._unformatted(text)
            if style:
                self.style = style

    def __str__(self) -> str:
        return self.inner_text

_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 , and multiple spaces replaced by ODF corresponding tags.

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 text are replaced by ODF corresponding tags. Defaults to True.

True
kwargs Any

Arbitrary keyword arguments for the Element base class.

{}
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
97
98
def __init__(
    self,
    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 <CR>,
    <TAB> and multiple spaces replaced by ODF corresponding tags.

    Args:
        text: The text content for the span.
        style: The style name for the span.
        formatted: If True, special characters in `text` are
            replaced by ODF corresponding tags. Defaults to True.
        kwargs: Arbitrary keyword arguments for the Element base class.

    """
    super().__init__(**kwargs)
    if self._do_init:
        if text:
            if formatted:
                self.text = ""
                self.append_plain_text(text)
            else:
                self.text = self._unformatted(text)
        if style:
            self.style = style

__str__

__str__() -> str
Source code in odfdo/span.py
100
101
def __str__(self) -> str:
    return self.inner_text