Skip to main content

streaming markdown to html converter

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.0.4.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.0.4-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: md_streamer-0.0.4.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.0.4.tar.gz
Algorithm Hash digest
SHA256 41aa9881824ebbf2336ab1c39d04a4cc59109e75b9caa08c8f2ca8ce45bd133c
MD5 30dd3317ab4b87d7667331780e18f403
BLAKE2b-256 c64895315178a611073380c23ad0761bc291fde2d6b0fec53c660227e658af3a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: md_streamer-0.0.4-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.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d740f65c77fc03c04347fd61c7d2f2ca88a41320ab63c0e9441789aef1a9288f
MD5 fd913077e507bb5b49e6d6a78869842b
BLAKE2b-256 017e1712d7ac62572dcf9a4b3a35445171498b7d5fccee33054ce4a6b30357db

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