Skip to main content

Library for splitting markdown documents into fragments.

Project description

Have you ever wanted to break a Markdown document into chunks? You are in luck, because that is what you can do with this package!

Install

Install this package like any other PyPI package.

pip install mdfrag

Examples

This package can be invoked as a CLI tool, or used as a library in your own project.

CLI Example

To split this document into chunks of 500 bytes, use the following CLI command:

python -m mdfrag docs/user-guide.md 500 

For more information, run python -m mdfrag --help. Additionally, see __main__.py.

Code Example

Use the mdfrag.split_markdown() function to split your markdown document.

See the docstring for more detailed information. Additionally, see __main__.py for an implementation of the below example.

import mdfrag

frags = None
with open('docs/user-guide.md', 'r') as f:
    frags = mdfrag.split_markdown(f.read(), 512)

# Walk through the list of fragments and write them to their appropriate files. 
for count, fragment in enumerate(frags):
    with open(f'output_{count}.md', 'w') as dest:
        dest.write(fragment)

Performance Considerations

If you select a small fragment-size, and your document contains large blocks of Markdown, the split_markdown function will struggle!

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

mdfrag-0.1.0.tar.gz (13.0 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: mdfrag-0.1.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.0.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.8

File hashes

Hashes for mdfrag-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a7a1d9ee6cff0d54e8a211d01d8de0fe8669a1a430a1e8c4d2f2ac36c35e7588
MD5 7f05dd40038c91726abedaa7d6379104
BLAKE2b-256 d8d7963960711b627f9143eec75533b50f78841e675a3ffa620a5df5a406179b

See more details on using hashes here.

Supported by

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