Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List block cannot have a second line #244

Open
Drizin opened this issue Mar 7, 2016 · 13 comments
Open

List block cannot have a second line #244

Drizin opened this issue Mar 7, 2016 · 13 comments

Comments

@Drizin
Copy link

Drizin commented Mar 7, 2016

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
Copy link
Collaborator

dmitshur commented Mar 8, 2016

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
Copy link
Author

Drizin commented Mar 8, 2016

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
Copy link
Collaborator

rtfb commented Mar 8, 2016

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
Copy link
Author

Drizin commented Mar 8, 2016

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.

@rtfb
Copy link
Collaborator

rtfb commented Mar 8, 2016

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

@dmitshur
Copy link
Collaborator

dmitshur commented Mar 9, 2016

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
Copy link

rugk commented Aug 23, 2016

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

@rtfb
Copy link
Collaborator

rtfb commented Oct 8, 2017

Closing this because it works by the spec.

@rtfb rtfb closed this as completed Oct 8, 2017
@rugk
Copy link

rugk commented Oct 8, 2017

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

@rtfb
Copy link
Collaborator

rtfb commented Oct 8, 2017

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
Copy link

rugk commented Oct 8, 2017

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 rtfb reopened this Oct 8, 2017
@rtfb
Copy link
Collaborator

rtfb commented Oct 8, 2017

@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
Copy link

rugk commented Oct 8, 2017

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.

tfogo added a commit to tfogo/website that referenced this issue May 21, 2018
There is an issue with ordered lists in the Creating HA clusters with
kubeadm setup tutorial. All list items are labeled 1. This is because
the underlying markdown processor for Hugo, blackfriday, requires
list items with multiple paragraphs to have four space indentation.
See (russross/blackfriday#244)

This commit adds an extra space before paragraphs in lists so they are
correctly interpreted as multi-paragraph lists.

However, this exposes a bug in blackfriday where lines beginning with
`-` in codefenced code blocks inside lists are parsed as sub-lists.
This means code fenced code blocks inside lists that contain yaml are
malformed. (See russross/blackfriday#239)

So this commit mitigates this bug in two situations. It uses a 4-space
indented code block in one situation. In another situation where a list
only contained one element, it is no longer a list.
tfogo added a commit to tfogo/website that referenced this issue May 21, 2018
There is an issue with ordered lists in the Creating HA clusters with
kubeadm setup tutorial. All list items are labeled 1. This is because
the underlying markdown processor for Hugo, blackfriday, requires
list items with multiple paragraphs to have four space indentation.
See (russross/blackfriday#244)

This commit adds an extra space before paragraphs in lists so they are
correctly interpreted as multi-paragraph lists.

However, this exposes a bug in blackfriday where lines beginning with
`-` in codefenced code blocks inside lists are parsed as sub-lists.
This means code fenced code blocks inside lists that contain yaml are
malformed. (See russross/blackfriday#239)

So this commit mitigates this bug in two situations. It uses a 4-space
indented code block in one situation. In another situation where a list
only contained one element, it is no longer a list.
tfogo added a commit to tfogo/website that referenced this issue May 23, 2018
There is an issue with ordered lists in the Creating HA clusters with
kubeadm setup tutorial. All list items are labeled 1. This is because
the underlying markdown processor for Hugo, blackfriday, requires
list items with multiple paragraphs to have four space indentation.
See (russross/blackfriday#244)

This commit adds an extra space before paragraphs in lists so they are
correctly interpreted as multi-paragraph lists.

However, this exposes a bug in blackfriday where lines beginning with
`-` in codefenced code blocks inside lists are parsed as sub-lists.
This means code fenced code blocks inside lists that contain yaml are
malformed. (See russross/blackfriday#239)

So this commit mitigates this bug in two situations. It uses a 4-space
indented code block in one situation. In another situation where a list
only contained one element, it is no longer a list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants