Browse Source

minor edit

main
lhess2021 4 years ago
parent
commit
894286db9e
  1. 10
      shell-scripts.d/tercet-tags.sh

10
shell-scripts.d/tercet-tags.sh

@ -7,16 +7,18 @@ echo -e "\nAdding terzina tags and numbers."
for file in *;
do
if [[ "$file" != 'tercet-tags.sh' ]]; then # exclude this script
if [[ "$file" != tercet-tags.sh ]] && [[ "$file" != canticle-to-xml.sh ]]; then # exclude this script
if [[ "$file" != sed* ]]; then # exclude sed file made later
echo -e "Modifying $file"
# Every third line (mod 3) add a closing tag, newline, and opening tag.
# TODO
# How many tabs to add?
awk -i inplace '{print}; NR % 3 == 0 {print "\t\t</tercet>\n\t\t<tercet num=~NUM~>"}' "$file"
awk -i inplace '{print}; NR % 3 == 0 {print "\t\t\t\t</tercet>\n\t\t\t\t<tercet num=~NUM~>"}' "$file"
# Add an opening tag at the beginning and a closing tag at the end because the above awk doesn't.
sed -i '1s/^/\t\t<tercet num="1">\n/' "$file"
echo -e "\t\t</terzina>" >> "$file"
sed -i '1s/^/\t\t\t\t<tercet num="1">\n/' "$file"
# Also remove the newline at the end of the file.
sed -i '$ d' "$file"
echo -e "\t\t\t\t</tercet>" >> "$file"
# Add the canto number attribute (at most 160/3 ~ 54 terzine)
for i in $(seq 1 54);
do

Loading…
Cancel
Save