Skip to main content

An easy-to-use Python to Markdown generator.

Project description

markdownmaker

PyPI PyPI - Python Version PyPI - Downloads PyPI - License

markdownmaker is an easy-to-use minimal library to generate a Markdown document with a Python API. Actually, this document you are reading right now was generated with markdownmaker for demonstration purposes (source). Currently it uses Github Flavored Markdown but more flavors might follow.

This library was developed to aid with generating a reference for Armory3D's logic nodes, thus its feature scope is rather small and the output might have some bugs when creating complex documents. If you encounter problems, please open an issue.

Installation

markdownmaker is installed via pip:

pip install markdownmaker

Usage (API)

Import the following:

from markdownmaker.document import Document
from markdownmaker.markdownmaker import *

Then, create a document:

doc = Document()

After you finished creating the document, doc.write() returns the Markdown source code.

Emphasis

doc.add(Paragraph(Italic("This text will be italic!")))
doc.add(Paragraph(Bold("This text will be bold!")))

doc.add(Paragraph(f"You can also combine {Bold(Italic('bold and italic text!'))}"))

This text will be italic!

This text will be bold!

You can also combine bold and italic text!

Headers

doc.add(Header("This is a header"))
with HeaderSubLevel(doc):
    doc.add(Header("This is a sub-header"))
    with HeaderSubLevel(doc):
        doc.add(Header("This is a sub-sub-header"))

This is a header

This is a sub-header

This is a sub-sub-header

Lists

doc.add(OrderedList((
    "Item 1", 
    "Item 2", 
    UnorderedList((
        Bold("Sub-item A"), 
        Italic("Sub-item B"))), 
    "Item 3")))
  1. Item 1
  2. Item 2
  • Sub-item A
  • Sub-item B
  1. Item 3

Horizontal Rule

doc.add(HorizontalRule())

Links and Images

doc.add(Link(label='Go to top', url='#markdownmaker'))
doc.add(Image(url='https://gitlab.com/uploads/-/system/project/avatar/21351489/markdownmaker.png?width=40', alt_text='logo'))

Go to top

logo

Code

doc.add(CodeBlock("""import this
import __hello__""", language="python"))

doc.add(Paragraph(f"{InlineCode('Inline code')} is also supported!"))
import this
import __hello__

Inline code is also supported!

Quotes

doc.add(Quote(f"""Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec et quam at eros dignissim accumsan. Aenean quis sagittis dolor. Ut justo nisl,
lobortis nec elit id, dictum ullamcorper ipsum. Fusce eu ullamcorper eros, nec
feugiat lectus.

{Italic(Bold("Albert Einstein."))}"""))

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et quam at eros dignissim accumsan. Aenean quis sagittis dolor. Ut justo nisl, lobortis nec elit id, dictum ullamcorper ipsum. Fusce eu ullamcorper eros, nec feugiat lectus.

Albert Einstein.

License

markdownmaker is licensed under the zlib license.

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

markdownmaker-0.4.0.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

markdownmaker-0.4.0-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page