Skip to main content

A Streamlit component to display markdown, which supports table, code switch, LaTeX, mermaid, and more.

Project description

streamlit-markdown

react-markdown with streaming support for streamlit webapp.

  • streaming rendering of markdown text
  • support for latex math, mermaid diagrams, code highlighting
  • support for tables, images, links

Have a try at https://streaming-markdown.streamlit.app/

Installation

pip install streamlit-markdown

Usage

static content:

from streamlit_markdown import st_markdown

markdown_text = "$ y = f(x)$"
st_markdown(markdown_text)

streaming content:

from streamlit_markdown import st_streaming_markdown

markdown_text = "$ y = f(x)$"
def token_stream():
    for token in markdown_text:
        yeild token
st_streaming_markdown(token_stream, key="token_stream") # key must be set to prevent re-rendering

combined streaming content:

from streamlit_markdown import st_streaming_markdown

markdown_text = "$ y = f(x)$"
def token_stream():
    import random
    for token in markdown_text:
        if random.rand() > 0.5:
            yeild token
        else:
            def callable_token():
                return token
            yeild callable_token
st_streaming_markdown(token_stream, key="token_stream") # key must be set to prevent re-rendering

run example:

streamlit run example.py

img.png img.png

Building from source

Prerequisites

  • nodejs >= 18.x
  • yarn >= 1.22.x
  • poetry >= 1.2.x
  • python >= 3.8.x

Building

./build.sh

Publishing

poetry publish

License

This project is licensed under the MIT 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

streamlit_markdown-1.0.7.tar.gz (3.9 MB view hashes)

Uploaded Source

Built Distribution

streamlit_markdown-1.0.7-py3-none-any.whl (2.3 MB view hashes)

Uploaded Python 3

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