Problem with `println()` and `display()`, `display()` can't display line breaks

I have a script that analyses some parameters and prints the result (in a Julia notebook). This includes both text messages and plots. I have problem finding a print format which preserved the order things are printed (like display()), but can print strings sensibly (like println()).

E.g. if I only use display():

display("Text Message 1")
display(plot(x->x,label="Plot 1"))
display("More Message 2")

then strings are displayed weirdly. Even worse, I cannot properly add linebreaks (useful to break up the information, making it less dense to read through).

Instead, I can display text using println(), which is good because the strings are displayed properly (and the linebreaks especially). However, this does not preserve the order with which things are printed, especially with regards to the plot:

println("Text Message 1")
display(plot(x->x,label="Plot 1"))
println("More Message 2")

So, is there some functionality where I can display strings properly, but also be sure in which order the stuff I print appears?

Not sure if it works in Jupyter, but try display(Text("foo\nbar\nbaz")).


I can confirm that it works

display(Text("Text Message 1"))
display(plot(x->x,label="Plot 1"))
display(Text("More Message 2"))


Thanks for the help :slight_smile: