Debian Codegraph @

texmf-dist/source/generic/hyph-utf8/contributed/make-exhyph.pl

raw
1 #!/usr/bin/perl
2 # -*- coding: utf-8; -*-
3 # Copyright (C) 2008 Vladimir Volovich.
4 # You may freely use, modify and/or distribute this file.
5 #
6 # Generate additional patterns (for some language), to be used in case
7 # there is an alternative hyphen character available.
8 #
9 # It enables the hyphenation of words containing explicit hyphens
10 # when using fonts with \hyphenchar\font <> `\- (e.g. T1 or T2A encoding).
11 #
12 # sample usage: perl make-exhyph.pl ru > exhyph-ru.tex
13
14 use strict;
15 use utf8;
16 binmode(STDOUT, ":utf8");
17
18 my %alphabet = (
19 'ru' => [ qw( а б в г д е ё ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я ) ],
20 'uk' => [ qw( а б в г ґ д е є ж з и і ї й к л м н о п р с т у ф х ц ч ш щ ь ю я ' ) ]
21 );
22
23 my $lang = $ARGV[0];
24 die "unspecified lang" if ! defined $lang;
25 die "invalid lang" if ! exists $alphabet{$lang};
26
27 my @alphabet = @{$alphabet{$lang}};
28
29 print <<\EOF;
30 \begingroup
31 \lccode45=45 % Make hyphen "-" a word constituent
32 \patterns{
33 8-7
34 --8
35 EOF
36
37 for my $l (@alphabet) {
38 print ".${l}-8\n";
39 }
40
41 for my $l1 (@alphabet) {
42 for my $l2 (@alphabet) {
43 print "-${l1}8${l2}8\n8${l1}8${l2}-\n";
44 }
45 }
46
47 print <<\EOF;
48 }
49 \endgroup
50 EOF