MkLink
A simple Link (with optional icon and option to show up as a button).¶
Description
If no title is given, the URL is used as a title.
Example: Regular¶
Example: Button¶
Example: Colored¶
Example: With icon¶
<p><a href="https://www.google.com"><span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="currentColor" d="M14.78 3.653a3.936 3.936 0 1 1 5.567 5.567l-3.627 3.627a3.936 3.936 0 0 1-5.88-.353a.75.75 0 0 0-1.18.928a5.436 5.436 0 0 0 8.12.486l3.628-3.628a5.436 5.436 0 1 0-7.688-7.688l-3 3a.75.75 0 0 0 1.06 1.061z"/><path fill="currentColor" d="M7.28 11.153a3.936 3.936 0 0 1 5.88.353a.75.75 0 0 0 1.18-.928a5.436 5.436 0 0 0-8.12-.486L2.592 13.72a5.436 5.436 0 1 0 7.688 7.688l3-3a.75.75 0 1 0-1.06-1.06l-3 3a3.936 3.936 0 0 1-5.567-5.568z"/></svg></span> With icon.</a></p>
Example: With tooltip¶
Bases: MkNode
__init__
¶
__init__(
target: LinkableType,
title: str | None = None,
*,
tooltip: str | None = None,
icon: str | None = None,
as_button: bool = False,
primary_color: bool = False,
**kwargs: Any
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target
|
LinkableType
|
Link target |
required |
title
|
str | None
|
Title used for link |
None
|
tooltip
|
str | None
|
Tooltip for the link |
None
|
icon
|
str | None
|
Optional icon to be displayed in front of title |
None
|
as_button
|
bool
|
Whether link should be rendered as button |
False
|
primary_color
|
bool
|
If rendered as button, use primary color as background. |
False
|
kwargs
|
Any
|
keyword arguments passed to parent |
{}
|
Name | Children | Inherits |
---|---|---|
MkNode mknodes.basenodes.mknode Base class for everything which can be expressed as Markup. |
graph TD
94721311725216["mklink.MkLink"]
94721308848336["mknode.MkNode"]
94721311766592["node.Node"]
140564252373184["builtins.object"]
94721308848336 --> 94721311725216
94721311766592 --> 94721308848336
140564252373184 --> 94721311766592
/home/runner/work/mknodes/mknodes/mknodes/basenodes/mklink/metadata.toml
[metadata]
icon = "octicon:link-24"
name = "MkLink"
[examples.regular]
title = "Regular"
jinja = """
{{ "https://www.google.com" | MkLink("This is a link") }}
"""
[examples.button]
title = "Button"
jinja = """
{{ "https://www.google.com" | MkLink("Disguised as button.", as_button=True) }}
"""
[examples.colored]
title = "Colored"
jinja = """
{{ "https://www.google.com" | MkLink("Colored.", as_button=True, primary_color=True) }}
"""
[examples.with_icon]
title = "With icon"
jinja = """
{{ "https://www.google.com" | MkLink("With icon.", icon="octicon:link-24") }}
"""
[examples.with_tooltip]
title = "With tooltip"
jinja = """
{{ "https://www.google.com" | MkLink("With tooltip.", as_button=True) }}
"""
# [examples.to_page]
# title = "To Page"
# jinja = """
# {{ page.parent.index_page | MkLink("To page.") }}
# """
[output.markdown]
template = """
[{{ node.icon | add(suffix=" ") }}{{ node.title }}]({{ node.url }}{{ node.tooltip | add(prefix=" '", suffix="'")}})
"""
[output.rst]
template = """
`{{ node.title }} <{{ node.url }}>`_
"""