russross / blackfriday

Blackfriday: a markdown processor for Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

List block cannot have a second line

Drizin opened this issue · comments

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?

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.

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.

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.

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

  • I used to refer to markdowntutorial.com, where a single space is enough
  • CommonMark specs suggest that subsequent paragraphs must start at the same position where the text after the list marker starts. They also discuss how the original spec was not followed by some implementations.

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

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

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.

commented

I also have this issue.
Moved from gogs/gogs#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

Closing this because it works by the spec.

commented

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

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.

commented

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.

@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.

commented

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.