Skip to main content

A simple python markdown files generator

Project description


A simple python3 package that facilitates the generation of markdown flavoured files


pip install markd


Initialize the module

from markd import Markdown()

markd = Markdown()

Add content blocks

add_header(text, htype=1)

Adds an htype header block to the content

markd.add_header("H2", 2)


Adds a text block to the content

markd.add_text("Sample text")

add_list_item(text, depth=None)

Adds a list item to the content with the specified text and intentation depth. The depth parameter is used to create sublists.

markd.add_list_item("List item 1")
markd.add_list_item("List item 1.1", 1)
markd.add_list_item("List item 1.2", 1)
markd.add_list_item("List item 1.2.1", 2)


Adds a linebreak block



Adds a blockquote with the specified lines of text

markd.add_blockquote("This is a blockquote")
markd.add_blockquote("This is a", "multi line", "block quote")


Adds a horizontal rule block



Adds a code block

trace = '''
Traceback (most recent call last):
File "", line 6, in <module>
    raise TypeError("Oups!")
TypeError: Oups!


add_image(url, alt_text)

Adds an image using the specified url and alt_text

markd.add_image("", "my image")


Adds a table to the content provided a list of table rows. The first row in the list, is considered to be the header.

    ["Header cell 1", "Header cell 2", "Header cell 3"],
    ["Row 1 cell 1", "Row 1 cell 2", "Row 1 cell 3"],
    ["Row 2 cell 1", "Row 2 cell 2", "Row 2 cell 3"],

Utility methods

link(url, text=None)

Creates a markdown link that can be added in the content using the available add_* methods

markd.add_text("", "test"))


Emphasizes a given text

markd.add_text(markd.emphasis("Text to be emphasized"))


Wraps the given text in italics

markd.add_text(markd.italics("Enter text here"))


Saves the file to the specified path"/path/to/save/the/")

Full Example

from markd import Markdown()

if __name__ == '__main__':
    markd = Markdown()
    markd.add_header("This an H1 headers")
    markd.add_header("This is an H2 header", 2)
    markd.add_text("Lorem ipsum text")
    markd.add_blockquote("You can also add blockquotes!!")
    markd.add_text("", "Link to google"))
    markd.add_list_item("List item 1")
    markd.add_list_item("List item 1.1", 1) # Sublist item
    markd.add_list_item("List item 1.1.1", 2) # Sublist item
    markd.add_list_item("List item 2")
    markd.add_list_item("","List item link"))
    markd.add_code("Some code here")
    markd.add_image("", "alt-text")
    ["Header cell 1", "Header cell 2", "Header cell 3"],
    ["Row 1 cell 1", "Row 1 cell 2", "Row 1 cell 3"],
    ["Row 2 cell 1", "Row 2 cell 2", "Row 2 cell 3"],
    print(markd.content) # Get the content"/path/to/save/the/")


GNU General Public License v3 (GPLv3)

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

markd-0.1.20.tar.gz (4.6 kB view hashes)

Uploaded source

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