question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make it easier to render newlines in markdown

See original GitHub issue

This 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:open
  • Created 4 years ago
  • Reactions:25
  • Comments:5

github_iconTop GitHub Comments

16reactions
JMBurleycommented, Nov 10, 2021

+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")

line 1  
line 2  
line 3

print("line 1 \n line 2 \n line 3")

line 1  
line 2  
line 3

st.write

st.write("line 1\n line 2\n line 3")

line 1  line 2  line 3

st.write("line 1 \n line 2 \n line 3")

line 1  
line 2  
line 3

(for clarity: need a double-whitespace before \n to get a newline in st.write for streamlit1.1.0)

0reactions
jriekecommented, Aug 29, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found