Skip to content

MkTaskList

Show source on GitHub

Node for task lists.

Example: Regular

Jinja

{{ [_mk.MkTask(True, "Item 1"), _mk.MkTask(True, "Item 2")] | MkTaskList }}

Python

MkTaskList([...])
  • Item 1
  • Item 2
- [x] Item 1
- [x] Item 2
<ul class="task-list">
<li class="task-list-item"><input type="checkbox" disabled checked/> Item 1</li>
<li class="task-list-item"><input type="checkbox" disabled checked/> Item 2</li>
</ul>
MkTaskList
├── MkTask(True, 'Item 1')
│   ╰── MkText('Item 1')
╰── MkTask(True, 'Item 2')
    ╰── MkText('Item 2')

Bases: MkContainer

__init__

__init__(content: list | str | MkNode | None = None, **kwargs: Any)

Parameters:

Name Type Description Default
content list | str | MkNode | None

Data show for the table

None
kwargs Any

Keyword arguments passed to parent

{}
Name Children Inherits
MkContainer
mknodes.basenodes.mkcontainer
A node containing other MkNodes.
graph TD
  94721311963776["mktasklist.MkTaskList"]
  94721311697232["mkcontainer.MkContainer"]
  94721308848336["mknode.MkNode"]
  94721311766592["node.Node"]
  140564252373184["builtins.object"]
  94721311697232 --> 94721311963776
  94721308848336 --> 94721311697232
  94721311766592 --> 94721308848336
  140564252373184 --> 94721311766592
/home/runner/work/mknodes/mknodes/mknodes/basenodes/mktasklist/metadata.toml
[metadata]
icon = "mdi:library"
name = "MkTaskList"

[requirements.extension."pymdownx.tasklist"]

[examples.regular]
title = "Regular"
jinja = """
{{ [_mk.MkTask(True, "Item 1"), _mk.MkTask(True, "Item 2")] | MkTaskList }}
"""

[fragments]
task = """
- [{{ "x" if node.value else " " }}] {{ node.items | join(node.block_separator) | indent }}

"""

[output.markdown]
template = """
{{ node.items | join(node.block_separator) }}
"""
mknodes.basenodes.mktasklist.MkTaskList
class MkTaskList(mkcontainer.MkContainer):
    """Node for task lists."""

    REQUIRED_EXTENSIONS = [resources.Extension("pymdownx.tasklist")]
    ICON = "material/library"

    def __init__(
        self,
        content: list | str | mknode.MkNode | None = None,
        **kwargs: Any,
    ):
        """Constructor.

        Args:
            content: Data show for the table
            kwargs: Keyword arguments passed to parent
        """
        super().__init__(content=content, block_separator="", **kwargs)

    def add_item(self, content, value):
        item = MkTask(value, content)
        self.append(item)