MkBlockQuote¶
BlockQuote node.¶
Example: Regular
Jinja
{{ "Some text" | MkBlockQuote }}
Python
MkBlockQuote()
Some text
> Some text
<blockquote>
<p>Some text</p>
</blockquote>
Some text
MkBlockQuote
╰── MkText('Some text')
Example: Nested
Jinja
{{ "Nested!" | MkBlockQuote | MkBlockQuote }}
Python
MkContainer()
Nested!
Nested!
> Nested!
> > Nested!
<blockquote>
<p>Nested!</p>
</blockquote>
<blockquote>
<blockquote>
<p>Nested!</p>
</blockquote>
</blockquote>
MkContainer
├── MkBlockQuote()
│ ╰── MkText('Nested!')
╰── MkBlockQuote()
├── MkBlockQuote()
│ ╰── MkText('Nested!')
Name |
Children |
Inherits |
|---|---|---|
MkContainer |
graph TD
1647548858["mkblockquote.MkBlockQuote"]
835538629["mkcontainer.MkContainer"]
1956333208["mkcontainer.MkContainerBase"]
1359323199["mknode.MkNode"]
2751680898["builtins.object"]
835538629 --> 1647548858
1956333208 --> 835538629
1359323199 --> 1956333208
2751680898 --> 1359323199
/home/runner/work/mknodes/mknodes/src/mknodes/basenodes/mkblockquote/metadata.toml¶
[metadata]
icon = "mdi:format-quote-open"
name = "MkBlockQuote"
[examples.regular]
title = "Regular"
jinja = """
{{ "Some text" | MkBlockQuote }}
"""
[examples.nested]
title = "Nested"
description = "We can also nest blocks, they will adjust their delimiters automatically."
jinja = """
{{ "Nested!" | MkBlockQuote | MkBlockQuote }}
"""
[output.markdown]
template = """
{{ node.get_items() | join(node.block_separator) | indent(width="> ", first=True) | rstrip("\n") }}
"""
# [output.html]
# template = """
# <blockquote>
# {{ node.get_items() | join(node.block_separator) }}
# </blockquote>
# """
[output.rst]
template = """
{{ node.get_items() | join(node.block_separator) | indent(width=" ", first=True) | rstrip("\n") }}
"""
mknodes.basenodes.mkblockquote.MkBlockQuote¶
10class MkBlockQuote(mkcontainer.MkContainer):
11 """BlockQuote node."""
12
13 ICON = "material/format-quote-open"
14 STATUS = "new"
15
16 def get_content(self) -> resources.NodeContent:
17 """Single-pass: get content and apply blockquote indentation."""
18 content = super().get_content()
19 md = textwrap.indent(content.markdown, "> ").rstrip("\n") + "\n"
20 return resources.NodeContent(markdown=md, resources=content.resources)
21
22 def to_md_unprocessed(self) -> str:
23 content = self.get_content()
24 return content.markdown
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/format-quote-open
status: new
title: MkBlockQuote