Skip to content

Commit

Permalink
Add taskfile with md:list and md:fmt targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Tit Petric committed Mar 22, 2024
1 parent 09112c6 commit 8fcd9f7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
version: "3"

vars:
lit: '{'
changes:
sh: git diff --name-only master | grep '.md$'

tasks:
md:list:
desc: "List changed .md files on PR"
cmds:
- for:
var: changes
as: change
split: "\n"
silent: true
cmd: echo {{.change}}

md:fmt:
desc: "Run mdox fmt on changed .md files on PR"
cmds:
- for:
var: changes
as: change
split: "\n"
silent: true
cmd: |
if [ -f "{{.change}}" ]; then
echo {{.change}}
mdox fmt {{.change}}
# list item formatting
perl -pi -e 's/^\* /- /g' {{.change}}
# leading space before list (-) after colon (:)
sed -i -E ':a;N;$!ba;s/:\n-/:\n\n-/g' {{.change}}
# sanitize code block highlights from .js to js, ...
sed -i 's/```\./```/g' {{.change}}
# restore notice hugo shortcode whitespace
sed -i 's/>}} />}}\n/g' {{.change}}
sed -i 's/[[:space:]]\x7b\x7b</\n\x7b\x7b</g' {{.change}}
fi

0 comments on commit 8fcd9f7

Please sign in to comment.