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

an issue about sublists rendering #367

Open
reool opened this issue Mar 30, 2017 · 10 comments
Open

an issue about sublists rendering #367

reool opened this issue Mar 30, 2017 · 10 comments
Assignees
Labels

Comments

@reool
Copy link

reool commented Mar 30, 2017

The version I use is 1.6.4, I set disableForced4SpacesIndentedSublists to true, and I use '2 spaces' as indentation of sublists, the markdown code is

- zzzz
  - xxxx
    - cccc

but the HTML i got is:

<ul>
  <li>zzzz
    <ul>
      <li>xxxx</li>
      <li>cccc</li>
    </ul>
  </li>
</ul>

In the html above, xxxx and cccc are sibling nodes.

So is it a bug or just a misuse ?

@simov
Copy link
Contributor

simov commented Mar 30, 2017

It's a bug:

- 1
  - 2
    - 3
      - 4
        - 5
          - 6
            - 7
              - 8
                - 9

marked compiler:

<ul>
    <li>1
        <ul>
            <li>2
                <ul>
                    <li>3
                        <ul>
                            <li>4
                                <ul>
                                    <li>5
                                        <ul>
                                            <li>6
                                                <ul>
                                                    <li>7
                                                        <ul>
                                                            <li>8
                                                                <ul>
                                                                    <li>8</li>
                                                                </ul>
                                                            </li>
                                                        </ul>
                                                    </li>
                                                </ul>
                                            </li>
                                        </ul>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                    </li>
                </ul>
            </li>
        </ul>
    </li>
</ul>

showdown compiler:

<ul>
    <li>1
        <ul>
            <li>2</li>
            <li>3
                <ul>
                    <li>4</li>
                    <li>5
                        <ul>
                            <li>6</li>
                            <li>7
                                <ul>
                                    <li>8</li>
                                    <li>9</li>
                                </ul>
                            </li>
                        </ul>
                    </li>
                </ul>
            </li>
        </ul>
    </li>
</ul>

@tivie
Copy link
Member

tivie commented Mar 30, 2017

Well, the original spec states that, in lists, sub-blocks must be indented 4 spaces (a sub-list is a sub-block). But that was miss implemented in showdown's original version. The rule we used was that sub-lists required 3 spaces indentation.

We fixed the bug but created the option disableForced4SpacesIndentedSublists for backward compatibility for people upgrading versions. The option is not meant to be used in "production" and we can't really fix it as it would defeat the purpose of backwards compatibility.

Check the demo:

@tivie tivie added the Wont Fix label Mar 30, 2017
@simov
Copy link
Contributor

simov commented Mar 31, 2017

@tivie I think lots of people are using just 2 spaces for nested lists on GitHub readmes for example.
I'm fine with using disableForced4SpacesIndentedSublists because this is exactly what I want and this is the behavior that works in every website or implementation that I can think of.

But the problem with this option is that it's not consistent:

- ul
  - ul - using 2 spaces indents properly
     - ul - should use 3 or 4 spaces to indent properly
         - ul - should use 4 spaces to indent properly
             - ul - again 4 spaces, and so on

Example

@reool
Copy link
Author

reool commented Mar 31, 2017

I think there can be just another option, like enable2SpacesIndentedSublists.

@tivie
Copy link
Member

tivie commented Mar 31, 2017

I will have a look and think in a way of making this work with 2 spaces and not break past behavior.

@tivie tivie added bug and removed Wont Fix labels Mar 31, 2017
@tivie
Copy link
Member

tivie commented Mar 31, 2017

Meanwhile, check the comparison of implementations

@tivie tivie added the Pending label Aug 5, 2017
@noe132
Copy link

noe132 commented Nov 20, 2017

2 space indentation is quite useful for many people like me
I'm coding with 2 space indentation and I also want markdown to be 2 space too

@tivie
Copy link
Member

tivie commented Nov 20, 2017

This issue is quite complex because how other sub blocks behave. For instance, it becomes quite problematic with sublists which have a code sub-block:

input

 - this is indented 1 space
    - this is indented 4 spaces

          code needs 10 spaces indentation. Why? 

     - this is indented 5 spaces

           code needs 11 spaces indentation. Why?
     
      - this is indented 6 spaces

            code needs 12 spaces indentation

       - this is indented 7 spaces (why is it level 2)

             code needs 13 spaces indentation

        - this is indented 8 spaces (why is it still level 2)

              code needs 14 spaces indentation

         - this is indented 9 spaces (why is it still level 2)

               code needs 15 spaces indentation

result

  • this is indented 1 space

    • this is indented 4 spaces

      code needs 10 spaces indentation. Why? 
      
    • this is indented 5 spaces

      code needs 11 spaces indentation. Why?
      
    • this is indented 6 spaces

      code needs 12 spaces indentation
      
    - this is indented 7 spaces (why is it level 2)
    
          code needs 13 spaces indentation
    
     - this is indented 8 spaces (why is it still level 2)
    
           code needs 14 spaces indentation
    
      - this is indented 9 spaces (why is it still level 2)
    
            code needs 15 spaces indentation
    

As you see, even github gets this wrong. Showdown, on the other hand, always behaves consistently (when disableForced4SpacesIndentedSublists is off). (see the demo)

That being said, I have a partial fix, but still haven't had the time to properly address all the issues regarding this.

@tannerlinsley
Copy link

I would say 2 spaces is becoming the norm, despite was is supported or not. In the wild, there are a lot of projects (if not most, that I see) using 2 space indentation in their editors and markdown files. Another driving need for this is the wide adoption of Prettier in the community. It formatts markdown files too, often normalizing indentation from 3/4 to 2.

I would call this a need. Is there anything I can do to help? I would love to flip that disableForced4SpacesIndentedSublists switch and have all be well in the world :)

arielcamus added a commit to arielcamus/markdown-embedder that referenced this issue Jul 17, 2018
I founder this bug that prevents lists nested using double spaces from rendering properly. It seems like it's an easy fix:
showdownjs/showdown#367
@fabiospampinato
Copy link

This is broken for us too, the following:

- foo
  - bar
    - baz
      - qux

gets rendered as:

screen shot 2019-01-30 at 02 32 08

@tivie I'd like to submit a PR for this, would it be considered? If so, can you point me at the right section of the code? I'm not very familiar with the codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants