From 8874e67498a2dca711dee19cd9bdf129888b30f9 Mon Sep 17 00:00:00 2001 From: wlemb Date: Thu, 17 Apr 2003 07:41:51 +0000 Subject: Add comments. Remove nested paired braces also. --- tmac/hyphenex.pl | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'tmac/hyphenex.pl') diff --git a/tmac/hyphenex.pl b/tmac/hyphenex.pl index 493303f2..310f9b06 100644 --- a/tmac/hyphenex.pl +++ b/tmac/hyphenex.pl @@ -8,7 +8,7 @@ # # Written by Werner Lemberg . # -# Version 1.0 (2003/04/16) +# Version 1.1 (2003/04/17) # # Public domain. # @@ -17,6 +17,7 @@ # # [perl] hyphenex.pl < tugboat-article > hyphenation-exceptions +# print header print "% Hyphenation exceptions for US English,\n"; print "% based on the hyphenation exception log article in TUGBoat.\n"; print "%\n"; @@ -28,37 +29,50 @@ print "\n"; print "\\hyphenation{\n"; while (<>) { + # retain only lines starting with \1 ... \6 or \tabalign next if not (m/^\\[123456]/ || m/^\\tabalign/); + # remove final newline chop; + # remove all TeX commands except \1 ... \6 s/\\[^123456\s{]+//g; - s/{(.*?)}/\1/g; + # remove all paired { ... } + 1 while s/{(.*?)}/\1/g; + # skip lines which now have only whitespace before `&' next if m/^\s*&/; + # remove comments s/%.*//; + # remove trailing whitespace s/\s*$//; + # remove trailing `*' (used as a marker in the document) s/\*$//; + # split at whitespace @field = split(' '); if ($field[0] eq "\\1" || $field[0] eq "\\4") { print " $field[2]\n"; } elsif ($field[0] eq "\\2" || $field[0] eq "\\5") { print " $field[2]\n"; + # handle multiple suffixes separated by commata @suffix_list = split(/,/, "$field[3]"); foreach $suffix (@suffix_list) { print " $field[2]$suffix\n"; } } elsif ($field[0] eq "\\3" || $field[0] eq "\\6") { + # handle multiple suffixes separated by commata @suffix_list = split(/,/, "$field[3],$field[4]"); foreach $suffix (@suffix_list) { print " $field[2]$suffix\n"; } } else { + # for `&', split at `&' with trailing whitespace @field = split(/&\s*/); print " $field[1]\n"; } } +# print trailer print "}\n"; print "\n"; print "% EOF\n"; -- cgit v1.2.1