Skip to main content

Python tool to write Markdown as code easily.

Project description

MarkdownIO

Pypi Version Python Version CI Coverage Status Project license Code Style

Python tool to write Markdown as code easily.

Installation

$ pip install markdownio

Usage

from markdownio import MarkdownIO, span
from markdownio.block import TableHeader

markdown = 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='<p>Test</p>', language='html')

print(markdown.output())

output:

# My test document

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus rutrum consequat **odio** et mollis. p
![img](path/img.jpg "img")

| Col1 | Col2 | Col3   |
| ---- | ---- | :----: |
| foo  | bar  | foobar |
| oof  | rab  | 2000   |

This is an interesting article: <http://test.io>

## Code example

```html
<p>Test</p>
```

Merge two documents

from markdownio import MarkdownIO

document1 = MarkdownIO()
document1.p("Part 1.")

document2 = MarkdownIO()
document2.p("Part 2.")

full_document = document1 + document2
print(full_document.output())

output:

Part 1.

Part 2.

Documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

markdownio-0.1.0.tar.gz (7.1 kB view hashes)

Uploaded source

Built Distribution

markdownio-0.1.0-py3-none-any.whl (9.8 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page