-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to get cont scippt - temp changes for dev only
- Loading branch information
chris del
committed
Nov 7, 2024
1 parent
f27ba36
commit 139f14d
Showing
1 changed file
with
20 additions
and
4 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 |
---|---|---|
@@ -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 |