Line breaks in Markdown


#1

I am trying to port some documentation from RST to Markdown and can’t figure how to make a line break without creating a new paragraph. As an example see this RST based doc and compare to the markdown version created with Documenter. I know I can introduce a paragraph (and so far it’s my only choice) but shouldn’t it be possible to do line breaks in Julia’s Markdown? I tried inserting two spaces before the line break like I see in web docs, but no effect. In fact, even I try in REPL I can not do it as well

julia> d1 = md"""- *C*
                   blabla"""
    •    C

  blabla

#2

Two spaces before the line break is standard markdown syntax - if that doesn’t work with Documenter it might be worth opening an issue.


#3

This works:

julia> display(md"""adfa\
       sdfads
       """)
  adfa
  sdfads

Note that the two spaces wouldn’t really work in the current Julia setup as trailing white-space is not allowed.


#4

My REPL example was an attempt to show a very simple to reproduce example. When you say wouldn’t really work in the current Julia setup as trailing white-space is not allowed you mean the REPL only or in .md files too?

As I mentined, I was not able to make it work in .md files processed with Documenter.jl but I can see it work in the Julia manual here
so I’m confused.


#5

What I meant is that the test-suite of Julia itself currently fails when there is trailing white-space. Of course this could be changed, but people seem reasonably fond of it.


#6

CommonMark spec says line break from ending with two spaces then a new line.
Propergating new Markdown varients causes sufferring.

Let’s not, not use the CommonMark spec.

A line break (not in a code span or HTML tag) that is preceded by two or more spaces and does not occur at the end of a block is parsed as a hard line break (rendered in HTML as a
tag):

https://spec.commonmark.org/0.28/#hard-line-break


#7

CommonMark (your link) mentions that a slash can be used for hard line breaks:

For a more visible alternative, a backslash before the line ending may be used instead of two spaces

Maybe this \ should be added under the ‘the following markdown syntax is supported in Julia’ chapter in the manual? And mention that .., i.e. 2+ spaces, are not supported (if the reasonable trailing white-space behavior stays as is).


#8

Thanks for the link @kevbonham. Indeed the \ works fine from within the Documenter.jl


#9

I think you meant to thank @swissr? Though I am half Swiss and willing to take credit on my countryman’s behalf :smile:


#10

Sure, thank you both (I actually had seen it too from the link but @swissr post made me tried it right away) .


#11

And to be fair @mauro3 was the first to touch the point.