6 # This small filter converts a hyphenation exception log article for
7 # TUGBoat to a real \hyphenation block.
9 # Written by Werner Lemberg <wl@gnu.org>.
11 # Version 1.1 (2003/04/17)
18 # [perl] hyphenex.pl < tugboat-article > hyphenation-exceptions
21 print "% Hyphenation exceptions for US English,\n";
22 print "% based on the hyphenation exception log article in TUGBoat.\n";
24 print "% This is an automatically generated file. Do not edit!\n";
26 print "% Please contact Barbara Beeton <bnb\@ams.org>\n";
27 print "% for corrections and omissions.\n";
29 print "\\hyphenation{\n";
32 # retain only lines starting with \1 ... \6 or \tabalign
33 next if not (m/^\\[123456]/ || m/^\\tabalign/);
34 # remove final newline
36 # remove all TeX commands except \1 ... \6
38 # remove all paired { ... }
39 1 while s/{(.*?)}/\1/g;
40 # skip lines which now have only whitespace before `&'
44 # remove trailing whitespace
46 # remove trailing `*' (used as a marker in the document)
50 if ($field[0] eq "\\1" || $field[0] eq "\\4") {
53 elsif ($field[0] eq "\\2" || $field[0] eq "\\5") {
55 # handle multiple suffixes separated by commata
56 @suffix_list = split(/,/, "$field[3]");
57 foreach $suffix (@suffix_list) {
58 print " $field[2]$suffix\n";
61 elsif ($field[0] eq "\\3" || $field[0] eq "\\6") {
62 # handle multiple suffixes separated by commata
63 @suffix_list = split(/,/, "$field[3],$field[4]");
64 foreach $suffix (@suffix_list) {
65 print " $field[2]$suffix\n";
69 # for `&', split at `&' with trailing whitespace
70 @field = split(/&\s*/);