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.2 (2007/11/16)
18 # [perl] hyphenex.pl < tugboat-article > hyphenation-exceptions
21 print "% Hyphenation exceptions for US English,\n";
22 print "% based on hyphenation exception log articles in TUGboat.\n";
24 print "% Copyright 2007 TeX Users Group.\n";
25 print "% You may freely use, modify and/or distribute this file.\n";
27 print "% This is an automatically generated file. Do not edit!\n";
29 print "% Please contact the TUGboat editorial staff <tugboat\@tug.org>\n";
30 print "% for corrections and omissions.\n";
32 print "\\hyphenation{\n";
35 # retain only lines starting with \1 ... \6 or \tabalign
36 next if not (m/^\\[123456]/ || m/^\\tabalign/);
37 # remove final newline
39 # remove all TeX commands except \1 ... \6
41 # remove all paired { ... }
42 1 while s/{(.*?)}/\1/g;
43 # skip lines which now have only whitespace before `&'
47 # remove trailing whitespace
49 # remove trailing `*' (used as a marker in the document)
53 if ($field[0] eq "\\1" || $field[0] eq "\\4") {
56 elsif ($field[0] eq "\\2" || $field[0] eq "\\5") {
58 # handle multiple suffixes separated by commata
59 @suffix_list = split(/,/, "$field[3]");
60 foreach $suffix (@suffix_list) {
61 print " $field[2]$suffix\n";
64 elsif ($field[0] eq "\\3" || $field[0] eq "\\6") {
65 # handle multiple suffixes separated by commata
66 @suffix_list = split(/,/, "$field[3],$field[4]");
67 foreach $suffix (@suffix_list) {
68 print " $field[2]$suffix\n";
72 # for `&', split at `&' with trailing whitespace
73 @field = split(/&\s*/);