use TeX::Hyphen; my $hyp = new TeX::Hyphen 'file' => 'hyphen.tex', 'style' => 'czech', leftmin => 2, rightmin => 2; my $hyp = new TeX::Hyphen 'file' => 'hyphen.tex', 'style' => 'utf8'; # my $hyp = new TeX::Hyphen "hyphen.tex"; my $word = "representation"; my @points = $hyp->hyphenate($word); print $hyp->visualize($word), "\n";
For convenience and backward compatibility, the file name can also be specified as the first (odd) parameter to new().
Currently, the default czech (which also works for English alright), german, and utf8 are available. See the TeX::Hyphen::czech man page for more information, especially if you want to support other languages/styles.
$hyp->hyphenate('representation')
returns list (3, 5, 8, 10).
Method visualize() can be used to show these points, so
$hyp->visualize('representation')
should return "rep-re-sen-ta-tion", at least for English patterns.
Variables $TeX::Hyphen::LEFTMIN and $TeX::Hyphen::RIGHTMIN can be used to restrict minimal starting and ending substring where it is not possible to hyphenate. They both default to 2 but should be changed to match the paratemers used to generate the patterns.
Variable $TeX::Hyphen::DEBUG can be set to see some statistics and processing.
The file with hyphenation patterns may contain "\'" and "\v" accents, used in the Czech (and other) languages.
All rights reserved. This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Contact the author at jpx dash perl at adelton dot com.