Skip to main content

streaming markdown to html converter

Project description

md_streamer-py Streaming Markdown to HTML Converter

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.3.tar.gz (7.2 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.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for md_streamer-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ba2b5b2073c878a94cb8048e59699d6da1cd84aa3864a0710e8f9a27ecf91026
MD5 09d56bbc96afd7e7986b2ecfe3394150
BLAKE2b-256 d25a926086ae7182e2861d87f0f8df7f8b31851d6466012dbc2a2121e2ad8e92

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for md_streamer-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ae139448179a39c1fa3e474d0ac5e6c3e766b8d13e81e178e3caf12e53a79c0e
MD5 e5be428246c0f040dfd14b775404ff7b
BLAKE2b-256 fec24f822aee7553cbad61abe6256a9470f9ae3aed148fb3f4e990e76fc76c1f

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