MkSpeechBubble

github Show source on GitHub

Node for showing a css-based speech bubble.

Example: Regular

Jinja

{{ "some text" | MkSpeechBubble }}

Python

MkSpeechBubble()

some text

<div class="speech bottom">

some text

</div>
<div class="speech bottom">
<p>some text</p>
</div>
<div class="speech bottom">

some text

</div>
MkSpeechBubble
╰── MkText('some text')

Example: No arrow

Jinja

{{ "some text" | MkSpeechBubble(arrow=None) }}

Python

MkSpeechBubble(arrow=None)

some text

<div class="speech">

some text

</div>
<div class="speech">
<p>some text</p>
</div>
<div class="speech">

some text

</div>
MkSpeechBubble
╰── MkText('some text')

class MkSpeechBubble(mkcontainer.MkContainer)

Name

Children

Inherits

MkContainer
mknodes.basenodes.mkcontainer
A node containing other MkNodes.

graph TD
  1965962441["mkspeechbubble.MkSpeechBubble"]
  835538629["mkcontainer.MkContainer"]
  1956333208["mkcontainer.MkContainerBase"]
  1359323199["mknode.MkNode"]
  2751680898["builtins.object"]
  835538629 --> 1965962441
  1956333208 --> 835538629
  1359323199 --> 1956333208
  2751680898 --> 1359323199
/home/runner/work/mknodes/mknodes/src/mknodes/basenodes/mkspeechbubble/metadata.toml
[metadata]
icon = "mdi:chat"
name = "MkSpeechBubble"

[[resources.css]]
filename = "speechbubble.css"

[examples.regular]
title = "Regular"
jinja = """
{{ "some text" | MkSpeechBubble }}
"""

[examples.no_arrow]
title = "No arrow"
jinja = """
{{ "some text" | MkSpeechBubble(arrow=None) }}
"""

[output.markdown]
template = """
<div class="speech{{ node.arrow | add(prefix=' ') }}" markdown="1">
{{node.get_items()  | join(node.block_separator) }}
</div>
"""
mknodes.basenodes.mkspeechbubble.MkSpeechBubble
13class MkSpeechBubble(mkcontainer.MkContainer):
14    """Node for showing a css-based speech bubble."""
15
16    ICON = "material/chat"
17    CSS = [resources.CSSFile("speechbubble.css")]
18
19    def __init__(
20        self,
21        content: str | mknode.MkNode | list | None = None,
22        *,
23        arrow: Literal["top", "bottom", "left", "right"] | None = "bottom",
24        **kwargs: Any,
25    ) -> None:
26        self.arrow = arrow
27        super().__init__(content=content or [], **kwargs)
28
29    def get_element(self) -> xml.Div:
30        klass = f"speech {self.arrow}" if self.arrow else "speech"
31        root = xml.Div(klass, markdown=True)
32        root.text = "\n" + super().to_md_unprocessed() + "\n"
33        return root
34
35    def to_md_unprocessed(self) -> str:
36        element = self.get_element()
37        return element.to_string()
Page info
Code for this page
mknodes.manual.nodes_section.create_section_for_nodes
 93def create_section_for_nodes(
 94    nav: mk.MkNav,
 95    klasses: Sequence[type[mk.MkNode]],
 96) -> mk.MkTable:
 97    table = mk.MkTable(columns=["Node", "Docstrings", "Markdown extensions"])
 98    for kls in klasses:
 99        tpl = "classpage_custom.jinja"
100        page = mk.MkClassPage(kls, icon=kls.ICON, template_path=tpl, parent=nav, hide="toc")
101        nav += page
102        if kls.STATUS:
103            page.metadata.status = kls.STATUS
104        elif kls.JS_FILES:
105            page.metadata.status = "js"
106        elif kls.CSS:
107            page.metadata.status = "css"
108        page.created_by = create_section_for_nodes
109        link = mk.MkLink(page, kls.__name__, icon=kls.ICON)
110        extensions = ", ".join(f"`{i}`" for i in kls.REQUIRED_EXTENSIONS)
111        table.add_row((link, kls.__doc__, extensions))
112    return table
Resources
Resources(css=[],
          markdown_extensions={'admonition': {},
                               'pymdownx.details': {},
                               'pymdownx.highlight': {'anchor_linenums': True,
                                                      'line_spans': '__span',
                                                      'pygments_lang_class': True},
                               'pymdownx.superfences': {'custom_fences': [{'class': 'mermaid',
                                                                           'format': <function fence_code_format at 0x7ff77e88b060>,
                                                                           'name': 'mermaid'}]},
                               'pymdownx.tabbed': {},
                               'tables': {}},
          plugins=[Plugin('mkdocstrings')],
          js=[],
          assets=[],
          packages=[])
Metadata
created:
  source_filename: /home/runner/work/mknodes/mknodes/src/mknodes/manual/nodes_section.py
  source_function: create_section_for_nodes
  source_line_no: 93
hide:
- toc
icon: material/chat
status: css
title: MkSpeechBubble