Skip to content

Commit

Permalink
Update update-arcs.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
SudoWeezy committed Oct 2, 2024
1 parent a2332b4 commit 0d34f28
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions _devportal/scripts/update-arcs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,30 @@ for file in arc-*.md; do
continue
fi

# 2. Replace links like [ARC-1](./arc-0001.md) or [ARC-1](arc-0001.md) with [ARC-1](/standards/arcs/arc-0001)
sed -i $SED_INLINE -E 's|\(\.?/arc-([0-9]{4})\.md\)|(/standards/arcs/arc-\1)|g' "$file"
# 2 Step 1: Remove leading './' from links like ./arc-0001.md or ./arc-0001.md#interface-signtxnsopts
sed -i $SED_INLINE -E 's|\(\./arc-([0-9]{1,4})\.md(\#[a-zA-Z0-9_-]+)?\)|\(arc-\1.md\2)|g' "$file"
if [[ $? -ne 0 ]]; then
echo "Failed to update links in $file"
echo "Failed to remove leading './' in links in $file"
continue
fi

# 3. Replace links like [here](../assets/arc-0062) with [here](https://github.com/algorandfoundation/ARCs/tree/main/assets/arc-0062)
sed -i $SED_INLINE -E 's|\(\.\./assets/arc-([0-9]{4})\)|\(https://github.com/algorandfoundation/ARCs/tree/main/assets/arc-\1\)|g' "$file"
# 2 Step 2: Replace all arc-XXXX.md links with /standards/arcs/arc-XXXX
sed -i $SED_INLINE -E 's|\(arc-([0-9]{1,4})\.md(\#[a-zA-Z0-9_-]+)?\)|\(/standards/arcs/arc-\1\2)|g' "$file"
if [[ $? -ne 0 ]]; then
echo "Failed to update asset links in $file"
echo "Failed to update links to /standards/arcs/ in $file"
continue
fi

# 3a. Handle anchors like [ARC-1](./arc-0001.md#interface-signtxnsopts) or [ARC-1](arc-0001.md#interface-signtxnsopts)
sed -i $SED_INLINE -E 's|\(\.?/arc-([0-9]{4})\.md(\#[a-zA-Z0-9_-]+)?\)|(/standards/arcs/arc-\1\2)|g' "$file"
# 3. Replace links like [here](../assets/arc-0062) with [here](https://github.com/algorandfoundation/ARCs/tree/main/assets/arc-0062)
sed -i $SED_INLINE -E 's|\(\.\./assets/arc-([0-9]{4})\)|\(https://github.com/algorandfoundation/ARCs/tree/main/assets/arc-\1\)|g' "$file"
if [[ $? -ne 0 ]]; then
echo "Failed to update anchored links in $file"
echo "Failed to update asset links in $file"
continue
fi




# 4. Ensure exactly one blank line between the end of the front matter and the Abstract section
sed -i $SED_INLINE -E '/^---$/,/^## Abstract$/ { /^\s*$/d; }' "$file"
if [[ $? -ne 0 ]]; then
Expand Down

0 comments on commit 0d34f28

Please sign in to comment.