[−][src]Crate broken_md_links
A library and command-line tool for detecting broken links in Markdown files.
By default, this tool detects broken links like "foo" (target file does not exist) and broken header links like "foo" (target file exists but specific header does not exist)
Command-line usage
Check a single file:
broken-md-links input.md
Check a whole directory:
broken-md-links dir/ -r
Output
There are several levels of verbosity:
-v silent
: display nothing (exit code will be 0 if there was no broken link)-v errors
: display errors only-v warn
: display errors and warnings (the default)-v info
: display the list of analyzed files as well-v verbose
: display detailed informations-v trace
: display debug informations
Additionally, the --no-error
flag converst all broken/invalid link errors to warnings.
Library usage
use broken_md_links::check_broken_links; fn main() { match check_broken_links(Path::new("file.md"), false, false, false, &mut HashMap::new()) { Ok(0) => println!("No broken link :D"), Ok(errors @ _) => println!("There are {} broken links :(", errors), Err(err) => println!("Something went wrong :( : {}", err) } }
Functions
check_broken_links | Check broken links in a Markdown file or directory |
generate_slugs | Get all headers of a Markdown file as slugs This function is used to check if the header specified in a link exists in the target file Returns an error message if the operation failed for any reason |
safe_canonicalize | Canonicalize a path and display it as a lossy string |
slugify | Slugify a Markdown header This function is used to generate slugs from all headers of a Markdown file (see the 'generate_slugs' function) |