| 1 | package TeX::Hyphen::utf8; | ||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||
| 5 | TeX::Hyphen::utf8 -- provides parsing routine for generic utf8 text | ||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||
| 9 | use TeX::Hyphen; | ||||||||||||||||||||||||||||||||||||
| 10 | my $hyp = new TeX::Hyphen 'hyphen.tex', style => 'utf8'; | ||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||
| 12 | # and then follow documentation for TeX::Hyphen | ||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||
| 14 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||
| 16 | This pattern is for utf8 pattern files. | ||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||
| 18 | =over 4 | ||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||
| 20 | =item process_patterns | ||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||
| 22 | This method gets individual lines of the \patterns content. It should | ||||||||||||||||||||||||||||||||||||
| 23 | parse these lines, and fill values in $bothhyphen, $beginhyphen, | ||||||||||||||||||||||||||||||||||||
| 24 | $endhyphen and $hyphen which are being passed to this function as | ||||||||||||||||||||||||||||||||||||
| 25 | parameters following the line. The function should return 0 if end of | ||||||||||||||||||||||||||||||||||||
| 26 | the pattern section (macro) was reached, 1 if the parsing should | ||||||||||||||||||||||||||||||||||||
| 27 | continue. | ||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||
| 29 | =item process_hyphenation | ||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||
| 31 | This method gets the lines of the \hyphenation content. It should | ||||||||||||||||||||||||||||||||||||
| 32 | parse these lines and fill values into $exception which is passed as | ||||||||||||||||||||||||||||||||||||
| 33 | second parameter upon call. The function should return 0 if end of the | ||||||||||||||||||||||||||||||||||||
| 34 | exception section (macro) was reached, 1 if the parsing should | ||||||||||||||||||||||||||||||||||||
| 35 | continue. | ||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||
| 37 | =back | ||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||
| 39 | Check the TeX::Hyphen::czech source to see the exact form of the | ||||||||||||||||||||||||||||||||||||
| 40 | values inserted into these has structures. | ||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||
| 42 | Each style module should also define $LEFTMIN and $RIGHTMIN global | ||||||||||||||||||||||||||||||||||||
| 43 | variables, if they have different values than the default 2. The | ||||||||||||||||||||||||||||||||||||
| 44 | values should match the paratemers used to generate the patterns. | ||||||||||||||||||||||||||||||||||||
| 45 | Since various pattern files could be generated with different values | ||||||||||||||||||||||||||||||||||||
| 46 | set, this is just default that can be changed with parameters to the | ||||||||||||||||||||||||||||||||||||
| 47 | TeX::Hyphen constructor. | ||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||
| 49 | =cut | ||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||
| 51 | # ###################################################### | ||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | use vars qw( $LEFTMIN $RIGHTMIN $VERSION ); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 54 | 1 | $VERSION = 0.121; | |||||||||||||||||||||||||||||||||||
| 55 | 1 | $LEFTMIN = 2; | |||||||||||||||||||||||||||||||||||
| 56 | 1 | $RIGHTMIN = 2; | |||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||
| 58 | sub process_patterns { | ||||||||||||||||||||||||||||||||||||
| 59 | 4 | ▶ | my ($line, $bothhyphen, $beginhyphen, $endhyphen, $hyphen) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
process_patterns: called CC=11 SCAR=25.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||
| 61 | 4 | ▶ | if ($line =~ /\}/) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 62 | 1 | return 0; | |||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||
| 65 | 3 | for (split /\s+/, $line) { | |||||||||||||||||||||||||||||||||||
| 66 | 3 | ▶ | next if $_ eq ''; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 67 | 3 | my $orig = $_; | |||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||
| 69 | 3 | my $begin = 0; | |||||||||||||||||||||||||||||||||||
| 70 | 3 | my $end = 0; | |||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||
| 72 | 3 | ▶ | $begin = 1 if s!^\.!!; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 73 | 3 | ▶ | $end = 1 if s!\.$!!; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 74 | 3 | s!(\D)(?=\D)!${1}0!g; # insert zeroes | |||||||||||||||||||||||||||||||||||
| 75 | 3 | s!^(?=\D)!0!; # and start with some digit | |||||||||||||||||||||||||||||||||||
| 76 | 3 | ▶ | print "$orig => $_\n" if ($TeX::Hyphen::DEBUG>5); | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||
| 78 | 3 | ($tag = $_) =~ s!\d!!g; # get the string | |||||||||||||||||||||||||||||||||||
| 79 | 3 | ($value = $_) =~ s!\D!!g; # and numbers apart | |||||||||||||||||||||||||||||||||||
| 80 | 3 | $tag = lc($tag); # convert to lowercase | |||||||||||||||||||||||||||||||||||
| 81 | # (if we knew locales are fine everywhere, | ||||||||||||||||||||||||||||||||||||
| 82 | # we could use them) | ||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||
| 84 | 3 | ▶ | if ($begin and $end) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
$begin and $end
MC/DC0%0/2
$begin and $end
$begin
$end
Truth table33%1/3
A and B
A= $beginB= $end
| |||||||||||||||||||||||||||||||||||||
| 85 | 0 | $bothhyphen->{$tag} = $value; | |||||||||||||||||||||||||||||||||||
| 86 | } elsif ($begin) { | ||||||||||||||||||||||||||||||||||||
| 87 | 0 | $beginhyphen->{$tag} = $value; | |||||||||||||||||||||||||||||||||||
| 88 | } elsif ($end) { | ||||||||||||||||||||||||||||||||||||
| 89 | 1 | $endhyphen->{$tag} = $value; | |||||||||||||||||||||||||||||||||||
| 90 | } else { | ||||||||||||||||||||||||||||||||||||
| 91 | 2 | $hyphen->{$tag} = $value; | |||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||
| 95 | 3 | 1; | |||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||
| 98 | sub process_hyphenation { | ||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | my ($line, $exception) = @_; | ||||||||||||||||||||||||||||||||||
|
Subroutine
process_hyphenation: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if ($line =~ /\}/) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 102 | 0 | return 0; | |||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||
| 105 | 0 | local $_ = $line; | |||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||
| 107 | 0 | ($tag = $_) =~ s!-!!g; | |||||||||||||||||||||||||||||||||||
| 108 | 0 | $tag = lc($tag); | |||||||||||||||||||||||||||||||||||
| 109 | 0 | ($value = '0' . $_) =~ s!0!g; | |||||||||||||||||||||||||||||||||||
| 110 | 0 | $value =~ s![^-]-!1!g; | |||||||||||||||||||||||||||||||||||
| 111 | 0 | $value =~ s![^01]!0!g; | |||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||
| 113 | 0 | $exception->{$tag} = $value; | |||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||
| 115 | 0 | return 1; | |||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||
| 118 | 1 | 1; | |||||||||||||||||||||||||||||||||||