" ‘\n’ " in js outputs ‘\n’. Does anyone know why that is not the case in observable or how I would replicate a similar output?
I imagine you mean inside a
md literal string. You might try to add a backslash before:
Can you elaborate a bit, or maybe link to your notebook? I don’t quite understand what behavior you are looking for.
Thanks @severo , this helps!
@jrus, I am going through Eloquent JS currently and chapter 1 uses “”\n"" as an example to show how 2 backslashes collapse each other.
However when simply inputting “”\n"" in an observable cell returns
"\\n" compared to “”\n"" in a js console.
As Severo mentioned, the solution is to use md. I still wonder why there is a difference though.
The output is just the exact string
If you put
html`\\n` as the source for a cell, you’ll get just the text
\n in the cell output, as the content of the html element for the cell.
You can think of this as like the difference between: