-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add taskfile with md:list and md:fmt targets
- Loading branch information
Tit Petric
committed
Mar 22, 2024
1 parent
09112c6
commit 8fcd9f7
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |