diff --git a/README.md b/README.md index f566cba..005bda8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # streamlit-embedcode -streamlit-embedcode is the easiest way to embed code snippets into your Streamlit app! This component supports the following code sharing services: +streamlit-embedcode is the easiest way to embed code snippets into your Streamlit app! This [static component](https://docs.streamlit.io/en/stable/develop_streamlit_components.html#create-a-static-component) supports the following code sharing services: - [GitHub gist](https://gist.github.com/) - [GitLab snippets](https://gitlab.com/explore/snippets) diff --git a/examples/streamlit-embedcode-docs.py b/examples/streamlit-embedcode-docs.py index 32b5dd6..70da1b3 100644 --- a/examples/streamlit-embedcode-docs.py +++ b/examples/streamlit-embedcode-docs.py @@ -47,27 +47,112 @@ github_gist + "---" + "### Example:" + with st.echo(): + + import streamlit as st + from streamlit_embedcode import github_gist + + t = st.text_input( + "Enter GitHub gist URL:", + "https://gist.github.com/randyzwitch/934d502e53f2adcb48eea2423fe4a47e", + ) + + w = st.slider("width", 300, 800, 710) + github_gist(t, width=w) + elif choice == "gitlab_snippet()": """## gitlab_snippet()""" gitlab_snippet + "---" + "### Example:" + with st.echo(): + + import streamlit as st + from streamlit_embedcode import gitlab_snippet + + t = st.text_input( + "Enter GitLab snippet URL:", "https://gitlab.com/snippets/1995463", + ) + + w = st.slider("width", 300, 800, 710) + gitlab_snippet(t, width=w) + elif choice == "pastebin_snippet()": """## pastebin_snippet()""" pastebin_snippet + "---" + "### Example:" + with st.echo(): + + import streamlit as st + from streamlit_embedcode import pastebin_snippet + + t = st.text_input( + "Enter Pastebin snippet URL:", "https://pastebin.com/i1YQv94Q", + ) + + w = st.slider("width", 300, 800, 710) + pastebin_snippet(t, width=w) + elif choice == "codepen_snippet()": """## codepen_snippet()""" codepen_snippet + "---" + "### Example:" + with st.echo(): + + import streamlit as st + from streamlit_embedcode import codepen_snippet + + t = st.text_input( + "Enter CodePen snippet URL:", "https://codepen.io/ste-vg/pen/GRooLza", + ) + + w = st.slider("width", 300, 800, 750, key="1") + h = st.slider("height", 500, 800, 600, key="2") + codepen_snippet(t, width=w, height=h) + elif choice == "ideone_snippet()": """## ideone_snippet()""" ideone_snippet + "---" + "### Example:" + with st.echo(): + + import streamlit as st + from streamlit_embedcode import ideone_snippet + + t = st.text_input("Enter Ideone snippet URL:", "https://ideone.com/vQ54cr",) + + w = st.slider("width", 300, 800, 710, key="1") + ideone_snippet(t, width=w) + elif choice == "tagmycode_snippet()": """## tagmycode_snippet()""" tagmycode_snippet + + "---" + "### Example:" + with st.echo(): + + import streamlit as st + from streamlit_embedcode import tagmycode_snippet + + t = st.text_input( + "Enter Ideone snippet URL:", + "https://tagmycode.com/snippet/5965/recursive-list-files-in-a-dir#.Xwyc43VKglU", + ) + + w = st.slider("width", 300, 800, 710, key="1") + tagmycode_snippet(t, width=w) diff --git a/streamlit_embedcode/__init__.py b/streamlit_embedcode/__init__.py index 37558f6..781918b 100644 --- a/streamlit_embedcode/__init__.py +++ b/streamlit_embedcode/__init__.py @@ -43,7 +43,7 @@ def github_gist(link, height=600, width=950, scrolling=True): Example ------- - >>> github_gist("https://gist.github.com/randyzwitch/be8c5e9fb5b8e7b046afebcac12e5087/") + >>> github_gist("https://gist.github.com/randyzwitch/934d502e53f2adcb48eea2423fe4a47e") """ gistcreator, gistid = _clean_link(link).split("/")[-2:] @@ -71,7 +71,7 @@ def gitlab_snippet(link, height=600, width=950, scrolling=True): Example ------- - >>> gitlab_snippet("https://gitlab.com/snippets/1990429/", height = 400) + >>> gitlab_snippet("https://gitlab.com/snippets/1995463", height = 400) """ snippetnumber = _clean_link(link).split("/")[-1] @@ -134,7 +134,7 @@ def codepen_snippet( Example ------- - >>> pastebin_snippet("https://pastebin.com/AWYbziQF", width = 600, scrolling = False) + >>> codepen_snippet("https://codepen.io/ste-vg/pen/GRooLza", width = 600, scrolling = False) """ user, _, slughash = _clean_link(link).split("/")[-3:] @@ -200,7 +200,7 @@ def tagmycode_snippet(link, height=600, width=950, scrolling=True): Example ------- - >>> tagmycode_snippet("https://tagmycode.com/snippet/14040/css-structure#.XvYhunVKglU") + >>> tagmycode_snippet("https://tagmycode.com/snippet/5965/recursive-list-files-in-a-dir#.Xwyc43VKglU") """ snippetnumber = _clean_link(link).split("/")[-2]