Skip to content

Commit

Permalink
Changes to get cont scippt - temp changes for dev only
Browse files Browse the repository at this point in the history
  • Loading branch information
chris del committed Nov 7, 2024
1 parent f27ba36 commit 139f14d
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions .github/scripts/get-contributing.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,52 @@
#!/bin/bash

DEST="../../en/resources/contributing.md"
DEST="./en/resources/contributing.md"

# This script replaces the contents of a section with the contents from
# the annotated source address.

level=''
src=''
while IFS= read -r line; do
# echo "TOP LINE: $line"
if [[ -n "$src" ]] && [[ "$line" != '#'* || "$line" == "$level"'#'* ]]; then
echo "AFTER top: level: $Level, lineL $line src: $src"
continue
else
echo "NOT Continue: "$src": "$line""
fi

src=''
# gets headers
if [[ "$line" == '#'* ]]; then
# echo "after Continue: "$src": "$line""
title=${line##*\#}
level="${line:0:$((${#line} - ${#title}))}"
elif [[ "$line" == '<!-- SRC:'* ]]; then
src=${line:10}
src=${src% *}
fi

echo "SET src: "$src""
elif [[ "$line" == '<!-- LOAD:'* ]]; then
src=${line:11}
src=${src% *}
echo "SET NEW src: "$src""
fi
# echo "XXX: $line"
echo "$line"
if [[ "$line" == '<!-- LOAD:'* ]]; then
echo "STOP"
break
fi

if [[ -n "$src" ]]; then
echo
echo "START IMPORT: $src"
path=${src#* }
repo=${src% *}
curl -s "https://raw.githubusercontent.com/${repo}/master/${path}" | \
sed -En '/^##|^[^#]/,$p' | \
sed 's/^#/&'"${level:1}"'/g' | \
sed -E 's/(\[[^]]*\])\(([^):#]*)\)/\1(https:\/\/github.com\/'"$(sed 's/\//\\\//g' <<< "$repo")"'\/blob\/master\/\2)/g'
echo
echo "END IMPORT"
fi
done <<<"$(< $DEST)" > $DEST

0 comments on commit 139f14d

Please sign in to comment.