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 ".[test]"
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.3.1.tar.gz (14.6 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: humanmark-0.3.1.tar.gz
  • Upload date:
  • Size: 14.6 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.3.1.tar.gz
Algorithm Hash digest
SHA256 1b0b7c9819b70f82985c1db37a7377922ff9d1e9c4cdcbf8805b0b26a1ca29a2
MD5 e713576d41328437151a4e60eefe8577
BLAKE2b-256 7026774652dfe38afd87d665a1032068bfa3a220833f93fb2a3f8af7425c76e2

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