# Script name: eqpdlinks.awk # Last update: October 04 2016 # Purpose: Extract all scripture references and create # html style links to open them in Equipd Bible. # Result will be like: equipdbible://bible/Philippians4:6,7 # To Do: Modify script to correctly capture Song Of Solomon. # File used for extraction could be w_E_201609_01.rtf downloaded # from jw.org and converted to text format. # Next line is command to run at bash prompt. Adjust according to need. #gawk -f eqpdlinks.awk Documents/w_E_201609_01.txt > Documents/wtlinks.txt BEGIN{ prefix="equipdbible://bible/" } { line = $0 # This first regex captures all single or multiple scripture references. Some # multiples may only give book name for first reference. # Ex: Nehemiah 1:10; 2:17-20; 6:9 while(match(line,/([[:digit:]]?[[:space:]]?[[:alpha:]]{2,})\.?[[:space:]]*[[:digit:]]{1,}:[[:digit:]]{1,}[,-]?([[:space:]](ftn\.?|footnote))?([[:space:]]*[[:digit:]]{1,3},?)*(([[:space:]]?(ftn\.?|footnote))?;[[:space:]]*[[:digit:]]{1,}:[[:digit:]]{1,}[,-]?([[:space:]]*[[:digit:]]{1,3},?)*)*/, arrGroups)>0){ output=substr(line,RSTART,RLENGTH) gsub(/([[:space:]]|\.)*/, "", output) split(output, arrBks, ";") # Cleaning unneeded text. sub(/[,[:space:]]?(ftn\.?|footnote)/, "", arrBks[1]) # Here we print just the reference containing the book name. print prefix arrBks[1] # Now we add missing book names as necessary. if(index(output, ";")){ gsub(/([[:space:]]|\.)*/, "", arrGroups[1]) ub = split(output, arrBksplus, /(;[^;A-Za-z]+)/, arrNameNeeded) # Here we loop through the remaining references captured into an array. for(i=1;i