Giter VIP home page Giter VIP logo

linxueyuanstdio / streamlit-markdown Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 5.44 MB

a streaming markdown component for streamlit with LaTeX, Mermaid, Table, code support. A drop-in replacement for st.markdown.

Home Page: https://streaming-markdown.streamlit.app/

License: MIT License

Shell 0.57% Python 23.20% TypeScript 28.34% JavaScript 34.05% CSS 5.89% HTML 7.95%
latex mermaid react-markdown streamlit streamlit-component

streamlit-markdown's Introduction

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

Buiding 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

streamlit-markdown's People

Contributors

linxueyuanstdio avatar

Stargazers

Peng-YM avatar Marc G avatar Jourmore avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.