Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Markie

A small project for processing markdown files with metadata.

Install

pip install markie

Note: This project is still in Alpha – significant changes are expected and features are limited

Example

from pprint import pprint

from markie import Doc

main_content = """
---
title: "Ducks: And how to Make Them Pay"
year: 1894
---

# Ducks: And how to Make Them Pay

By William Cook

Author of "The Practical Poultry Breeder and Feeder";
"The Horse: its keep and management";
"Pheasants, Turkeys, and Geese: their management for pleasure and profit"
""".strip()

chapter_1 = """
## Introduction

Not so many years ago roast duck was a luxury only for the rich, unless it 
might have been a few foreign birds sent into our markets, which could 
usually be bought up at a very low price. 
""".strip()

doc = Doc.from_md(main_content)

# content can be appended with .append, or prepended with .prepend
doc.append(chapter_1)

# Metadata can be retrieved and set
doc.metadata["authors"] = ["William Cook"]

# can be pretty printed to quickly glean the overall document structure
pprint(doc)

# Iterating over docs yields markdown-it tokens in order
# pprint([*doc])

# Docs are rendered to markdown
with open(f"{doc.metadata['title']}.md", "w") as f:
    f.write(doc.render())

The above would print:

Doc(metadata={'authors': ['William Cook'],
              'title': 'Ducks: And how to Make Them Pay',
              'year': 1894},
    preamble='',
    sections=[Section(level=1,
                      title='Ducks: And how to Make Them Pay',
                      preamble='By William Cook\n'
                               '\n'
                               'Author of "The Practical Poultry Breeder and '
                               'Feeder";\n'
                               '"The Horse: its keep and management";\n'
                               '"Pheasants, Turkeys, and Geese: their '
                               'management for pleasure and profit"',
                      subsections=[Section(level=2,
                                           title='Introduction',
                                           preamble='Not so many years ago '
                                                    'roast duck was a luxury '
                                                    'only for the rich, unless '
                                                    'it\n'
                                                    'might have been a few '
                                                    'foreign birds sent into '
                                                    'our markets, which could\n'
                                                    'usually be bought up at a '
                                                    'very low price.',
                                           subsections=[])])])

And write the following to a file "Ducks: And how to Make Them Pay.md":

---
title: 'Ducks: And how to Make Them Pay'
year: 1894
authors:
  - William Cook
---

# Ducks: And how to Make Them Pay

By William Cook

Author of "The Practical Poultry Breeder and Feeder";
"The Horse: its keep and management";
"Pheasants, Turkeys, and Geese: their management for pleasure and profit"

## Introduction

Not so many years ago roast duck was a luxury only for the rich, unless it
might have been a few foreign birds sent into our markets, which could
usually be bought up at a very low price.

Notes for Developers

Tests

Install the test requirements from tests/requirements.txt.

These tests use ApprovalTests and pytest with the ApprovalTests pytest plugin. To enable diff checking on PyCharm, see their documentation which describes how to set up a run configuration which uses PyCharm's built-in diff checker.

Metadata

Release files for markie 0.0.1a3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for markie 0.0.1a3
File Size Uploaded
markie-0.0.1a3.tar.gz 13.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for markie 0.0.1a3
File Interpreter ABI Platform
markie-0.0.1a3-py3-none-any.whl Python 3 none any Details

Total release size: 22.4 kB

Release files / markie-0.0.1a3.tar.gz

Download URL markie-0.0.1a3.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3bdfafaf4be9589a5737ad63e53366ab4214b0fce3a24ae1c981ab5c9aa354da
BLAKE2b-256 checksum
How to use checksums
f3efae5a1fd9e20afd0ab0525acaacdb6541f01ff2cbe5f087d2c149872412b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / markie-0.0.1a3-py3-none-any.whl

Download URL markie-0.0.1a3-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
93f6da64f7254e2a5ec60fbe7ec098a059396ee9caf6ab059ccb5269f8b12d97
BLAKE2b-256 checksum
How to use checksums
9ee1a7f3e00b71977a5ca3aae349db0eaae0a2a25c3849da33f7f6332466e240
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page