Skip to main content

streaming markdown parser

Project description

Streaming Markdown to HTML Converter (md_streamer-py)

Overview

This repository provides a lightweight and efficient Python package for converting streaming Markdown content into HTML in real-time. It is designed for applications that need dynamic Markdown rendering, such as live blogging, documentation platforms, and chat applications.

Features

  • Streaming Conversion: Processes Markdown input incrementally and converts it to HTML on the fly.
  • Lightweight and Fast: Optimized for performance and minimal resource usage.
  • Easy Integration: Can be used as a standalone module or integrated into larger applications.

Installation

pip install md-streamer

Usage

Basic Example

from md_streamer import MDStreamer

md_stream_obj = MDStreamer()

example_content = """Certainly! To split a string in Python, you can use the built-in `split()` method, which divides a string into a list of substrings based on a specified delimiter. By default, it splits on whitespace."""

for md_text in example_content.split(): 
    html_text = md_stream_obj.process_chunk(f" {md_text}")
    print(html_text)

When stream ends to get final output

html_text = md_stream_obj.process_chunk("", last=True)
print(html_text)

Async Example

import asyncio
from md_streamer import MDStreamer

md_stream_obj = MDStreamer()

example_content = """Certainly! To split a string in Python, you can use the built-in `split()` method, which divides a string into a list of substrings based on a specified delimiter. By default, it splits on whitespace."""

async def md_to_html(text):
    for md_text in text.split(): 
        print(await md_stream_obj.aprocess_chunk(f" {md_text}")))
    print(await md_stream_obj.aprocess_chunk("", last=True))

asyncio.run(md_to_html(example_text))

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your improvements.

License

This project is licensed under the Apache License. See the LICENSE file for details.

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

md_streamer-0.1.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

md_streamer-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: md_streamer-0.1.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for md_streamer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f764cdfbf9a4c73340eb0552376ff9aad61f7fdad89de90c3d8718dd4823eb09
MD5 68a6389d7f7f01ba99c9c0d647f4f5a0
BLAKE2b-256 1e33b56ccff8877e72e5473daafbcc2d891220ad52112fdc79e7d046aeb11a96

See more details on using hashes here.

File details

Details for the file md_streamer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: md_streamer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for md_streamer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd5bcb5ed1d1e9028b2bb5f7e5b813821961bbb88f06fa9caa688ec886f26143
MD5 67521facb1185501f67964d1240566d3
BLAKE2b-256 8367614e6d611847cbe2878f718e811778e2b01a78dfa7e2d38a741852da4d5d

See more details on using hashes here.

Supported by

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