Markdown

The markdown module is usefull to export tracks to markdown files. The Markdown class creates a markdown file and can add elements such as titles, images, and tables.

A markdown file can be edited using the with statement.

Note

You can read markdown files using Zettlr.

class markdown.Markdown(filename)

Bases: object

Create a markdown file. A Markdown object is composed of two fields:

  • filename (str)

  • f (file object)

__init__(filename)

Init a markdown file. It creates and opens the file.

Parameters:

filename (str) – filename (markdown file)

property filename

Get the filename.

property f

Get the file object.

__enter__()

Enter in a with statement.

write(text, break_before=True, break_after=True)

Write text in the file. You can precise if you want a break line before and/or after the text.

Parameters:
  • text (str) – text to add

  • breack_before (bool) – add a break line before the text if True

  • breack_after (bool) – add a break line after the text if True

close()

Close the file.

add_title(title, level)

Add a title to the file. You can choose the level of the title.

Parameters:
  • title (str) – title to add

  • level (int) – level of the title (must be between 1 and 6)

Raises:

Exception – invalid level for a title in md

add_image(file, name='Track')

Add an image to the file.

Parameters:
  • file (str) – filename of the image to add

  • name (str) – label of the image

add_separator()

Add a separator to the file.

add_table(array, head=True)

Add a table to the file. You can precise if you want a header or not.

Parameters:
  • array (numpy.array) – table to add

  • head (bool) – make a header if True

__exit__(exc_type, exc_value, traceback)

Exit and close the file.