Debian Codegraph @

scripts/latex-encode

raw
1 #!/usr/bin/perl
2 # $Id: latex-encode 28 2012-08-30 20:00:09Z andrew $
3
4 use strict;
5
6 use LaTeX::Encode;
7 use Getopt::Long;
8 use Pod::Usage;
9
10 my ($list_packages, $help, $man);
11
12 GetOptions('packages' => \$list_packages,
13 'help|?' => \$help,
14 'man' => \$man)
15 or pod2usage(2);
16
17 pod2usage(1) if $help;
18 pod2usage(-exitstatus => 0, -verbose => 2) if $man;
19
20
21 if ($list_packages) {
22 my $text = join(qr{}, <>);
23 my $packages = {};
24 latex_encode($text, $packages);
25 foreach my $package (sort keys %$packages) {
26 print "$package\n";
27 }
28 }
29 else {
30 while (<>) {
31 print latex_encode($_);
32 }
33 }
34
35 __END__
36
37 =head1 NAME
38
39 latex-encode - LaTeX-encode data
40
41 =head1 USAGE
42
43 latex-encode [options] <utf8-file >latex-file
44
45 =head1 OPTIONS
46
47 =over 4
48
49 =item C<-packages|-p>
50
51 rather than output the LaTeX-encoded version of the input, C<latex-encode> outputs a list
52 of the LaTeX packages that are required to typeset the encoded version of the input, one
53 package per line
54
55 =item C<-help|?>
56
57 output a help string
58
59 =item C<-man>
60
61 display the man page for latex-encode
62
63 =back
64
65 =head1 DESCRIPTION
66
67 This script converts utf-8 characters in its input to their LaTeX encodings using the
68 C<LaTeX::Encode> module, unless the C<-packages> option is given, in which case it outputs
69 a list of the LaTeX packages required to typeset the encoded bersion of the input.
70
71 =head1 DIAGNOSTICS
72
73 =head1 EXIT STATUS
74
75 =head1 CONFIGURATION
76
77 =head1 DEPENDENCIES
78
79 =head1 INCOMPATIBILITIES
80
81 =head1 BUGS AND LIMITATIONS
82
83 =head1 AUTHOR
84
85 Andrew Ford E<lt>[email protected]<gt>
86
87 =head1 COPYRIGHT AND LICENSE
88
89 Copyright (C) 2012 Andrew Ford. All Rights Reserved.
90
91 This module is free software; you can redistribute it and/or
92 modify it under the same terms as Perl itself.
93
94 =cut
95