#!/bin/sh
# script/fmt: format this repo's markdown and CSS with prettier, using
# our standard settings. Scope is every markdown and CSS file in the
# tree, per REPO_POLICIES.md ("prettier for JS/CSS/Markdown/HTML").
# What is deliberately NOT covered is recorded in .prettierignore, with
# the reason next to each entry: the Hugo layout templates, which are
# Go templates and not HTML, and content/, whose reformatting was
# measured to change the rendered page.
#
# Both prettier entrypoints run on the host: only linting is
# containerised (owner ruling, 2026-08-10), and formatting is not a
# lint. Keep the version, scope and flags here in sync with
# script/fmt-check.
set -eu

ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"

PRETTIER_VERSION="3.4.2"

main() {
    cd "$ROOT"
    npx --yes "prettier@${PRETTIER_VERSION}" --write \
        '**/*.md' '**/*.css' --tab-width 4 --prose-wrap always
}

main "$@"
