Skip to content

Commit

Permalink
Merge pull request #4040 from ralfhandl/v3.0.4-dev-markdownlint
Browse files Browse the repository at this point in the history
3.0.4: tables cleanup & markdownlint
  • Loading branch information
ralfhandl authored Aug 29, 2024
2 parents ccb3b7a + c6abcd8 commit 4f1c33d
Show file tree
Hide file tree
Showing 5 changed files with 353 additions and 317 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/validate-markdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ jobs:
fetch-depth: 0
- name: use the javascript environment from main
run: |
git checkout remotes/origin/main -- package.json package-lock.json
git checkout remotes/origin/main -- package.json package-lock.json .markdownlint.yaml
- uses: actions/setup-node@v4 # setup Node.js
with:
node-version: '20.x'
- name: Validate markdown
run: npx --yes mdv versions/3.*.md
- name: Lint markdown v3.0.4
run: npx --yes markdownlint-cli --config .markdownlint.yaml versions/3.0.4.md

16 changes: 16 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Unordered list symbol
MD004:
style: asterisk

# Unordered list indentation
MD007:
indent: 2

MD012: false # allow blank lines

MD013:
line_length: 800
tables: false

MD024: false # duplicate headings
MD033: false # inline HTML
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
"Swagger",
"schema",
"API"
]
],
"scripts": {
"format-markdown": "bash ./scripts/format-markdown.sh ./versions/3.0.4.md"
}
}
15 changes: 15 additions & 0 deletions scripts/format-markdown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

SRCDIR="$(dirname "${BASH_SOURCE[0]}")" # check on Windows

for filename in $*; do
# mostly to format code blocks with examples, unfortunately messes up bullet lists and tables
npx prettier --write --single-quote $filename

# repair the tables: remove superfluos spaces and dashes that make diffing revisions harder
# and sed -i is not portable, so we need to use a temporary file
sed -E -e "s/ +\|/ |/g" -e "s/\| +/| /g" -e "s/-----+/----/g" $filename > $filename.tmp && mv $filename.tmp $filename

# repair the bullet lists and various other markdown formatting issues
npx --yes markdownlint-cli --fix --config $SRCDIR/../.markdownlint.yaml $filename
done
Loading

0 comments on commit 4f1c33d

Please sign in to comment.