1TeX::Hyphen(3) User Contributed Perl Documentation TeX::Hyphen(3)
2
3
4
6 TeX::Hyphen -- hyphenate words using TeX's patterns
7
9 use TeX::Hyphen;
10 my $hyp = new TeX::Hyphen 'file' => 'hyphen.tex',
11 'style' => 'czech', leftmin => 2,
12 rightmin => 2;
13
14 # my $hyp = new TeX::Hyphen "hyphen.tex";
15
16 my $word = "representation";
17 my @points = $hyp->hyphenate($word);
18 print $hyp->visualize($word), "\n";
19
21 Constructor new() creates a new Hyphen object and loads the file with
22 patterns into memory. Then you can ask it for hyphenation of a word by
23 calling a method of this object. If no file is specified, the default
24 Donald E. Knuth's hyphen.tex, that is included in this module, is used
25 instead.
26
27 Arguments to constructor
28
29 You can pass arguments to the new() call as hash, possible options are
30
31 file
32 Name of the file with the patters. It will be loaded and the
33 resulting object will be able to hyphenate according to patterns in
34 that file.
35
36 For convenience and backward compatibility, the file name can also
37 be specified as the first (odd) parameter to new().
38
39 style
40 Various languages use special shortcuts to specify the patterns.
41 Instead of doing the full TeX expansion, we use Perl code to parse
42 the patterns. The style option loads TeX::Hyphen::name_of_the_style
43 module and uses the parsing functions found in it.
44
45 Currently, the default czech (which also works for English alright)
46 and german are available. See the TeX::Hyphen::czech man page for
47 more information, especially if you want to support other lan‐
48 guages/styles.
49
50 leftmin
51 The minimum starting substring which will not be hyphenated. This
52 overrides the default specified in the style file.
53
54 rightmin
55 The minimum ending substring which will not be hyphenated. This
56 overrides the default specified in the style file.
57
58 Methods that are supported
59
60 Method hyphenate() returns list of places where the word can be
61 divided, so
62
63 $hyp->visualize('representation')
64
65 returns list (3, 5, 8, 10).
66
67 Method visualize() can be used to show these points, so
68
69 $hyp->visualize('representation')
70
71 should return "rep-re-sen-ta-tion", at least for English patterns.
72
73 Variables $TeX::Hyphen::LEFTMIN and $TeX::Hyphen::RIGHTMIN can be used
74 to restrict minimal starting and ending substring where it is not pos‐
75 sible to hyphenate. They both default to 2 but should be changed to
76 match the paratemers used to generate the patterns.
77
78 Variable $TeX::Hyphen::DEBUG can be set to see some statistics and pro‐
79 cessing.
80
81 The file with hyphenation patterns may contain "\'" and "\v" accents,
82 used in the Czech (and other) languages.
83
85 0.110 Tue Dec 11 14:26:15 MET 2001
86 Support for more languages made modular, code for German parsing
87 provided by Slaven Rezic.
88
89 0.101 Wed Nov 3 16:06:02 MET 1999
90 Parsing of patterns extended to allow other styles as well -- Span‐
91 ish pattern file provided by Adrian Perez Jorge.
92
93 0.10 Fri Dec 11 10:58:01 MET 1998
94 Bug fixes concering LEFTMIN and RIGHTMIN values and use of excep‐
95 tions (thanks go to Vladimir Volovich).
96
97 0.06 Mon Jul 21 18:53:26 MET DST 1997
98 Exception table handling added -- error spotted by Jon Orwant.
99
100 0.05 Wed Jul 9 14:49:42 MET DST 1997
101 Added the default hyphen.tex into the module and possibility to
102 call the constructior without argument to get this default pattern
103 file.
104
105 0.04 Wed Apr 9 15:41:32 MET DST 1997
106 Hash lookup made faster.
107
108 Method TeX::Hyphen::visualize() only takes one argument, it calls
109 hyphenate().
110
111 0.03 Sun Feb 16 13:55:26 MET 1997
112 Hash lookup made faster.
113
114 Original name Hyphen chaged to TeX::Hyphen.
115
117 0.140
118
120 perl(1), TeX::Hyphen::czech.
121
123 (c) 1997--2002 Jan Pazdziora, adelton@fi.muni.cz at Faculty of Infor‐
124 matics, Masaryk University, Brno
125
126
127
128perl v5.8.8 2002-04-24 TeX::Hyphen(3)