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 'file' => 'hyphen.tex',
15 'style' => 'utf8';
16
17 # my $hyp = new TeX::Hyphen "hyphen.tex";
18
19 my $word = "representation";
20 my @points = $hyp->hyphenate($word);
21 print $hyp->visualize($word), "\n";
22
24 Constructor new() creates a new Hyphen object and loads the file with
25 patterns into memory. Then you can ask it for hyphenation of a word by
26 calling a method of this object. If no file is specified, the default
27 Donald E. Knuth's hyphen.tex, that is included in this module, is used
28 instead.
29
30 Arguments to constructor
31 You can pass arguments to the new() call as hash, possible options are
32
33 file
34 Name of the file with the patters. It will be loaded and the
35 resulting object will be able to hyphenate according to patterns in
36 that file.
37
38 For convenience and backward compatibility, the file name can also
39 be specified as the first (odd) parameter to new().
40
41 style
42 Various languages use special shortcuts to specify the patterns.
43 Instead of doing the full TeX expansion, we use Perl code to parse
44 the patterns. The style option loads TeX::Hyphen::name_of_the_style
45 module and uses the parsing functions found in it.
46
47 Currently, the default czech (which also works for English
48 alright), german, and utf8 are available. See the
49 TeX::Hyphen::czech man page for more information, especially if you
50 want to support other languages/styles.
51
52 leftmin
53 The minimum starting substring which will not be hyphenated. This
54 overrides the default specified in the style file.
55
56 rightmin
57 The minimum ending substring which will not be hyphenated. This
58 overrides the default specified in the style file.
59
60 Methods that are supported
61 Method hyphenate() returns list of places where the word can be
62 divided, so
63
64 $hyp->hyphenate('representation')
65
66 returns list (3, 5, 8, 10).
67
68 Method visualize() can be used to show these points, so
69
70 $hyp->visualize('representation')
71
72 should return "rep-re-sen-ta-tion", at least for English patterns.
73
74 Variables $TeX::Hyphen::LEFTMIN and $TeX::Hyphen::RIGHTMIN can be used
75 to restrict minimal starting and ending substring where it is not
76 possible to hyphenate. They both default to 2 but should be changed to
77 match the paratemers used to generate the patterns.
78
79 Variable $TeX::Hyphen::DEBUG can be set to see some statistics and
80 processing.
81
82 The file with hyphenation patterns may contain "\'" and "\v" accents,
83 used in the Czech (and other) languages.
84
86 1.18
87
89 http://www.adelton.com/perl/TeX-Hyphen/
90
92 (c) 1997--2016 Jan Pazdziora.
93
94 All rights reserved. This package is free software; you can
95 redistribute it and/or modify it under the same terms as Perl itself.
96
97 Contact the author at jpx dash perl at adelton dot com.
98
100 perl(1), TeX::Hyphen::czech.
101
102
103
104perl v5.30.1 2020-01-30 TeX::Hyphen(3)