summaryrefslogtreecommitdiff
path: root/veracrypt/debian/veracrypt_help_to_troff.pl
blob: 359158df27831a53f18f0a39a7b4d6acdacc99d2 (plain)
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
54
55
56
57
58
59
60
61
#!/usr/bin/perl -w
use strict;

open(OUT, ">&STDOUT") or die "Couldn't dup STDOUT: $!";
open(IN,  "<&STDIN" ) or die "Couldn't dup STDIN : $!";

print OUT ".TH VERACRYPT 1\n";
print OUT ".SH NAME\n";
print OUT "veracrypt \\- create and mount VeraCrypt encrypted volumes\n";

my $section = "";

while(my $line = <IN>)
{
  if ($line =~ m/^([a-z_]+):$/i)
  {
    $section= lc($1);
  }

  my $out = $line;

  if ($line =~ m/^[a-z_]+:$/i)
  {
    $line =~ s/://;
    $line = ".SH " . $line;

    $out = uc($line);
  }
  elsif ($section eq "synopsis")
  {
    $line =~ s/([A-Z_]+)/\\fI$1\\fP/g;
    $out = $line."\n";
  }
  elsif ($section eq "examples")
  {
    if ($line =~ m/^.*:$/)
    {
      $out = ".PP\n.B $line";
    }
    elsif ($line =~ m/.+/)
    {
      $out = ".nf\n$line.fi\n";
    }
  }
  elsif ($line =~ m/^-/)
  {
    $out = ".TP\n.B ".$line;
  }

  # In general, the hyphen-minus is meant to be a minus.
  $out =~ s/-/\\-/g;
  print OUT $out
}

print OUT ".SH COPYRIGHT\n";
print OUT "VeraCrypt is \\(co 2012 TrueCrypt Developers Association. All rights reserved.\n";

print OUT ".PP\nThis manual page was automatically generated from the output of \\fBveracrypt \\-\\-help\\fP\n";

close(IN);
close(OUT);
bgstack15