#!/usr/bin/env sh
set -e
# This will attempt to automatically fix most of the Markdown linting issues
# detected.

# We will first transform the file according to remark config. This will mostly
# convert inline links to references at the bottom of the file.
REMARK_MODE=fix \
  remark \
    --quiet \
    ./*.md \
    ./src/*.md \
    --output

# We then check the actual natural language content of the file, to fix
# misspellings, punctuation and other fixable issues.
textlint \
  --fix \
  ./*.md \
  ./src/*.md 

# Finally, we'll run everything through prettier to make sure all files are
# formatted the same way. This will remove trailing spaces, fit all content
# under 80 char long lines, etc
prettier \
  --write \
  ./*.md \
  ./src/*.md
