Skip to content

Commit 4a8c4ca

Browse files
committed
bash script for markdown formatting
1 parent 5382de7 commit 4a8c4ca

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727
"API"
2828
],
2929
"scripts": {
30-
"format-markdown": "npx prettier --write --single-quote versions/3.0.4.md && sed -i '' -E -e 's/ +\\|/ |/g' -e 's/\\| +/| /g' -e 's/-----+/----/g' versions/3.0.4.md && npx --yes markdownlint-cli --fix --config .markdownlint.yaml versions/3.0.4.md"
30+
"format-markdown": "bash ./scripts/format-markdown.sh ./versions/3.0.4.md"
3131
}
3232
}

scripts/format-markdown.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
for filename in $*; do
4+
# mostly to format code blocks with examples, unfortunately messes up bullet lists and tables
5+
npx prettier --write --single-quote $filename
6+
7+
# repair the tables: remove superfluos spaces and dashes that make diffing revisions harder
8+
# and sed -i is not portable, so we need to use a temporary file
9+
sed -E -e "s/ +\|/ |/g" -e "s/\| +/| /g" -e "s/-----+/----/g" $filename > $filename.tmp && mv $filename.tmp $filename
10+
11+
# repair the bullet lists and various other markdown formatting issues
12+
npx --yes markdownlint-cli --fix --config .markdownlint.yaml $filename
13+
done

0 commit comments

Comments
 (0)