diff --git a/rules/list-item.js b/rules/list-item.js index d37c654..004001b 100644 --- a/rules/list-item.js +++ b/rules/list-item.js @@ -110,9 +110,10 @@ function validateList(list, file) { // Might have children like {image} {text} {link} - {descrition} // Keep discarding elements until we find a link - if (link.type !== 'link') { + // or linkReference + if (!/link/.test(link.type)) { for (let i = 0; i < description.length - 1; i++) { - if (description[i].type === 'link') { + if (/link/.test(description[i].type)) { link = description[i]; description = description.slice(i + 1); } @@ -128,6 +129,13 @@ function validateList(list, file) { } function validateListItemLink(link, file) { + // NB. need remark-lint-no-undefined-references separately + // to catch if this is a valid reference. here we only care that it exists + if (link.type === 'linkReference') { + // TODO: need to test link children against listItemLinkNodeAllowList? + return true; + } + if (link.type !== 'link') { file.message('Invalid list item link', link); return false; diff --git a/test/fixtures/list-item/0.md b/test/fixtures/list-item/0.md index ea0ab28..0372167 100644 --- a/test/fixtures/list-item/0.md +++ b/test/fixtures/list-item/0.md @@ -136,6 +136,7 @@ These sub-lists use mixed indentation (spaces and tabs). - [why-is-node-running](https://github.com/mafintosh/why-is-node-running) - Node.js is running but you don't know why? +- [gtkada] - Ada graphical toolkit based on Gtk3 components (issue #161 link reference below but checked by `remark-lint-no-undefined-references` not `rules/list-item.js`). - [foo](https://foo.com) ![stars](https://img.shields.io/github/stars/foo/foo.svg) - Valid description. - ![v3](img/vapor-3.png) [API Error Middleware](https://github.com/skelpo/APIErrorMiddleware) - Vapor middleware for converting thrown errors to JSON responses. - ![v2](img/vapor-2.png) ![v3](img/vapor-3.png) [Bugsnag](https://github.com/nodes-vapor/bugsnag) - Report errors with Bugsnag. @@ -145,3 +146,5 @@ These sub-lists use mixed indentation (spaces and tabs). - [__Compiling machine learning programs via high-level tracing__. Roy Frostig, Matthew James Johnson, Chris Leary. _MLSys 2018_.](https://mlsys.org/Conferences/doc/2018/146.pdf) - This white paper describes an early version of JAX, detailing how computation is traced and compiled (issue #136) --> +[gtkada]: https://github.com/AdaCore/gtkada + diff --git a/test/fixtures/list-item/1.md b/test/fixtures/list-item/1.md index fbc00b8..deec760 100644 --- a/test/fixtures/list-item/1.md +++ b/test/fixtures/list-item/1.md @@ -70,3 +70,4 @@ Test description's ending punctuation. - [foo](https://foo.com) - Quote-inducing double punctuation “end…”??! - [foo](https://foo.com) - Quote-inducing double punctuation “end?…...”…...? +- [gtkada] - reference link with no reference diff --git a/test/rules/snapshots/list-item.js.snap b/test/rules/snapshots/list-item.js.snap index 3d2b7ba..887aeae 100644 Binary files a/test/rules/snapshots/list-item.js.snap and b/test/rules/snapshots/list-item.js.snap differ