From ae91733d08617b6f4babc2c01e129e61e457aaa8 Mon Sep 17 00:00:00 2001 From: WillForan Date: Sun, 31 Dec 2023 11:50:01 -0500 Subject: [PATCH] address #161 with linkReference test; update list-item snapshots --- rules/list-item.js | 12 ++++++++++-- test/fixtures/list-item/0.md | 3 +++ test/fixtures/list-item/1.md | 1 + test/rules/snapshots/list-item.js.snap | Bin 1868 -> 1878 bytes 4 files changed, 14 insertions(+), 2 deletions(-) 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 3d2b7ba37540b497909cfda47a6fc97c71949567..887aeae9dbc4a1ca4f650adeed2adc544b39619b 100644 GIT binary patch literal 1878 zcmV-c2dVf$RzVHo8N@ULBQI{trkJn znEXHQS|5uD00000000Bkn|W*$RRD+Ibhq34z7N{zeQs}Bz)~qz3fMqEjzExP+MUvc z?QYqba)&4a2}ne-5+w}^L5x@-A(TG|9#NulL=q$<5+nhE1ZnsK8#IPgfA966yr*u| z8v9JX^ecYg4?2Bi?aYDJW|yaBmGSaH-E^8R-EcV#)9y6&cGa#r-D@2#|8OjlF2F@2Y60Mm<91DOs`4Pt8dC+t5BT}Cy8=_^!2nVzB=#`G@L zaHfeiXav(ns*z0BP>o{x9@S{3m#M}uwcvxS#4@d*8pl+l8qf4KstHU#rJBg}KGh_q z69S>hOq-~tFx^NsmFW?x6PSKSHH~Rt5Hy`>4ONwCE7c69Z&J-t(;ui-F^vv`PNbht)_Q0oXaT)pL)V~fZu3gL#Z>%8G%_-h<+qXC z0|DWLED7gwi;(X?vKxE|0wTEFD&#dtrh+Bl4Lqs2)PT17rY8?@p+<<$EFgJ464Dd zR4z{v^3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