OSDN Git Service

wiki convert utils
[g15jp/utils.git] / conv.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use utf8;
5 use Encode;
6
7 my $file = $ARGV[0] || die;
8
9 open(IF, $file) || die;
10 $/ = undef;
11 my $text = <IF>;
12 close(IF);
13
14 $text = decode('utf8', $text);
15 $text =~ s/^\*/= /mg;
16 $text =~ s/^\*\*/== /mg;
17 $text =~ s/^\- /  * /mg;
18 $text =~ s/^\-- /    * /mg;
19 $text =~ s/^\--- /      * /mg;
20 $text =~ s/\[\[/[/g;
21 $text =~ s/\|/||/g;
22 $text =~ s/]]/]/g;
23 $text =~ s/~%/\n/g;
24 $text = encode('utf8', $text);
25
26 my $outd = 'converted';
27 mkdir $outd;
28 open(OF, "> $outd/$file") || die;
29 print OF $text;
30 close(OF);
31
32 1;
33