1 # orgcard2txt.pl - a script to generate orgcard.txt from orgcard.tex
2 # Copyright (C) 2010 Osamu OKANO
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # perl orgcard2txt.pl orgcard.tex > orgcard.txt
27 $s =~ s/\\kbd{([^}]+)}/$1/g;
28 $s =~ s/\$\^([0-9])\$/[$1]/g;
40 $s =~ s/\$\\leftrightarrow\$/<->/g;
41 $s =~ s/\$\\pm 1\$/±1/g;
42 $s =~ s/``{\\tt ([^}]+)}''/`$1'/g;
51 $orgversionnumber = $1 if /\\def\\orgversionnumber{([^}]+)}/;
56 ================================================================================
57 Org-Mode Reference Card (for version $orgversionnumber)
58 ================================================================================
65 @
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
77 next if /Org-Mode Reference Card \([12]\/2\
)/;
78 next if /\\centerline{\(for version \\orgversionnumber\)}/;
79 next if /\(for version \)/;
80 next if /\\newcolumn/;
81 next if /\\copyrightnotice/;
83 next if /\\title{([^}]+)}/;
88 if (/\\section{(.+)}/){
89 my $sec = rep_esc
($1);
90 print "================================================================================\n";
92 print "================================================================================\n";
97 print "--------------------------------------------------------------------------------\n";
99 print "--------------------------------------------------------------------------------\n";
103 my $it = rep_esc
($1);
104 print "--------------------------------------------------------------------------------\n";
106 print "--------------------------------------------------------------------------------\n";
109 if(/^\\key{(.+)}\s*$/||/^\\metax{(.+)}\s*$/){
110 my ($k,$v) = split(/}{/,$1);
111 my $k2 = &rep_esc
($k);
112 my $v2 = &rep_esc
($v);
113 # print "$k2\t$v2\n";
114 ($key,$value)=($k2,$v2);
118 my $line = rep_esc
($_);
119 $line =~ s/{\\it ([^}]+)}/$1/g;
120 $line =~ s/{\\tt ([^}]+)}/$1/g;