A library for extracting and validating links.

The majority of this code has been extracted from the mdbook-linkcheck plugin, so it may have some bias towards the way mdbook works.

If you were validating links in batches, this is one way to go about it:

use linkcheck ::{ Link , BasicContext }; use std :: path :: Path ; use codespan :: Files ; let mut files = Files :: new (); let src = r#" This is some markdown linking to [a website](https://example.com) and [a file](./README.md). "# ; let file_id = files . add ( "blah.md" , src ); let links = linkcheck :: scanners :: markdown ( src ); let links = links . map ( | ( url , span ) | Link :: new ( url , span , file_id )); let current_dir = Path :: new ( env ! ( "CARGO_MANIFEST_DIR" )); let ctx = BasicContext :: default (); let result = linkcheck :: validate ( current_dir , links , & ctx ). await ; assert ! ( result . invalid . is_empty ()); assert_eq ! ( result . valid . len (), 2 );

Extra functionality is accessible by enabling feature flags. The features currently available are: