/[suikacvs]/markup/2004/tex/pretex.pl
Suika

Contents of /markup/2004/tex/pretex.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Sun Jun 13 03:53:35 2004 UTC (20 years, 4 months ago) by wakaba
Branch: MAIN
File MIME type: text/plain
\sourcecode command implemented

1 #!/usr/bin/perl
2 use strict;
3 use Encode;
4 sub c{
5 $_ = shift;
6 s/\x{3001}/, /g;
7 s/\x{3002}/. /g;
8 s{\\sourcecode\s*(?:\[([^\[\]]*)\]\s*)?{([^{}]+)}}{
9 my %opt = map {$_->[1] = 1 unless defined $_->[1]; @$_}
10 map {[split /\s*=\s*/, $_, 2]} split /\s*,\s*/, $1;
11 my $filename = $2;
12 open my $file, '<', $filename or die "$0: $filename: $!";
13 my $source = '';
14 my $line = 1;
15 for (<$file>) {
16 s/\t/ /g and warn "$0: $filename\[$line]: TAB found";
17 $source .= sprintf '%3d %s', $line++, $_;
18 }
19 $opt{size} ||= 'tiny';
20 "% $&\n\\begin{$opt{size}}\\begin{verbatim}\n$source\n\\end{verbatim}\\end{$opt{size}}\n";
21 }ge;
22 $_;
23 }
24 while(<>){
25 print encode(q<iso-2022-jp>,c(decode(q<iso-2022-jp>,$_)))
26 }
27
28
29 =head1 NAME
30
31 pretex.pl - Preprocessor for Japanese LaTeX document
32
33 =head1 SYNOPSIS
34
35 $ perl pretex.pl a.pretex > a.tex
36
37 =head1 DESCRIPTION
38
39 This script preprocesses LaTeX document. This script is
40 written to satisfy author's need only.
41
42 =head1 FEATURES
43
44 =over 4
45
46 =item Replacement of COMMA and FULL STOP
47
48 In science community, use of COMMA and FULL STOP, rather than
49 IDEOGRAPHIC COMMA and IDEOGRAPHIC FULL STOP, is often encouraged.
50 This filter script substitutes IDEOGRAPHIC COMMA and IDEOGRAPHIC FULL STOP
51 to COMMA and FULL STOP, followed by a SPACE.
52
53 =item Command C<\sourcecode{filename}>
54
55 This filter script puts content of external plain text file
56 as C<verbatim> block, in place <\sourcecode> pseudo-command happens.
57
58 =back
59
60 Note that input document must be written in ISO-2022-JP.
61
62 =head1 AUTHOR
63
64 Wakaba <w@suika.fam.cx>
65
66 =head1 LICENSE
67
68 Copyright 2004 Wakaba <w@suika.fam.cx>
69
70 This program is free software; you can redistribute it and/or
71 modify it under the same terms as Perl itself.
72
73 =cut
74
75 # $Date:$

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24