mirror of
https://github.com/inttter/md-badges.git
synced 2026-05-06 18:36:58 +02:00
feat: ✨ generate ref-style table - first cut
This commit is contained in:
parent
dd91b6dbad
commit
8498f2f736
5 changed files with 144 additions and 0 deletions
44
.github/scripts/extract-refstyle-badges/extract-refstyle-badges.sh
vendored
Executable file
44
.github/scripts/extract-refstyle-badges/extract-refstyle-badges.sh
vendored
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# #################################################################################
|
||||
# extract-refstyle-badges.sh
|
||||
#
|
||||
# Description:
|
||||
# Creates a table of reference-style markdown badges from the table rows in README.md
|
||||
#
|
||||
# #################################################################################
|
||||
|
||||
# get a reference to the current directory
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
READMEFILE="${DIR}/../../../README.md"
|
||||
|
||||
# extract the table rows from README.md, sort them, and pass them to
|
||||
# the awk script to generate the reference-style link for each row.
|
||||
# Add a newline at the end and write to md-badges.md
|
||||
readmerows=$(
|
||||
cat "${READMEFILE}" | \
|
||||
grep -E '^\| \[' | \
|
||||
sort
|
||||
)
|
||||
|
||||
# add a newline before processing with awk
|
||||
printf "%s\n" "$readmerows" \
|
||||
| awk -F '|' -f "${DIR}/extract-refstyle-badges.awk" \
|
||||
> md-badges.md
|
||||
|
||||
# now insert the generated md-badges.md content into README.md
|
||||
|
||||
lead='^<\!-- ### BEGIN GENERATED CONTENT -->'
|
||||
tail='^<\!-- ### END GENERATED CONTENT -->'
|
||||
|
||||
sed -e "/$lead/,/$tail/{
|
||||
/$lead/{
|
||||
p;
|
||||
r md-badges.md
|
||||
};
|
||||
/$tail/p;
|
||||
d
|
||||
}" "${READMEFILE}" > "${READMEFILE}.tmp"
|
||||
mv "${READMEFILE}.tmp" "${READMEFILE}"
|
||||
|
||||
# echo "${READMEFILE}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue