-
Notifications
You must be signed in to change notification settings - Fork 1
/
tex2xml.sh
5 lines (4 loc) · 1.56 KB
/
tex2xml.sh
1
2
3
4
5
#!/bin/bash
echo '<?xml version="1.0" encoding="UTF-8"?><text><body>'
egrep -v '^\\(setlength|markboth)' | egrep '[a-z]' | sed 's/^\\noindent//' | egrep -v '\\(addcontent|chapter)' | sed 's/^\\textdbend\\textdagger/\\textdagger/' | sed '/^[^\/$]/s/\([^,.]*\)[,.] */<sense><cit type="translation" xml:lang="ga"><quote>\1<\/quote><\/cit><\/sense>/g' | sed 's/<\/sense>$/&\n<\/entry>/' | sed '/^\$\\rightarrow/s/^\$\\rightarrow\$ \\hyperlink{\([^}]*\)}.*/<xr><ptr target="#\1"\/><\/xr>\n<\/entry>/' | sed 's/^\\hypertarget{\([^}]*\)}{\\textbf{\([^}]*\)}}, \\textit{\([^}]*\)}: */<entry xml:id="\1">\n<form><orth>\2<\/orth><\/form><gramGrp><pos>\3<\/pos><\/gramGrp>/' | sed 's/^\\hypertarget{\([^}]*\)}{\\textbf{\([^}]*\)}}$/<entry xml:id="\1">\n<form><orth>\2<\/orth><\/form>/' | sed 's/^\\textbf{\([^}]*\)}, \\textit{\([^}]*\)}$/<entry>\n<form><orth>\1<\/orth><\/form><gramGrp><pos>\2<\/pos><\/gramGrp>/' | sed 's/^\\textdagger\\hypertarget{\([^}]*\)}{\\textbf{\([^}]*\)}}, \\textit{\([^}]*\)}: */<entry xml:id="\1">\n<form><orth>\2<\/orth><\/form><gramGrp><pos>\3<\/pos><\/gramGrp><lbl>annamh<\/lbl>/' | sed 's/^\$\\bigstar\$\\hypertarget{\([^}]*\)}{\\textbf{\([^}]*\)}}, \\textit{\([^}]*\)}: */<entry xml:id="\1">\n<form><orth>\2<\/orth><\/form><gramGrp><pos>\3<\/pos><\/gramGrp><lbl>doiléir<\/lbl>/' | sed 's/^\\textdbend\\hypertarget{\([^}]*\)}{\\textbf{\([^}]*\)}}, \\textit{\([^}]*\)}: */<entry xml:id="\1">\n<form><orth>\2<\/orth><\/form><gramGrp><pos>\3<\/pos><\/gramGrp><lbl>bréagchara<\/lbl>/' | sed 's/^\\textbf{\([^}]*\)}$/<entry>\n<form><orth>\1<\/orth><\/form>/'
echo '</body></text>'