This repository has been archived by the owner on May 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gaurav Nelson
committed
Jun 23, 2017
1 parent
6fc44b2
commit 97d2e0b
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# asciidoc-link-check | ||
Checks if all hyperlinks in an asciidoc file are alive(or dead). | ||
|
||
(Uses most of the source code from [markdown-link-check](https://github.com/tcort/markdown-link-check) module) | ||
|
||
## Installation | ||
To add the module to your project, run: | ||
|
||
```bash | ||
npm install --save asciidoc-link-check | ||
``` | ||
|
||
To install the command line tool globally, run: | ||
|
||
```bash | ||
npm install -g asciidoc-link-check | ||
``` | ||
|
||
## API | ||
Use the following function: | ||
|
||
|
||
```javascript | ||
asciidocLinkCheck(asciidoc, callback) | ||
``` | ||
Accepts a string containing `asciidoc` formatted text and a `callback`, extracts all links and checks if they are alive or dead. Then calls the `callback` with `(err, results)`. | ||
|
||
## Examples | ||
### JavaScript | ||
|
||
```javascript | ||
'use strict'; | ||
|
||
var asciidocLinkCheck = require('asciidoc-link-check'); | ||
|
||
asciidocLinkCheck('xref:https://www.google.com[Google]', function (err, results) { | ||
if (err) { | ||
console.error('Error', err); | ||
return; | ||
} | ||
results.forEach(function (result) { | ||
console.log('%s is %s', result.link, result.status); | ||
}); | ||
}); | ||
``` | ||
|
||
### Command Line | ||
#### Check links for a local file | ||
|
||
```bash | ||
asciidoc-link-check README.adoc | ||
``` | ||
|
||
#### Check links for an online file | ||
|
||
```bash | ||
asciidoc-link-check https://github.com/gaurav-nelson/asciidoc-link-check/blob/master/README.adoc | ||
``` | ||
|
||
#### Check links from standard input | ||
|
||
```bash | ||
cat *.adoc | asciidoc-link-check | ||
``` |