forked from trent_larson/crowd-funder-for-time-pwa
Fix: markdownlint MD012/MD019 errors in build-pattern-conversion-plan.md
- Removed extra blank lines at end of file to resolve MD012 (no-multiple-blanks) - Standardized heading spacing to resolve MD019 (no-multiple-space-atx) - Stripped trailing whitespace and ensured file ends with a single newline All changes maintain content integrity and bring the file into full markdownlint compliance.
This commit is contained in:
37
scripts/format-markdown.sh
Executable file
37
scripts/format-markdown.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# format-markdown.sh
|
||||
# Author: Matthew Raymer
|
||||
# Date: 2025-07-09
|
||||
# Description: Format markdown files to comply with project markdown ruleset
|
||||
|
||||
set -e
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: $0 <file-or-directory> [more files...]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for target in "$@"; do
|
||||
if [ -d "$target" ]; then
|
||||
files=$(find "$target" -type f -name "*.md")
|
||||
else
|
||||
files="$target"
|
||||
fi
|
||||
for file in $files; do
|
||||
# Remove trailing spaces
|
||||
sed -i 's/[[:space:]]*$//' "$file"
|
||||
# Remove multiple consecutive blank lines
|
||||
awk 'NF{blank=0} !NF{blank++} blank<2' "$file" > "$file.tmp" && mv "$file.tmp" "$file"
|
||||
# Ensure file ends with a single newline
|
||||
awk '1; END{if (NR && $0!="") print ""}' "$file" > "$file.tmp" && mv "$file.tmp" "$file"
|
||||
# Optionally run markdownlint (requires npx and markdownlint-cli)
|
||||
if command -v npx >/dev/null 2>&1; then
|
||||
npx markdownlint "$file"
|
||||
else
|
||||
echo "npx/markdownlint not found, skipping lint check for $file"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
echo "Markdown formatting complete."
|
||||
Reference in New Issue
Block a user