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.2.0.tar.gz (13.3 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for humanmark-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1ac8bbe7f955d5c3e5b454a0695076aa3535950767a73705c5836c62bd190adf
MD5 a6aedcf5996e8baff2dea61b024f8d2f
BLAKE2b-256 f8c2020f8f67572532668cd87c9c6ec431decb4d10803b273a3ac8a82d920a79

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