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
Advanced Usage
Style Customization
There are two ways to customize.
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
Built Distribution
File details
Details for the file streamlit_markdown-1.0.9.tar.gz
.
File metadata
- Download URL: streamlit_markdown-1.0.9.tar.gz
- Upload date:
- Size: 3.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.16 Darwin/24.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3378ffa454dd92e386e538a4f61adf23213770670f8f2ea271668becee6c9001 |
|
MD5 | d1757b5fac4b240b70330996626eacdd |
|
BLAKE2b-256 | 9f5f0deb149780b642ee618f03cff6d2d4888b9ea8e05c5d54a0517de864c32b |
File details
Details for the file streamlit_markdown-1.0.9-py3-none-any.whl
.
File metadata
- Download URL: streamlit_markdown-1.0.9-py3-none-any.whl
- Upload date:
- Size: 2.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.16 Darwin/24.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b10f953db9161dc0209440555a818e741159b4510f936ea0073a246138f9be39 |
|
MD5 | 1d683b5ca6dd3acfa080a27291a65e23 |
|
BLAKE2b-256 | ac6e2f78258b823a0841d26573f57285c12052db18da8095d31e189aae139aac |