Block elements are basic block structure of markdown document. You can build them independently and add them to a **
MarkdownIO** document or you can also use MarkdownIO short syntax. Then just call output
method to build the
markdown document.
from markdownio import MarkdownIO, block
document = MarkdownIO()
h1 = block.Header1(text="Hello")
document.add(h1)
# Short syntax
document.p(text="Hello.")
print(document.output())
output:
# Hello
Hello.
document.p(text="This is a paragraph.")
This is a paragraph.
document.h1(text="H1 header")
document.h2(text="H2 header")
document.h3(text="H3 header")
document.h4(text="H4 header")
document.h5(text="H5 header")
document.h6(text="H6 header")
# H1 header
## H2 header
### H3 header
#### H4 header
##### H5 header
###### H6 header
document.ul(items=["foo", "bar"])
document.ol(items=["foo", "bar"])
document.ul(items=["foo", "bar", ["oof", "rab"], "foobar"])
* foo
* bar
1. foo
2. bar
* foo
* bar
* oof
* rab
* foobar
Mixed list with OrderedList
or UnorderedList
:
from markdownio.block import OrderedList
document.ul(items=["foo", "bar", OrderedList(items=["oof", "rab"], "foobar")])
* foo
* bar
1. oof
2. rab
* foobar
document.quote(text="This is a quote.")
> This is a quote.
document.hr()
---
document.code(text="<p>Html here!<\p>", language="html")
```html
<p>Html here!<\p>
```
Column alignments: TableHeader.center
, TableHeader.left
and TableHeader.right
from markdownio.block import TableHeader
document.table(
columns=3,
headers=['Col1', 'Col2', TableHeader.center('Col3')],
rows=[
['foo', 'bar', 'foobar'],
['oof', 'rab', 2000],
]
)
| Col1 | Col2 | Col3 |
| ---- | ---- | :----: |
| foo | bar | foobar |
| oof | rab | 2000 |