#broken-links #markdown #command-line-tool #file #target-file #header #detect

bin+lib broken-md-links

A command-line tool and library to detect broken links in Markdown files

8 stable releases

2.1.1 Oct 5, 2024
2.1.0 Sep 21, 2023
1.2.1 Jun 17, 2022
1.2.0 Mar 17, 2021
0.1.0 Jul 30, 2020

#285 in Text processing

Download history 13/week @ 2024-06-30 1/week @ 2024-07-28 1/week @ 2024-09-22 116/week @ 2024-09-29 53/week @ 2024-10-06 11/week @ 2024-10-13

181 downloads per month

Apache-2.0

24KB
401 lines

Broken Markdown Links

This repository is an utility written in Rust that ensures all links in a Markdown file are valid, by ensuring the target files exist. It also ensures that for links pointing to a specific header (like [link name](file.md#some-header)) the said header exists in the target file.

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

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)
  }
}

License

This project is released under the Apache-2.0 license terms.

Dependencies

~4–16MB
~158K SLoC