88** [ remark] [ github-remark ] ** plugin to check that markdown links and images
99point to existing local files and headings in a Git repo.
1010
11- For example, this document does not have a heading named ` Hello ` .
12- So if we’d link to it (` [welcome](#hello) ` ), we’d get a warning.
11+ For example,
12+ this document does not have a heading named ` Hello ` .
13+ So if we’d link to it (` [welcome](#hello) ` ),
14+ we’d get a warning.
1315Links to headings in other markdown documents (` examples/foo.md#hello ` ) and
1416links to files (` license ` or ` index.js ` ) are also checked.
1517
@@ -45,21 +47,24 @@ plugin to check local links in a Git repo.
4547
4648## When should I use this?
4749
48- This project is useful if you have a Git repo, such as this one, with docs in
49- markdown and links to headings and other files, and want to check whether
50- they’re correct.
51- Compared to other links checkers, this project can work offline (making it fast
52- en prone to fewer false positives), and is specifically made for local links in
53- Git repos.
54- This plugin does not check external URLs (see
55- [ ` remark-lint-no-dead-urls ` ] [ github-remark-lint-no-dead-urls ] ) or undefined
56- references (see
50+ This project is useful if you have a Git repo,
51+ such as this one,
52+ with docs in markdown and links to headings and other files,
53+ and want to check whether they’re correct.
54+ Compared to other links checkers,
55+ this project can work offline
56+ (making it fast en prone to fewer false positives),
57+ and is specifically made for local links in Git repos.
58+ This plugin does not check external URLs
59+ (see [ ` remark-lint-no-dead-urls ` ] [ github-remark-lint-no-dead-urls ] )
60+ or undefined references (see
5761[ ` remark-lint-no-undefined-references ` ] [ github-remark-lint-undefined ] ).
5862
5963## Install
6064
6165This package is [ ESM only] [ github-gist-esm ] .
62- In Node.js (version 16+), install with [ npm] [ npmjs-install ] :
66+ In Node.js (version 16+),
67+ install with [ npm] [ npmjs-install ] :
6368
6469``` sh
6570npm install remark-validate-links
@@ -130,9 +135,10 @@ example.md
130135⚠ 3 warnings
131136```
132137
133- > 👉 ** Note** : ` readme.md#no-such-heading ` is not warned about on the API, as it
134- > does not check headings in other markdown files.
135- > The remark CLI is able to do that.
138+ > 👉 ** Note** :
139+ > ` readme.md#no-such-heading ` is not warned about on the API,
140+ > as it does not check headings in other markdown files;
141+ > the remark CLI is able to do that.
136142
137143## API
138144
@@ -144,10 +150,11 @@ The default export is [`remarkValidateLinks`][api-remark-validate-links].
144150Check that markdown links and images point to existing local files and headings
145151in a Git repo.
146152
147- > ⚠️ ** Important** : The API in Node.js checks links to headings and files but
148- > does not check whether headings in other files exist.
149- > The API in browsers only checks links to headings in the same file.
150- > The CLI can check everything.
153+ > ⚠️ ** Important** :
154+ > the API in Node.js checks links to headings and files but does not check
155+ > whether headings in other files exist;
156+ > the API in browsers only checks links to headings in the same file;
157+ > the CLI can check everything.
151158
152159###### Parameters
153160
@@ -164,40 +171,55 @@ Configuration (TypeScript type).
164171
165172###### Fields
166173
167- * ` repository ` (` string ` or ` false ` , default: detected from Git remote)
174+ * ` repository `
175+ (` string ` or ` false ` , default: detected from Git remote)
168176 — URL to hosted Git;
169- if you’re not in a Git repository, you must pass ` false ` ;
177+ if you’re not in a Git repository,
178+ you must pass ` false ` ;
170179 if the repository resolves to something npm understands as a Git host such
171- as GitHub, GitLab, or Bitbucket, full URLs to that host (say,
172- ` https://github.com/remarkjs/remark-validate-links/readme.md#install ` ) are
173- checked
174- * ` root ` (` string ` , default: local Git folder)
180+ as GitHub, GitLab, or Bitbucket,
181+ then full URLs to that host
182+ (say,
183+ ` https://github.com/remarkjs/remark-validate-links/readme.md#install ` )
184+ are checked
185+ * ` root `
186+ (` string ` , default: local Git folder)
175187 — path to Git root folder;
176- if both ` root ` and ` repository ` are nullish, the Git root is detected;
177- if ` root ` is not given but ` repository ` is, ` file.cwd ` is used
178- * ` urlConfig ` ([ ` UrlConfig ` ] [ api-url-config ] , default: detected from repo)
188+ if both ` root ` and ` repository ` are nullish,
189+ the Git root is detected;
190+ if ` root ` is not given but ` repository ` is,
191+ ` file.cwd ` is used
192+ * ` urlConfig `
193+ ([ ` UrlConfig ` ] [ api-url-config ] , default: detected from repo)
179194 — config on how hosted Git works;
180- ` github.com ` , ` gitlab.com ` , or ` bitbucket.org ` work automatically;
181- otherwise, pass ` urlConfig ` manually
195+ ` github.com ` , ` gitlab.com ` , or ` bitbucket.org `
196+ work automatically;
197+ otherwise,
198+ pass ` urlConfig ` manually
182199
183200### ` UrlConfig `
184201
185202Hosted Git info (TypeScript type).
186203
187204###### Fields
188205
189- * ` headingPrefix ` (` string ` , optional, example: ` '#' ` , ` '#markdown-header-' ` )
206+ * ` headingPrefix `
207+ (` string ` , optional, example: ` '#' ` , ` '#markdown-header-' ` )
190208 — prefix of headings
191- * ` hostname ` (` string ` , optional, example: ` 'github.com' ` ,
209+ * ` hostname `
210+ (` string ` , optional, example: ` 'github.com' ` ,
192211 ` 'bitbucket.org' ` )
193212 — domain of URLs
194- * ` lines ` (` boolean ` , default: ` false ` )
213+ * ` lines `
214+ (` boolean ` , default: ` false ` )
195215 — whether lines in files can be linked
196- * ` path ` (` string ` , optional, example:
216+ * ` path `
217+ (` string ` , optional, example:
197218 ` '/remarkjs/remark-validate-links/blob/' ` ,
198219 ` '/remarkjs/remark-validate-links/src/' ` )
199220 — path prefix before files
200- * ` topAnchor ` (` string ` , optional, example: ` #readme ` )
221+ * ` topAnchor `
222+ (` string ` , optional, example: ` #readme ` )
201223 — hash to top of readme
202224
203225###### Notes
@@ -207,27 +229,28 @@ looks as follows:
207229
208230``` js
209231{
232+ // Prefix of headings:
233+ headingPrefix: ' #' ,
210234 // Domain of URLs:
211235 hostname: ' github.com' ,
236+ // Whether lines in files can be linked:
237+ lines: true ,
212238 // Path prefix before files:
213239 prefix: ' /remarkjs/remark-validate-links/blob/' ,
214- // Prefix of headings:
215- headingPrefix: ' #' ,
216240 // Hash to top of markdown documents:
217- topAnchor: ' #readme' ,
218- // Whether lines in files can be linked:
219- lines: true
241+ topAnchor: ' #readme'
220242}
221243```
222244
223- If this project were hosted on Bitbucket, it would be:
245+ If this project were hosted on Bitbucket,
246+ it would be:
224247
225248``` js
226249{
227- hostname: ' bitbucket.org' ,
228- prefix: ' /remarkjs/remark-validate-links/src/' ,
229250 headingPrefix: ' #markdown-header-' ,
230- lines: false
251+ hostname: ' bitbucket.org' ,
252+ lines: false ,
253+ prefix: ' /remarkjs/remark-validate-links/src/'
231254}
232255```
233256
@@ -258,7 +281,8 @@ But this does exist: [license](license).
258281So does this: [readme](readme.md#install).
259282```
260283
261- Now, running ` ./node_modules/.bin/remark --use remark-validate-links . ` yields:
284+ Now,
285+ running ` ./node_modules/.bin/remark --use remark-validate-links . ` yields:
262286
263287<!-- To do: regenerate. -->
264288
@@ -282,7 +306,8 @@ Install both with [npm][npmjs-install]:
282306npm install remark-cli remark-validate-links --save-dev
283307```
284308
285- Then, add a format script and configuration to ` package.json ` :
309+ Then,
310+ add a format script and configuration to ` package.json ` :
286311
287312``` js
288313{
@@ -301,11 +326,11 @@ Then, add a format script and configuration to `package.json`:
301326}
302327```
303328
304- > 💡 ** Tip** : Add other tools such as prettier or ESLint to check and format
305- > other files.
306- >
307- > 💡 ** Tip** : Run ` ./node_modules/.bin/remark --help ` for help with
308- > ` remark-cli ` .
329+ > 💡 ** Tip** :
330+ > add other tools such as prettier or ESLint to check and format other files.
331+
332+ > 💡 ** Tip** :
333+ > run ` ./node_modules/.bin/remark --help ` for help with ` remark-cli ` .
309334
310335Now you check and format markdown in your project with:
311336
@@ -318,14 +343,19 @@ npm run format
318343` remark-validate-links ` can detect anchors on nodes through several properties
319344on nodes:
320345
321- * ` node.data.hProperties.name ` — used by
346+ * ` node.data.hProperties.name `
347+ — used by
322348 [ ` mdast-util-to-hast ` ] [ github-mdast-util-to-hast-notes ]
323- to create a ` name ` attribute, which anchors can link to
324- * ` node.data.hProperties.id ` — used by
349+ to create a ` name ` attribute,
350+ which anchors can link to
351+ * ` node.data.hProperties.id `
352+ — used by
325353 [ ` mdast-util-to-hast ` ] [ github-mdast-util-to-hast-notes ]
326- to create an ` id ` attribute, which anchors can link to
327- * ` node.data.id ` — Used potentially in the future by other tools to signal
328- unique identifiers on nodes
354+ to create an ` id ` attribute,
355+ which anchors can link to
356+ * ` node.data.id `
357+ — used potentially in the future by other tools to signal unique identifiers
358+ on nodes
329359
330360## Types
331361
@@ -338,22 +368,27 @@ It exports the additional types [`Options`][api-options] and
338368Projects maintained by the unified collective are compatible with maintained
339369versions of Node.js.
340370
341- When we cut a new major release, we drop support for unmaintained versions of
342- Node.
371+ When we cut a new major release,
372+ we drop support for unmaintained versions of Node.
343373This means we try to keep the current release line,
344- ` remark-validate-links@^13 ` , compatible with Node.js 16.
374+ ` remark-validate-links@13 ` ,
375+ compatible with Node.js 16.
345376
346- This plugin works with ` unified ` version 6+, ` remark ` version 7+, and
347- ` remark-cli ` version 8+.
377+ This plugin works with ` unified ` version 6+,
378+ ` remark ` version 7+,
379+ and ` remark-cli ` version 8+.
348380
349381## Security
350382
351- ` remark-validate-links ` , in Node, accesses the file system based on user
352- content, and this may be dangerous.
383+ ` remark-validate-links ` ,
384+ in Node,
385+ accesses the file system based on user content,
386+ and this may be dangerous.
353387In Node ` git remote ` and ` git rev-parse ` also runs for processed files.
354388
355- The tree is not modified, so there are no openings for
356- [ cross-site scripting (XSS)] [ wikipedia-xss ] attacks.
389+ The tree is not modified,
390+ so there are no openings for [ cross-site scripting (XSS)] [ wikipedia-xss ]
391+ attacks.
357392
358393## Related
359394
@@ -371,8 +406,9 @@ for ways to get started.
371406See [ ` support.md ` ] [ health-support ] for ways to get help.
372407
373408This project has a [ code of conduct] [ health-coc ] .
374- By interacting with this repository, organization, or community you agree to
375- abide by its terms.
409+ By interacting with this repository,
410+ organization,
411+ or community you agree to abide by its terms.
376412
377413## License
378414
0 commit comments