#!/usr/bin/env bash
mdformat README.md ./docs --no-validate --number

# Check for toolchain version of 'sed'
# The formatter replaces '---' with the '______...' but this is required to stay due to mkdocs yaml directives
if sed --version 2>/dev/null | grep -q 'GNU'; then
  # GNU sed (Linux)
  find ./docs -type f -name "*.md" -exec sed -i 's/^______________________________________________________________________$/---/' {} +
else
  # Assumed BSD sed (macOS, FreeBSD, etc.)
  find ./docs -type f -name "*.md" -exec sed -i '' 's/^______________________________________________________________________$/---/' {} +
fi
