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

Handles multiple paragraphs and code blocks in list incorrectly #8

Open
dominikh opened this issue Apr 8, 2016 · 4 comments
Open

Comments

@dominikh
Copy link

dominikh commented Apr 8, 2016

Consider the following markdown input:

- List item 1
- List item 2

  ```
  some code here
  ```

  more text here

  ```
  more code here
  ```

Your package renders it as

<ul>
<li>List item 1</li>
<li>List item 2</li>
</ul>

<pre><code>  some code here
</code></pre>

<p>more text here</p>

<pre><code>  more code here
</code></pre>

That is, it closes the list too soon. GitHub renders it correctly:

  • List item 1

  • List item 2

    some code here
    

    more text here

    more code here
    
@dmitshur
Copy link
Member

dmitshur commented Apr 8, 2016

This is a known behavior of blackfriday. Unlike GitHub's markdown parser, it requires indent to be of size 4 spaces or 1 tab at minimum. GitHub requires a minimum of 2 spaces. See russross/blackfriday#244 (comment).

You should either write (note indent is 4 spaces):

- List item 1
- List item 2

    ```
    some code here
    ```

    more text here

    ```
    more code here
    ```

Or you can use tabs. This is the recommended style and it's what markdownfmt uses.

@dominikh
Copy link
Author

dominikh commented Apr 8, 2016

May that as it be, your library has github in its name :) – Also, ordinary continuation lines of a list item don't need to be indented deeper than the first line. Why is that not true for additional paragraphs?

@dmitshur
Copy link
Member

dmitshur commented Apr 8, 2016

I agree, this is a bug, because this package's intent is to be compatible with GitHub Flavored Markdown rendering as done via their API:

The functionality should be equivalent to the GitHub Markdown API endpoint specified at https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode, except the rendering is performed locally.

What I shared above is a workaround you can use until this is resolved.

To resolve this issue, russross/blackfriday#244 needs to be resolved.

@jlearman
Copy link

jlearman commented Mar 14, 2022

Possibly related, the indents for nested list items is off. Consider the following:

Markdown
* 1
  * 2
    * 3
      * 4
        * 5
          * 6
            * 7

The above renders as fully nested in Markdown.

The following indentation is needed to get it to render correctly in github_flavored_markdown:

github_flavored_markdown (indents, indents from the line above)
* 1                             0
  * 2                           2   2
     * 3                        5   3
         * 4                    9   4
             * 5                13  4
                 * 6            17  4
                     * 7        21  4

The workaround to use 4 spaces works.

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

No branches or pull requests

3 participants