3 #@ This small filter converts a hyphenation exception log article for
4 #@ TUGBoat to a real \hyphenation block.
5 #@ Version 1.2 (2007/11/16)
7 #@ [perl] hyphenex.pl < tugboat-article > hyphenation-exceptions
9 # Written by Werner Lemberg <wl@gnu.org>.
12 # Adapted to S-roff by Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>.
15 print "% Hyphenation exceptions for US English,\n";
16 print "% based on hyphenation exception log articles in TUGboat.\n";
18 print "% Copyright 2007 TeX Users Group.\n";
19 print "% You may freely use, modify and/or distribute this file.\n";
21 print "% This is an automatically generated file. Do not edit!\n";
23 print "% Please contact the TUGboat editorial staff <tugboat\@tug.org>\n";
24 print "% for corrections and omissions.\n";
26 print "\\hyphenation{\n";
29 # retain only lines starting with \1 ... \6 or \tabalign
30 next if not (m/^\\[123456]/ || m/^\\tabalign/);
31 # remove final newline
33 # remove all TeX commands except \1 ... \6
35 # remove all paired { ... }
36 1 while s/{(.*?)}/\1/g;
37 # skip lines which now have only whitespace before `&'
41 # remove trailing whitespace
43 # remove trailing `*' (used as a marker in the document)
47 if ($field[0] eq "\\1" || $field[0] eq "\\4") {
50 elsif ($field[0] eq "\\2" || $field[0] eq "\\5") {
52 # handle multiple suffixes separated by commata
53 @suffix_list = split(/,/, "$field[3]");
54 foreach $suffix (@suffix_list) {
55 print " $field[2]$suffix\n";
58 elsif ($field[0] eq "\\3" || $field[0] eq "\\6") {
59 # handle multiple suffixes separated by commata
60 @suffix_list = split(/,/, "$field[3],$field[4]");
61 foreach $suffix (@suffix_list) {
62 print " $field[2]$suffix\n";
66 # for `&', split at `&' with trailing whitespace
67 @field = split(/&\s*/);