retextjs / retext-sentence-spacing

plugin to check spacing between sentences
https://unifiedjs.com
MIT License
10 stars 1 forks source link

False positives with Markdown tables #9

Closed Zamiell closed 2 years ago

Zamiell commented 2 years ago

Initial checklist

Affected packages and versions

5.2.0

Steps to reproduce

I forgot my markdown files with Prettier, and then use remark afterwards to validate certain things.

However, this rule does not seem to work properly with markdown tables. For example, it generates false positives for the following text:

| Priority | Category of card                                        | Reason                                                                |
| -------- | ------------------------------------------------------- | --------------------------------------------------------------------- |
| 1        | Blind-plays                                             | Demonstrating that a _Finesse_ or _Bluff_ occurred is very important. |
| 2        | Cards that lead into clued cards in someone else's hand | Otherwise, the team would lose _Tempo_.                               |
| 3        | Cards that lead into the player's own hand              | It is bad for a suit to be "held up" on one player.                   |
| 4        | 5's                                                     | Playing a 5 gets the team a free clue.                                |
| 5        | The lower rank card                                     | The smaller stacks are more important to fill up.                     |
| 6        | The left-most card                                      | The left-most card is more likely to be good.                         |

Runtime

Node v16

Package manager

yarn 1

OS

Windows

Build and bundle tools

No response

wooorm commented 2 years ago

Can you paste a small repro of which versions and which tools

Zamiell commented 2 years ago

Sure, I tried to create a reprex here, but I get a weird error:

$ npx remark --quiet --frail test.md
test.md
  1:1  error  Error: mdast-util-to-nlcst expected parser

Any idea what that means?

wooorm commented 2 years ago

You are not configuring plugins correctly. See the docs in the remark-retext readme:

This given processor must have a parser attached (this can be done by using the plugin retext-english or similar) and should use other retext plugins — https://github.com/remarkjs/remark-retext#destination

Zamiell commented 2 years ago

Ok, I fixed the reprex. See the instructions here.

dmundra commented 2 years ago

Ya we are getting the same error. You can see it here in a merge request that displays retext issues using remark lint: https://github.com/CivicActions/handbook/pull/907/files#diff-6c8d09c8d8c36b9ed6e328e38baa799da19cb956b269cf68fbbb404d999d207f

The error specifically is:

Expected `1` space between sentences, not `23`   space  retext-sentence-spacing
wooorm commented 2 years ago

Markdown does not have tables. Tables are a part of GFM. Like with any extension to markdown, you need to enable it. These reproductions don’t. To enable GFM, use remark-gfm.

The current output, without remark-gfm, makes sense. You do have 23 spaces between one sentence and another.

dmundra commented 2 years ago

Yup that does resolve the error. I updated the bug example to confirm it here https://github.com/dmundra/retext-bug.

wooorm commented 2 years ago

Sorry it took me a while to report this simple solution. I thought it was going to be a hairy bug so I tabled it until I had a bunch of free time!