-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
feature:markdownRelated to Markdown renderingRelated to Markdown renderingfeature:st.codeRelated to the `st.code` elementRelated to the `st.code` elementpriority:P3Medium priorityMedium prioritystatus:confirmedBug has been confirmed by the Streamlit teamBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expectedSomething isn't working as expected
Description
Checklist
- I have searched the existing issues for similar issues.
- I added a very descriptive title to this issue.
- I have provided sufficient information below to help reproduce this issue.
Summary
Rendering a code block using st.code() or st.markdown() where the block's first line has leading spaces results in these leading spaces (of the first line only) trimmed.
Reproducible Code Example
import streamlit as st
block = """
line 1
line 2
line 3
"""
st.code(block)
st.markdown(f"```\n{block}\n```")Steps To Reproduce
- Paste the above example into a python file (like
example.py) - Run it with Streamlit (e.g.
streamlit run example.py) - Point your browser to the URL listed.
Expected Behavior
The code block should render as
line 1
line 2
line 3
Current Behavior
Block is rendered as
line 1
line 2
line 3
Is this a regression?
- Not sure.
Debug info
- Streamlit version: 1.20.0
- Python version: 3.10.10
- Operating System: Ubuntu 22.04
- Browser: Firefox 110.0.1
- Virtual environment: poetry 1.3-built
emil-rb, foldl, github-actions, ya55en and MHoffmannAC
Metadata
Metadata
Assignees
Labels
feature:markdownRelated to Markdown renderingRelated to Markdown renderingfeature:st.codeRelated to the `st.code` elementRelated to the `st.code` elementpriority:P3Medium priorityMedium prioritystatus:confirmedBug has been confirmed by the Streamlit teamBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expectedSomething isn't working as expected