remarkjs / remark-gfm

remark plugin to support GFM (autolink literals, footnotes, strikethrough, tables, tasklists)
https://remark.js.org
MIT License
713 stars 24 forks source link

Indented lines with 4 or more spaces in list are interpreted as code blocks #1

Closed susisu closed 3 years ago

susisu commented 3 years ago

Subject of the issue

I'm upgrading remark-parse from 8.0.3 to 9.0.0 and using remark-gfm.

I found that the following indented list items example from CommonMark / GFM specs yields a different result from the specs.

- a
 - b
  - c
   - d
    - e

I don't think the package should be 100% spec compliant, and I'm sorry if it's actually working as intended.

Your environment

Steps to reproduce

See https://codesandbox.io/s/charming-dew-m14g7?file=/src/index.js

Expected behavior

As the specs say:

<ul>
<li>a</li>
<li>b</li>
<li>c</li>
<li>d
- e</li>
</ul>

Actual behavior

<ul>
<li>a</li>
<li>b</li>
<li>c</li>
<li>d</li>
</ul>
<pre><code>- e
</code></pre> 

Without remark-gfm, it works as expected.

The next example in the spec shows a result like this, but it's because there is a blank line before 3. c.

wooorm commented 3 years ago

This is a bug! Specifically, in micromark-extension-gfm-table. A similar bug is also in remark-frontmatter through micromark-extension-frontmatter. It is something that isn’t present in normal markdown (commonmark), because there multiline blocks are defined by their first line, but for frontmatter the last line defines it, and for tables the second line (alignment row).

I shared more of my thoughts about this issue here.