comparison DESpecs/skripte/create_overview_text.pl @ 31:edf6e8fcf323 default tip

Removing DESpecs directory which deserted to git
author Klaus Thoden <kthoden@mpiwg-berlin.mpg.de>
date Wed, 29 Nov 2017 16:55:37 +0100
parents 69b5769db3f9
children
comparison
equal deleted inserted replaced
30:69b5769db3f9 31:edf6e8fcf323
1 #!/usr/bin/perl -w
2 use strict;
3 use warnings;
4
5 #
6 # create_overview_text2.pl
7 #
8 # Wolfgang Schmidle, 2008-10-06
9 #
10
11
12 my @datei;
13
14 while (<>)
15 {
16 push @datei, $_;
17 }
18
19
20 # Bestimme die neuen Dateinamen:
21 # Aus "dateiname.tex" wird "dateiname_overview.tex".
22 # Wenn der alte Dateiname nicht auf ".tex" endet, wird einfach "_neu.tex" angehängt.
23
24 $_ = $ARGV;
25 /^(.+?)(\.TEX|\.tex)?$/;
26 my $neuerDateiname = "$1_overview.tex";
27
28
29 my @neueDatei;
30
31 my $sollweg = 0;
32 my $leerzeile = 0;
33
34 my $unwichtig = ' mainruleLessImportant clarification note ';
35 $unwichtig .= ' example exampleTest sampleImage smallSampleImage ';
36 $unwichtig .= ' crossref exception ';
37 $unwichtig .= ' tabelle liste ';
38
39 foreach (@datei)
40 {
41 next if (/^%/ && !(/%!TEX/)); # remove comment lines, keep the header lines,
42 s/\.tex/_overview.tex/; # but add _overview to the reference
43
44 next if /^\\vspace/;
45 next if /^\\tocspace/;
46 next if /^\\clearpage/;
47 next if /^\\mehrzeilen/;
48
49 s/^%overview //; # commands for the overview document
50 # that are ignored in the main document
51
52 # remove all unwanted enviromnents, e.g. clarification
53 if (/\\begin\{(.+?)\}/)
54 {
55 if ($unwichtig =~ / $1 /) { $sollweg = 1; }
56 }
57 unless ($sollweg)
58 {
59 if (/^ *$/) { $leerzeile++; } else { $leerzeile = 0; }
60 push @neueDatei, $_ unless $leerzeile > 1;
61 }
62 if (/\\end\{(.+?)\}/)
63 {
64 if ($unwichtig =~ / $1 /) { $sollweg = 0; }
65 }
66 }
67
68 for my $i (0..$#neueDatei-2)
69 {
70 my $offset = 2;
71 $_ = $neueDatei[$i+1];
72 if (/\\label/) { $offset++; }
73
74 $_ = $neueDatei[$i];
75 if (/\\section/)
76 {
77 $_ = $neueDatei[$i+$offset];
78 if (/^ *$/ || /\\section/)
79 {
80 # $neueDatei[$i] =~ s/\{(.+?)\}/\{($1)\}/;
81 $neueDatei[$i] = "% $neueDatei[$i]";
82 $neueDatei[$i] .= '\refstepcounter{section}';
83 $neueDatei[$i] .= "\n";
84 }
85 }
86 else
87 {
88 if (/\\subsection/)
89 {
90 $_ = $neueDatei[$i+$offset];
91 if (/^ *$/ || /\\section/ || /\\subsection/)
92 {
93 # $neueDatei[$i] =~ s/\{(.+?)\}/\{($1)\}/;
94 $neueDatei[$i] = "% $neueDatei[$i]";
95 $neueDatei[$i] .= '\refstepcounter{subsection}';
96 $neueDatei[$i] .= "\n";
97 }
98 }
99 else
100 {
101 if (/\\subsubsection/)
102 {
103 $_ = $neueDatei[$i+$offset];
104 if (/^ *$/ || /\\section/ || /\\subsection/ || /\\subsubsection/)
105 {
106 # $neueDatei[$i] =~ s/\{(.+?)\}/\{($1)\}/;
107 $neueDatei[$i] = "% $neueDatei[$i]";
108 $neueDatei[$i] .= '\refstepcounter{subsubsection}';
109 $neueDatei[$i] .= "\n";
110 }
111 }
112 }
113 }
114 }
115
116 # Schreibe das Ergebnis in die Datei $neuerDateiname im gleichen Verzeichnis wie die alte Datei.
117 # Eine bereits vorhandene Datei mit gleichem Namen wird ohne Warnung überschrieben.
118
119 open (NEUEDATEI, ">$neuerDateiname");
120 print NEUEDATEI @neueDatei;
121 close (NEUEDATEI);