Created
March 4, 2024 17:36
-
-
Save andreagrandi/800e5e33ec05f8d51f61a1cdc4fc4d91 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# This script is necessary to remove the annotations block from each Markdown file. | |
# These annotations are being written by iA Writer and are not necessary for the website. | |
# Define the directory to start searching from. Adjust this to your specific folder. | |
START_DIR="content" | |
# Process each Markdown file in the specified directory and its subfolders. | |
find "$START_DIR" -type f -name "*.md" | while read -r file; do | |
echo "Processing: $file" | |
# Use awk to skip the annotations block as described. | |
awk ' | |
/^---$/ { | |
getline; | |
if ($0 ~ /^Annotations:/) skip_block=1 | |
} | |
skip_block && /^...$/ { | |
skip_block=0; | |
next; | |
} | |
!skip_block { print } | |
' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file" | |
echo "Finished processing: $file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment