Skip to main content

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.

Metadata

Release files for md-streamer 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for md-streamer 0.1.0
File Size Uploaded
md_streamer-0.1.0.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for md-streamer 0.1.0
File Interpreter ABI Platform
md_streamer-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.1 kB

Release files / md_streamer-0.1.0.tar.gz

Download URL md_streamer-0.1.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f764cdfbf9a4c73340eb0552376ff9aad61f7fdad89de90c3d8718dd4823eb09
BLAKE2b-256 checksum
How to use checksums
1e33b56ccff8877e72e5473daafbcc2d891220ad52112fdc79e7d046aeb11a96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / md_streamer-0.1.0-py3-none-any.whl

Download URL md_streamer-0.1.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd5bcb5ed1d1e9028b2bb5f7e5b813821961bbb88f06fa9caa688ec886f26143
BLAKE2b-256 checksum
How to use checksums
8367614e6d611847cbe2878f718e811778e2b01a78dfa7e2d38a741852da4d5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page