Skip to content

Meta Hyperlink Behaviour

MetaHyperlinkBehaviour class for “meta:hyperlink-behaviour” tag.

Classes:

Name Description
MetaHyperlinkBehaviour

Container for hyperlink-behaviour properties, “meta:hyperlink-

Bases: Element

Container for hyperlink-behaviour properties, “meta:hyperlink- behaviour”.

Methods:

Name Description
__init__

Initialize a MetaHyperlinkBehaviour element.

__repr__
__str__
as_dict

Return the attributes of the hyperlink behavior element as a Python dictionary.

from_dict

Set the attributes of the hyperlink behavior element from a Python dictionary.

Attributes:

Name Type Description
show
target_frame_name
Source code in odfdo/meta_hyperlink_behaviour.py
29
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
class MetaHyperlinkBehaviour(Element):
    """Container for hyperlink-behaviour properties, "meta:hyperlink-
    behaviour".
    """

    _tag = "meta:hyperlink-behaviour"
    _properties: tuple[PropDef | PropDefBool, ...] = (
        PropDef("target_frame_name", "office:target-frame-name"),
        PropDef("show", "xlink:show"),
    )

    def __init__(
        self,
        target_frame_name: str = "_blank",
        show: str = "replace",
        **kwargs: Any,
    ) -> None:
        """Initialize a MetaHyperlinkBehaviour element.

        The `meta:hyperlink-behaviour` element specifies the default behavior
        for hyperlinks in a document.

        Args:
            target_frame_name: The name of the target frame for the hyperlink.
                Defaults to "_blank" (new window/tab).
            show: Specifies how the target resource is presented.
                Defaults to "replace".
            **kwargs: Additional keyword arguments for the parent `Element` class.
        """
        super().__init__(**kwargs)

        if self._do_init:
            self.target_frame_name = target_frame_name
            self.show = show

    def __repr__(self) -> str:
        return (
            f"<{self.__class__.__name__} tag={self.tag} "
            f"target={self.target_frame_name} show={self.show}>"
        )

    def __str__(self) -> str:
        return f"({self.target_frame_name})"

    def as_dict(self) -> dict[str, Any]:
        """Return the attributes of the hyperlink behavior element as a Python dictionary.

        Returns:
            dict[str, Any]: A dictionary containing the hyperlink behavior
                attributes, with keys like "office:target-frame-name" and "xlink:show".
        """
        return {
            "office:target-frame-name": self.target_frame_name,
            "xlink:show": self.show,
        }

    def from_dict(self, data: dict[str, Any]) -> None:
        """Set the attributes of the hyperlink behavior element from a Python dictionary.

        Args:
            data: A dictionary containing the hyperlink behavior
                attributes (e.g., "office:target-frame-name", "xlink:show").
        """
        self.target_frame_name = str(data.get("office:target-frame-name", ""))
        self.show = str(data.get("xlink:show", "replace"))
_properties: tuple[PropDef | PropDefBool, ...] = (
    PropDef(
        "target_frame_name", "office:target-frame-name"
    ),
    PropDef("show", "xlink:show"),
)
_tag = 'meta:hyperlink-behaviour'
show = show
target_frame_name = target_frame_name
__init__(
    target_frame_name: str = "_blank",
    show: str = "replace",
    **kwargs: Any,
) -> None

Initialize a MetaHyperlinkBehaviour element.

The meta:hyperlink-behaviour element specifies the default behavior for hyperlinks in a document.

Parameters:

Name Type Description Default
target_frame_name str

The name of the target frame for the hyperlink. Defaults to “_blank” (new window/tab).

'_blank'
show str

Specifies how the target resource is presented. Defaults to “replace”.

'replace'
**kwargs Any

Additional keyword arguments for the parent Element class.

{}
Source code in odfdo/meta_hyperlink_behaviour.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
def __init__(
    self,
    target_frame_name: str = "_blank",
    show: str = "replace",
    **kwargs: Any,
) -> None:
    """Initialize a MetaHyperlinkBehaviour element.

    The `meta:hyperlink-behaviour` element specifies the default behavior
    for hyperlinks in a document.

    Args:
        target_frame_name: The name of the target frame for the hyperlink.
            Defaults to "_blank" (new window/tab).
        show: Specifies how the target resource is presented.
            Defaults to "replace".
        **kwargs: Additional keyword arguments for the parent `Element` class.
    """
    super().__init__(**kwargs)

    if self._do_init:
        self.target_frame_name = target_frame_name
        self.show = show
__repr__() -> str
Source code in odfdo/meta_hyperlink_behaviour.py
64
65
66
67
68
def __repr__(self) -> str:
    return (
        f"<{self.__class__.__name__} tag={self.tag} "
        f"target={self.target_frame_name} show={self.show}>"
    )
__str__() -> str
Source code in odfdo/meta_hyperlink_behaviour.py
70
71
def __str__(self) -> str:
    return f"({self.target_frame_name})"
as_dict() -> dict[str, Any]

Return the attributes of the hyperlink behavior element as a Python dictionary.

Returns:

Type Description
dict[str, Any]

dict[str, Any]: A dictionary containing the hyperlink behavior attributes, with keys like “office:target-frame-name” and “xlink:show”.

Source code in odfdo/meta_hyperlink_behaviour.py
73
74
75
76
77
78
79
80
81
82
83
def as_dict(self) -> dict[str, Any]:
    """Return the attributes of the hyperlink behavior element as a Python dictionary.

    Returns:
        dict[str, Any]: A dictionary containing the hyperlink behavior
            attributes, with keys like "office:target-frame-name" and "xlink:show".
    """
    return {
        "office:target-frame-name": self.target_frame_name,
        "xlink:show": self.show,
    }
from_dict(data: dict[str, Any]) -> None

Set the attributes of the hyperlink behavior element from a Python dictionary.

Parameters:

Name Type Description Default
data dict[str, Any]

A dictionary containing the hyperlink behavior attributes (e.g., “office:target-frame-name”, “xlink:show”).

required
Source code in odfdo/meta_hyperlink_behaviour.py
85
86
87
88
89
90
91
92
93
def from_dict(self, data: dict[str, Any]) -> None:
    """Set the attributes of the hyperlink behavior element from a Python dictionary.

    Args:
        data: A dictionary containing the hyperlink behavior
            attributes (e.g., "office:target-frame-name", "xlink:show").
    """
    self.target_frame_name = str(data.get("office:target-frame-name", ""))
    self.show = str(data.get("xlink:show", "replace"))