russross / blackfriday

Blackfriday: a markdown processor for Go
Other
5.47k stars 602 forks source link

List block cannot have a second line #244

Open Drizin opened 8 years ago

Drizin commented 8 years ago

Given the following block:

1. Main bullet  

    Second line

Blackfriday is rendering this:

<ol>
   <li>
       <p>mainbullet</p>
   </li>
</ol>
<p>second line</p>

While I guess it shound render this:

<ol>
   <li>
      <p>mainbullet</p>
      <p>second line</p>
  </li>
</ol>

Makes sense?

dmitshur commented 8 years ago

I tried it in https://dmitri.shuralyov.com/projects/live-markdown/live-markdown.html and could not reproduce. It rendered the way you expected.

image

What configuration of blackfriday are you using? It seems to be a configuration issue.

Also, what version of blackfriday are you using? It probably makes a difference.

Drizin commented 8 years ago

shurcooL, thanks. Your live-preview website helped me track down the problem. The second paragraph needs to have 4 spaces to be correctly nested under the bullet I was expecting that 3 spaces would be enough (since the bullet has a 3-chars padding: 1 digit + 1 dot + 1 space).

I'm not sure if my expectation was wrong, but what led me to the error was that in Journey Blog Engine there is a live preview (while I'm editing posts) which uses javascript showdown and where only a single space padding is enough for nesting the paragraph. However, during runtime journey uses blackfriday, and the nested paragraphs were breaking the ordered list.

If 4 spaces is the correct minimum padding then please close this issue.

Thanks for the help.

rtfb commented 8 years ago

Markdown spec is explicit about the four spaces:

List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab

FWIW, we have a PR (#37) hanging there since 2013 that proposes one-space indent for lists. Needless to say, I'm reluctant to merging it and it should probably be closed already.

Drizin commented 8 years ago

I was not aware that there are multiple standards, but just for reference:

Maybe a flag for CommonMark compatibility would make sense? Just a suggestion.

rtfb commented 8 years ago

CommonMark is definitely in the plans, but it will take quite some time to put together.

dmitshur commented 8 years ago

I was expecting that 3 spaces would be enough (since the bullet has a 3-chars padding: 1 digit + 1 dot + 1 space).

Unfortunately, this is a common pitfall. Some Markdown packages require 4 spaces, some allow less. Blackfriday currently requires 4 spaces, or a single tab. A single tab is my personal preferred style for indentation.

If 4 spaces is the correct minimum padding then please close this issue.

I think it is "correct" for the current scope and goals of Blackfriday today. This may change in the future, but that's my current best estimate. Of course, not having a single definitive spec that we agree on makes the definition of correctness a fuzzy topic. CommonMark is a spec, but I'm not sure we all agree on it. I don't like it because it's too complicated. I'm not opposed to it, but I won't be able to contribute a lot of feature development to make it a reality.

rugk commented 8 years ago

I also have this issue. Moved from https://github.com/gogits/gogs/issues/3494


Description

Basically text for one list item element (for on bullet) can be indented with two spaces. Gogs however ignores that and shows too spaces even if these are e.g. in code blocks.

Example file

1. Okay.
  So let's start. (2 spaces)

2. Example
    So go on. (4 spaces)
3. Example
4. Hi, step 4 is this (remove X below; I just needed it for escaping, so the code is displayed correctly):

  `X``sh
  echo yes > ChrootEveryone
  echo 25 > MaxClientsNumber
  echo 5 > MaxClientsPerIP
  `X``

  Adjust everything like you want.

  > Also quotes

  You can also just don't do it.

Rendered on GitHub

  1. Okay. So let's start. (2 spaces)
  2. Example So go on. (4 spaces)
  3. Example
  4. Hi, step 4 is this (remove X below; I just needed it for escaping, so the code is displayed correctly):

    echo yes > ChrootEveryone
    echo 25 > MaxClientsNumber
    echo 5 > MaxClientsPerIP

    Adjust everything like you want.

    Also quotes

    You can also just don't do it.

Live example

https://try.gogs.io/rugk/markdown-indentation-parse-test/src/master/test.md

rtfb commented 7 years ago

Closing this because it works by the spec.

rugk commented 7 years ago

There is no official markdown spec. This is just how it is always done, so…

rtfb commented 7 years ago

I treat the original Markdown spec by John Gruber as official. When we support CommonMark (I already have some progress on it), we will have another, better-defined spec, but for now I find having an under-defined spec better than not having any at all.

rugk commented 7 years ago

So what? If you support CommonMark the thing this issue is about is defined here.

And if you follow the "original spec", you can find the same thing here. (at "hanging indents") or later:

Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab:

So in both specs you link too this is supported and your library does not follow any of these specs.

rtfb commented 7 years ago

@rugk, which of the four examples that you presented here do you think we ought to support? I have closed this due to what turned out to be a solved issue of OP. If you think the OP issue is not addressed, please be more specific. If you think some other of your provided examples should be supported, let's figure out if they belong to the same issue and address accordingly.

rugk commented 7 years ago

Uhh, just reread this old issue. I would be fine with a flexible approach just allowing 2, 3 or 4 spaces (or tabs) or so. That's what GitHub does, as I showed in the example above. Just be flexible.