File: wikispaces2markdown.pl

package info (click to toggle)
libmojomojo-perl 1.11%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,496 kB
  • ctags: 927
  • sloc: perl: 14,671; sh: 148; xml: 120; makefile: 8; ruby: 6
file content (32 lines) | stat: -rw-r--r-- 797 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/perl -w

use strict;
use FindBin '$Bin';
use lib "$Bin/../lib";
use Text::Wikispaces2Markdown;

if (not @ARGV) {
    die "USAGE: $0 <textile_files>
For each Wikispaces input file, will output a Markdown file with the same name and a .markdown extension
";
}

for my $filename (@ARGV) {
    open my $file_in, '<', $filename or die $!;
    my $text = do {local $/; <$file_in>};

    my ($filename_out) = $filename =~ /^(.*?) ((?<=.)\.[^.\/:\\]+)?$/x;  # basename (path+file) and extension

    open my $file_out, '>', "$filename_out.markdown" or die $!;
    print $file_out Text::Wikispaces2Markdown::convert($text) or die $!;
}

=head1 NAME

wikispaces2markdown.pl - rough draft of converting wikispaces to markdown

=head1 AUTHOR

Dan Dascalescu (dandv), http://dandascalescu.com

=cut