From 0d34f28f707edf2b590fd13f8f98a025be5f31fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane?= Date: Wed, 2 Oct 2024 18:59:28 +0200 Subject: [PATCH] Update update-arcs.sh --- _devportal/scripts/update-arcs.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/_devportal/scripts/update-arcs.sh b/_devportal/scripts/update-arcs.sh index 7975e810c..b4e858172 100755 --- a/_devportal/scripts/update-arcs.sh +++ b/_devportal/scripts/update-arcs.sh @@ -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