File: patchlatexverb

package info (click to toggle)
c++-annotations 11.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 11,244 kB
  • sloc: cpp: 21,698; makefile: 1,505; ansic: 165; sh: 121; perl: 90
file content (53 lines) | stat: -rwxr-xr-x 893 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl

$mark_in =  '\\\\begin\{verbatim}';
$mark_out = '\\\\end\{verbatim}';

sub process_marked
{
    if ($line =~ /(.*)$mark_in\s*/)
    {
        marked_section();
    }
    else
    {
        print $line;
    }
}

sub marked_section
{
    @marked = ($line);

    while ($line = <>)
    {
        push @marked, "$line";
        last if  $line =~ /$mark_out/;
    }
    
    print $marked[0];
    for ($from = 1; $marked[$from] =~ /^\s*$/; $from++)     # $from: at 1st to
    {}                                                      # print

    for ($to = $#marked - 1; $marked[$to] =~ /^\s*$/; $to--)# $to: last to pnt
    {}

    for ( ; $from <= $to; $from++)
    {
        print $marked[$from];
    }
    
    print $marked[$#marked];

    while ($line = <>)
    {
        last if  $line !~ /^\s*$/;
    }

    process_marked();
}

while ($line = <>)
{
    process_marked();
}