https://github.com/u8slvn/markdownio
Python tool to write Markdown as code easily.
https://github.com/u8slvn/markdownio
markdown markdown-builder python python-markdown
Last synced: 2 months ago
JSON representation
Python tool to write Markdown as code easily.
- Host: GitHub
- URL: https://github.com/u8slvn/markdownio
- Owner: u8slvn
- License: mit
- Created: 2020-03-16T09:09:26.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-11T08:10:09.000Z (over 1 year ago)
- Last Synced: 2025-04-25T01:55:45.854Z (2 months ago)
- Topics: markdown, markdown-builder, python, python-markdown
- Language: Python
- Homepage:
- Size: 69.3 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# MarkdownIO
[](https://pypi.org/project/markdownio/)
[](https://pypi.org/project/markdownio/)
[](https://github.com/u8slvn/markdownio/actions/workflows/ci.yml)
[](https://coveralls.io/github/u8slvn/markdownio?branch=master)
[](https://pypi.org/project/markdownio/)
[](https://github.com/psf/black)Python tool to write Markdown as code easily.
## Installation
```sh
$ pip install markdownio
```## Usage
```python
from markdownio import MarkdownIO, span
from markdownio.block import TableHeadermarkdown = MarkdownIO()
markdown.h1("My test document")
markdown.p(
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
"Vivamus rutrum consequat " + span.bold("odio") + " et mollis."
)
markdown.p(span.image(path="path/img.jpg", alt="img", title="img"))
markdown.table(
columns=3,
headers=['Col1', 'Col2', TableHeader.center('Col3')],
rows=[
['foo', 'bar', 'foobar'],
['oof', 'rab', 2000],
]
)
markdown.p(
text="This is an interesting article: " + span.link(path='http://test.io')
)
markdown.h2("Code example")
markdown.code(text='Test
', language='html')print(markdown.output())
```output:
~~~markdown
# My test documentLorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus rutrum consequat **odio** et mollis. p
| Col1 | Col2 | Col3 |
| ---- | ---- | :----: |
| foo | bar | foobar |
| oof | rab | 2000 |This is an interesting article:
## Code example
```html
Test
```
~~~## Merge two documents
```python
from markdownio import MarkdownIOdocument1 = MarkdownIO()
document1.p("Part 1.")document2 = MarkdownIO()
document2.p("Part 2.")full_document = document1 + document2
print(full_document.output())
```output:
```markdown
Part 1.Part 2.
```## Documentation
- [Block elements](./documentation/block.md)
- [Span elements](./documentation/span.md)