Skip to main content

Human-friendly markdown.

Project description

HumanMark

A human-friendly markdown generator. Accidentally also really useful for manipulating existing markdown.

📝 Parse & Modify Markdown

Editing existing markdown is trivial. Maybe we want to uppercase every header:

from humanmark import loads, Header, (text

fragment = loads('''# Hello World!

This is a sample document.
''')

for text in fragment.find(Header / Text):
    text.content = text.content.upper()

fragment.pprint()

Maybe we wanted to make sure we'd only edit top-level headers. We would just add a filter to our find():

headers = fragment.find(Header, f=lambda header: header.level == 1)

🙈 Why?

Manually updating a Awesome-style project's README.md sucks. Dead links, unsorted, royal pain to add and update star and fork counts, etc. So I created a meta-project, Awesome^2, to generate these README.md files automatically from an index.yaml. Originally, this just used a Jinja2 template to output the markdown, which sucked. Getting line wrapping and whitespace correct was non-trivial. So, made a generator.

Then I realized I'd need to parse markdown anyways, both to support having extra markdown in the header and footers of an index.yaml, and to ease conversion of existing README.md files to an index.yaml. So, made the generator bi-directional.

⚗ Testing

HumanMark has good test coverage via pytest. Install the extras with:

pip install -e ".[tests]"
pip install -e ".[cli]"

... and run the tests with:

pytest

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

humanmark-0.1.0.tar.gz (13.2 kB view details)

Uploaded Source

File details

Details for the file humanmark-0.1.0.tar.gz.

File metadata

  • Download URL: humanmark-0.1.0.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for humanmark-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7340be41d512517fb0e77558193998be8b73845aa3f20111b0d9746aec8b5b91
MD5 56d71fc6e89732fd1a3bea5aeaebfc98
BLAKE2b-256 b85ac14adb5999895bf739dc68a21160536204ee1774256ccdee417be36c8ecc

See more details on using hashes here.

Supported by

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