Skip to content

Commit 41a6b66

Browse files
committed
v0.0.2
1 parent 33e56a5 commit 41a6b66

File tree

3 files changed

+90
-5
lines changed

3 files changed

+90
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# streamlit-embedcode
22

3-
streamlit-embedcode is the easiest way to embed code snippets into your Streamlit app! This component supports the following code sharing services:
3+
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:
44

55
- [GitHub gist](https://gist.github.com/)
66
- [GitLab snippets](https://gitlab.com/explore/snippets)

examples/streamlit-embedcode-docs.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,112 @@
4747

4848
github_gist
4949

50+
"---"
51+
"### Example:"
52+
with st.echo():
53+
54+
import streamlit as st
55+
from streamlit_embedcode import github_gist
56+
57+
t = st.text_input(
58+
"Enter GitHub gist URL:",
59+
"https://gist.github.com/randyzwitch/934d502e53f2adcb48eea2423fe4a47e",
60+
)
61+
62+
w = st.slider("width", 300, 800, 710)
63+
github_gist(t, width=w)
64+
5065
elif choice == "gitlab_snippet()":
5166
"""## gitlab_snippet()"""
5267

5368
gitlab_snippet
5469

70+
"---"
71+
"### Example:"
72+
with st.echo():
73+
74+
import streamlit as st
75+
from streamlit_embedcode import gitlab_snippet
76+
77+
t = st.text_input(
78+
"Enter GitLab snippet URL:", "https://gitlab.com/snippets/1995463",
79+
)
80+
81+
w = st.slider("width", 300, 800, 710)
82+
gitlab_snippet(t, width=w)
83+
5584
elif choice == "pastebin_snippet()":
5685
"""## pastebin_snippet()"""
5786

5887
pastebin_snippet
5988

89+
"---"
90+
"### Example:"
91+
with st.echo():
92+
93+
import streamlit as st
94+
from streamlit_embedcode import pastebin_snippet
95+
96+
t = st.text_input(
97+
"Enter Pastebin snippet URL:", "https://pastebin.com/i1YQv94Q",
98+
)
99+
100+
w = st.slider("width", 300, 800, 710)
101+
pastebin_snippet(t, width=w)
102+
60103
elif choice == "codepen_snippet()":
61104
"""## codepen_snippet()"""
62105

63106
codepen_snippet
64107

108+
"---"
109+
"### Example:"
110+
with st.echo():
111+
112+
import streamlit as st
113+
from streamlit_embedcode import codepen_snippet
114+
115+
t = st.text_input(
116+
"Enter CodePen snippet URL:", "https://codepen.io/ste-vg/pen/GRooLza",
117+
)
118+
119+
w = st.slider("width", 300, 800, 750, key="1")
120+
h = st.slider("height", 500, 800, 600, key="2")
121+
codepen_snippet(t, width=w, height=h)
122+
65123
elif choice == "ideone_snippet()":
66124
"""## ideone_snippet()"""
67125

68126
ideone_snippet
69127

128+
"---"
129+
"### Example:"
130+
with st.echo():
131+
132+
import streamlit as st
133+
from streamlit_embedcode import ideone_snippet
134+
135+
t = st.text_input("Enter Ideone snippet URL:", "https://ideone.com/vQ54cr",)
136+
137+
w = st.slider("width", 300, 800, 710, key="1")
138+
ideone_snippet(t, width=w)
139+
70140
elif choice == "tagmycode_snippet()":
71141
"""## tagmycode_snippet()"""
72142

73143
tagmycode_snippet
144+
145+
"---"
146+
"### Example:"
147+
with st.echo():
148+
149+
import streamlit as st
150+
from streamlit_embedcode import tagmycode_snippet
151+
152+
t = st.text_input(
153+
"Enter Ideone snippet URL:",
154+
"https://tagmycode.com/snippet/5965/recursive-list-files-in-a-dir#.Xwyc43VKglU",
155+
)
156+
157+
w = st.slider("width", 300, 800, 710, key="1")
158+
tagmycode_snippet(t, width=w)

streamlit_embedcode/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def github_gist(link, height=600, width=950, scrolling=True):
4343
4444
Example
4545
-------
46-
>>> github_gist("https://gist.github.com/randyzwitch/be8c5e9fb5b8e7b046afebcac12e5087/")
46+
>>> github_gist("https://gist.github.com/randyzwitch/934d502e53f2adcb48eea2423fe4a47e")
4747
"""
4848

4949
gistcreator, gistid = _clean_link(link).split("/")[-2:]
@@ -71,7 +71,7 @@ def gitlab_snippet(link, height=600, width=950, scrolling=True):
7171
7272
Example
7373
-------
74-
>>> gitlab_snippet("https://gitlab.com/snippets/1990429/", height = 400)
74+
>>> gitlab_snippet("https://gitlab.com/snippets/1995463", height = 400)
7575
"""
7676

7777
snippetnumber = _clean_link(link).split("/")[-1]
@@ -134,7 +134,7 @@ def codepen_snippet(
134134
135135
Example
136136
-------
137-
>>> pastebin_snippet("https://pastebin.com/AWYbziQF", width = 600, scrolling = False)
137+
>>> codepen_snippet("https://codepen.io/ste-vg/pen/GRooLza", width = 600, scrolling = False)
138138
"""
139139

140140
user, _, slughash = _clean_link(link).split("/")[-3:]
@@ -200,7 +200,7 @@ def tagmycode_snippet(link, height=600, width=950, scrolling=True):
200200
201201
Example
202202
-------
203-
>>> tagmycode_snippet("https://tagmycode.com/snippet/14040/css-structure#.XvYhunVKglU")
203+
>>> tagmycode_snippet("https://tagmycode.com/snippet/5965/recursive-list-files-in-a-dir#.Xwyc43VKglU")
204204
"""
205205

206206
snippetnumber = _clean_link(link).split("/")[-2]

0 commit comments

Comments
 (0)