Ghost: Markdown bug: no new line inserted when quotes are used

Created on 7 Oct 2013  Â·  8Comments  Â·  Source: TryGhost/Ghost

See below for a demonstration

linebreak

bug editor

Most helpful comment

Or when in quote mode:
screen shot 2013-10-07 at 17 56 55

All 8 comments

Or when in quote mode:
screen shot 2013-10-07 at 17 56 55

It looks like the problem is generalized to whenever the first line starts with a space or a symbol (except the underscore).

If we have two lines, with only letter characters...

image

...this is what happens when the first character is instead a symbol or a space:

image
image

Only the subsequent line is affected:

image

This is probably one of the few markdown bugs which can be fixed without Haunted Markdown

I'll have a look at this.

The Markdown spec says....
"The implication of the “one or more consecutive lines of text” rule is that Markdown supports “hard-wrapped” text paragraphs. This differs significantly from most other text-to-HTML formatters (including Movable Type’s “Convert Line Breaks” option) which translate every line break character in a paragraph into a <br /> tag.

When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return."

You'll find that if two spaces are put at the end of a line everything behaves as expected.

However, Ghost also uses the Github extensions which "in very clear cases, let newlines become <br /> tags". This clear case is defined by this regex:

/^[\w\<][^\n]*\n+/gm

...so the line has to start with "...any alphanumeric character from the basic Latin alphabet, including the underscore" or <. Hence the exhibited issue.

Interestingly the current Github markdown does not exhibit the problem eg;

"first
second"

...it appears that they use redcarpet for rendering markdown, which deals with this issue.

In conclusion you could argue that there's not _technically_ a bug, the markdown spec is followed, however the behaviour can be changed if we want. The question is, what is the required behaviour? Which characters should be allowed at the start of a line and still create a line break without two spaces?

The code block already works, so only blockquote, I don't see others ?

Yeah, blockquote, you could argue for * too then bold works. Any opinions @ErisDS @JohnONolan ?

* is a list so probably shouldn't be included. I would say just the various quote marks so " and '

Was this page helpful?
0 / 5 - 0 ratings