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

[Bug] Doesn't parse indented code blocks #7

Open
scinos opened this issue Sep 15, 2020 · 1 comment · May be fixed by #8
Open

[Bug] Doesn't parse indented code blocks #7

scinos opened this issue Sep 15, 2020 · 1 comment · May be fixed by #8

Comments

@scinos
Copy link

scinos commented Sep 15, 2020

When the codeblock is indented followed by a codeblock that is not, the parser has a really bad time trying to parse it.

I created a repo with a reproduction case: https://github.com/scinos/eslint-md-parsing-error

Input:

- list

  ```js
  foo()
  ```

---

```js
bar()
```

Lint errors (./node_modules/.bin/eslint .):

   3:3  error  Insert `··`                              prettier/prettier
   4:1  error  Insert `··`                              prettier/prettier
   5:1  error  Insert `··`                              prettier/prettier
   6:1  error  Insert `··`                              prettier/prettier
   7:1  error  Insert `··`                              prettier/prettier
   8:1  error  Insert `··`                              prettier/prettier
   9:1  error  Insert `··`                              prettier/prettier
  10:1  error  Insert `··`                              prettier/prettier
  11:1  error  Insert `··`                              prettier/prettier
   5:3  error  Parsing error: Unexpected character '`'

Output when using autofix (./node_modules/.bin/eslint . --fix):

          -   list

    ```js
    foo()
  ```

---
  
```js
bar()
```

I found two workarounds:

  1. Removing the language tag from the first codeblock
  2. Un-indenting the first codeblock
@scinos
Copy link
Author

scinos commented Sep 15, 2020

Looks like the problem is in the regular expression in https://github.com/leo-buneev/eslint-plugin-md/blob/master/lib/processors/mdProcessor.js#L12, as it doesn't account for indented blocks. In the above example, it thinks there is a single code block from the 3rd line to the end of the file.

scinos added a commit to scinos/eslint-plugin-md that referenced this issue Sep 21, 2020
@scinos scinos linked a pull request Sep 21, 2020 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant