diff --git a/shell-scripts.d/top-level-tags.sh b/shell-scripts.d/top-level-tags.sh index ec24e42..65c00b2 100755 --- a/shell-scripts.d/top-level-tags.sh +++ b/shell-scripts.d/top-level-tags.sh @@ -2,6 +2,7 @@ # This script adds top-level tags to your XML files. # - XML header +# - TEI header # - and tags with attributes echo -e "\nAdding top-level tags." @@ -11,20 +12,38 @@ do if [[ "$file" != 'top-level-tags.sh' ]]; then CANTO_NUM="$(echo "'$file'" | tr -d -c 0-9)" # get canto number if [[ "$file" == inferno* ]]; then + CANTICLE="Inferno" COMM_NUM="$CANTO_NUM" # same as inferno canto number elif [[ "$file" == purgatorio* ]]; then + CANTICLE="Purgatorio" COMM_NUM="$((CANTO_NUM + 34))" # add 34 if in purgatory - else + elif [[ "$file" == paradiso* ]]; then + CANTICLE="Paradiso" COMM_NUM="$((CANTO_NUM + 67))" # add 68 if in paradise + else + echo -e "\nWhat file is this? $file" fi # Add tags to first line of file - sed -i '1s/^/\n\n\n\t\n/' "$file" - # Replace canto number and comedy number - sed -i "s/~CANTO_NUM~/\"$CANTO_NUM\"/" "$file" - sed -i "s/~COMM_NUM~/\"$COMM_NUM\"/" "$file" + sed -i -e '1s/^/\ +\n\ +\t\ +\t\t\ +\t\t\tCanto ~TITLE_CANTO_NUM~ of ~CANTICLE~<\/titleStmt>\ +\t\t<\/fileDesc>\ +\t<\/teiHeader>\ +\t\ +\t\t\ +\t\t\t\n/' "$file" + # Replace canto number, comedy number, and canticle + sed -i -e "s/~TITLE_CANTO_NUM~/$CANTO_NUM/" "$file" + sed -i -e "s/~CANTO_NUM~/\"$CANTO_NUM\"/" "$file" + sed -i -e "s/~COMM_NUM~/\"$COMM_NUM\"/" "$file" + sed -i -e "s/~CANTICLE~/$CANTICLE/" "$file" # Add tags to end of file - echo -e "\t" >> "$file" - echo -e "" >> "$file" + echo -e "\t\t\t" >> "$file" + echo -e "\t\t" >> "$file" + echo -e "\t" >> "$file" + echo -e "" >> "$file" # Add a `.xml` extension mv "$file" "$file.xml" fi