Skip to content

Commit 3eb29f1

Browse files
authored
no-undefined-references: add GFM table support
Closes GH-325. Closes GH-326.
1 parent aa9bced commit 3eb29f1

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

packages/remark-lint-no-undefined-references/index.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
* [*Uranus*][] is the seventh planet from the Sun.
107107
*
108108
* [Neptune][neptune][more] is the eighth and farthest planet from the Sun.
109+
*
109110
* @example
110111
* {"label": "output", "name": "not-ok.md"}
111112
*
@@ -148,6 +149,21 @@
148149
* 1:8-1:18: Unexpected reference to undefined definition, expected corresponding definition (`mercury`) for a footnote or escaped opening bracket (`\[`) for regular text
149150
*
150151
* @example
152+
* {"gfm": true, "label": "input", "name": "gfm-table.md"}
153+
*
154+
* | [Planet] | [Radius] |
155+
* | ----------------- | --------- |
156+
* | [Mercury] | 2439.7 km |
157+
*
158+
* [planet]: https://example.com/planet/
159+
*
160+
* @example
161+
* {"gfm": true, "label": "output", "name": "gfm-table.md"}
162+
*
163+
* 1:23-1:31: Unexpected reference to undefined definition, expected corresponding definition (`radius`) for a link or escaped opening bracket (`\[`) for regular text
164+
* 3:3-3:12: Unexpected reference to undefined definition, expected corresponding definition (`mercury`) for a link or escaped opening bracket (`\[`) for regular text
165+
*
166+
* @example
151167
* {"config": {"allowShortcutLink": true}, "label": "input", "name": "allow-shortcut-link.md"}
152168
*
153169
* [Mercury] is the first planet from the Sun and the smallest in the Solar
@@ -244,7 +260,11 @@ const remarkLintNoUndefinedReferences = lintRule(
244260
footnoteDefinitionIdentifiers.add(normalizeIdentifier(node.identifier))
245261
}
246262

247-
if (node.type === 'heading' || node.type === 'paragraph') {
263+
if (
264+
node.type === 'heading' ||
265+
node.type === 'paragraph' ||
266+
node.type === 'tableCell'
267+
) {
248268
phrasingStacks.push([...parents, node])
249269
}
250270
})

packages/remark-lint-no-undefined-references/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"author": "Titus Wormer <[email protected]> (https://wooorm.com)",
33
"bugs": "https://github.com/remarkjs/remark-lint/issues",
44
"contributors": [
5+
"Aaron Moat <[email protected]>",
56
"Merlijn Vos <[email protected]>",
67
"Murderlon <[email protected]>",
78
"Titus Wormer <[email protected]>"

packages/remark-lint-no-undefined-references/readme.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,28 @@ Solar System.
289289
1:8-1:18: Unexpected reference to undefined definition, expected corresponding definition (`mercury`) for a footnote or escaped opening bracket (`\[`) for regular text
290290
```
291291

292+
##### `gfm-table.md`
293+
294+
###### In
295+
296+
> 👉 **Note**: this example uses
297+
> GFM ([`remark-gfm`][github-remark-gfm]).
298+
299+
```markdown
300+
| [Planet] | [Radius] |
301+
| ----------------- | --------- |
302+
| [Mercury] | 2439.7 km |
303+
304+
[planet]: https://example.com/planet/
305+
```
306+
307+
###### Out
308+
309+
```text
310+
1:23-1:31: Unexpected reference to undefined definition, expected corresponding definition (`radius`) for a link or escaped opening bracket (`\[`) for regular text
311+
3:3-3:12: Unexpected reference to undefined definition, expected corresponding definition (`mercury`) for a link or escaped opening bracket (`\[`) for regular text
312+
```
313+
292314
##### `allow-shortcut-link.md`
293315

294316
When configured with `{ allowShortcutLink: true }`.

0 commit comments

Comments
 (0)