Skip to content

Commit c5e511e

Browse files
authored
Show line numbers for rendered code (#33)
1 parent 78b0def commit c5e511e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/streamlit_app.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ def render_code(self, fname="", code=""):
5252
if fname.endswith(".md"):
5353
st.markdown(code)
5454
else:
55-
st.code(code)
55+
col1, col2 = st.beta_columns([1, 20])
56+
with col1:
57+
st.code("\n".join(map("{:>3}".format, range(1, code.count("\n") + 1))))
58+
with col2:
59+
st.code(code)
5660

5761
def render_directory(self, dir):
5862
output = check_output(["tree", dir], encoding="utf-8")

0 commit comments

Comments
 (0)