brok: Finds broken links in text files

[ bsd3, command-line-tools, library, program ] [ Propose Tags ]
Versions [RSS] 0.1.2.0, 0.1.3.0, 0.1.4.0, 0.1.5.0, 0.1.6.0, 0.1.7.0, 0.2.0.0, 1.0.0, 1.1.0
Dependencies ansi-terminal (>=0.8.2 && <0.9), attoparsec (>=0.13.2.2 && <0.14), base (>=4.7 && <5), brok, classy-prelude (>=1.5.0 && <1.6), directory (>=1.3.3.0 && <1.4), file-embed (>=0.0.11 && <0.1), http-client (>=0.5.14 && <0.6), http-conduit (>=2.3.5 && <2.4), text (>=1.2.3.1 && <1.3), time (>=1.8.0.2 && <1.9) [details]
License BSD-3-Clause
Copyright 2019 Small Hadron Collider
Author Small Hadron Collider
Maintainer mark@smallhadroncollider.com
Category Command Line Tools
Home page https://github.com/smallhadroncollider/brok#readme
Bug tracker https://github.com/smallhadroncollider/brok/issues
Source repo head: git clone https://github.com/smallhadroncollider/brok
Uploaded by smallhadroncollider at 2019-02-08T16:44:07Z
Distributions
Executables brok
Downloads 3456 total (22 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2019-02-08 [all 1 reports]

Readme for brok-0.1.5.0

[back to package description]

brök

Find broken links in text documents

Demo

Similar idea to awesome_bot, but with different output options.

Currently only supports http:// and https:// prefixed URLs

Install

Binaries for Mac and Linux are available. Add the binary to a directory in your path (such as /usr/local/bin).

Cabal

If you have cabal installed:

cabal install brok

Make sure you run cabal update if you haven't run it recently.

Building

Requirements: Stack

The following command will build brök and then install it in ~/.local/bin:

stack build && stack install

Usage

Basic Usage

Check all links in a single text file:

brok test.md

Or in multiple files:

brok test.md links.tex

If you're using this as part of a test suite, you probably only need the errors:

brok text.md links.tex > /dev/null

Options

Cache

By default brök will cache successes for a day. It will always recheck errors.

If you want to adjust the cache length, you can enter the number of seconds after which the cache invalidates:

# cache for a week
brok --cache 604800 test.md links.tex

Ignore URLs

You can tell brök to ignore URLs with specified prefixes:

# ignore facebook and amazon URLS
brok --ignore "http://facebook.com" "http://amazon.com" test.md links.tex

Interval

By default brök waits for 100ms between URL checks. You can change the delay:

# wait for 1 second between checks
brok --interval 1000 test.md links.tex

Git Pre-Commit Hook

If you want to check all the links in your Git repo are valid before being able to commit then add something like the following to .git/hooks/pre-commit.

bash

#! /bin/bash

# cache for 1 week
# use find to check all *.md files
# only show errors (if there are any)
brok --cache 604800 $(find . -type f -name "*.md") > /dev/null

zsh

#! /bin/zsh

# cache for 1 week
# using a zsh glob to check all *.md files
# only show errors (if there are any)
brok --cache 604800 */**/*.md > /dev/null