class mdfy.elements.list.MdList(items: list[str | MdList], depth: int = 0, indent: int = 4, numbered: bool = False)[source]

Bases: MdElement

Represents a Markdown list.

items

List of items, where each item can be a string or another MdList.

Type:

list[Union[str, MdList]]

depth

Current depth of the list.

Type:

int

indent

indent size of the list.

Type:

int

numbered

If True, the list will be numbered. Otherwise, it will be bulleted.

Type:

bool

Examples

>>> from mdfy.elements import MdList
>>>
>>> list = MdList(["item 1", "item 2"])
>>> print(list)
- item 1
- item 2
>>>
>>> list = MdList(["item 1", "item 2"], numbered=True)
>>> print(list)
1. item 1
1. item 2
>>>
>>> list = MdList([
...     "item 1",
...     [
...         "item 2.1",
...         "item 2.2"
...     ]
... ])
>>> print(list)
- item 1
    - item 2.1
    - item 2.2
__str__() str[source]

Returns a string representation of the list in Markdown format.

Returns:

Formatted markdown string for the entire list.

Return type:

str