Make it easier to render newlines in markdown
See original GitHub issueThis isn’t a bug, but rather a potential source of confusion. (I was confused, at least.)
In markdown, if you want a newline in your text, simply putting a newline character in is not enough. You have to put two whitespace characters at the end of the previous line.
import streamlit as st
st.write("Not multi-\nline")
st.write("Still not multi- \nline")
st.write("Ok now it's multi- \nline")
Apparently this is part of the spec, so maybe we shouldn’t do anything here. But it seemed confusing enough to be worth noting.
Community voting on feature requests enables the Streamlit team to understand which features are most important to our users.
If you’d like the Streamlit team to prioritize this feature request, please use the 👍 (thumbs up emoji) reaction in response to the initial post.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:25
- Comments:5
Top Results From Across the Web
How to add new line in Markdown presentation?
When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then...
Read more >Line break in Markdown - Szymon Krajewski
There are a few different methods to enforce a line break in the same paragraph in Markdown syntax: HTML's <br /> , backslash...
Read more >Should the markdown renderer treat a single line break as <br>?
The idea of markdown is that you have text that is easy to use in plain and that can be converted. Plain text...
Read more >How to add a blank line or line break to markdown content?
This tutorial covers adding a line break to markdown content in GitHub and bitbucket with examples.. The line break is a new blank...
Read more >Markdown newline behaviour - GitLab
We propose to change this behaviour to conform to the markdown specification and only render line-breaks when you end a line with two...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
+1 for this issue. st.write() not handling text like a python print statement is, at best, confusing.
At worst it severely impacts streamlit interoperability with pre-existing python codebases. Any string you might want to print that works fine in normal python workflows may not render correctly in st.write().
print
print("line 1\n line 2\n line 3")
print("line 1 \n line 2 \n line 3")
st.write
st.write("line 1\n line 2\n line 3")
st.write("line 1 \n line 2 \n line 3")
(for clarity: need a double-whitespace before
\n
to get a newline in st.write for streamlit1.1.0
)Related: #5170 mentions that multiple “\n” don’t produce multiple newlines. Slighlty different but it’s also related to markdown parsing of new lines, so keeping this in here.