Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arnaudmiribel/stoc
https://github.com/arnaudmiribel/stoc
Last synced: 24 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/arnaudmiribel/stoc
- Owner: arnaudmiribel
- Created: 2022-02-06T19:00:42.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-17T15:54:57.000Z (over 2 years ago)
- Last Synced: 2024-11-03T09:42:14.300Z (2 months ago)
- Language: Python
- Size: 6.84 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Streamlit App](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://share.streamlit.io/arnaudmiribel/stoc/main)
# 📂 stoc: Table of contents in Streamlit
Learn how to generate table of contents in your Streamlit app! It's as easy as:
```python
from stoc import stoc
toc = stoc()toc.h1("Demo")
st.write("...")toc.h2("I want to talk about this")
st.write("...")toc.h3("Smaller again")
st.write("...")toc.h2("Another subtitle")
st.write("...")toc.h3("I also should address that")
st.write("...")toc.h2("Conclusion")
st.write("...")toc.toc()
```Or, if you have a large block of markdown, and want to add in a table of contents, you
can do:```python
md = """
# Demo
...## I want to talk about this
...### Smaller again
...## Another subtitle
...### I also should address that
...## Conclusion
...
"""stoc.from_markdown(md)
```And you'll see the table of contents being generated in your sidebar:
![stoc-demo](https://user-images.githubusercontent.com/7164864/153219373-efc78512-b53d-406e-9560-7c25a09b878f.gif)