/[pub]/suikawiki/wikidata/migration/grep2swml.pl
Suika

Contents of /suikawiki/wikidata/migration/grep2swml.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Tue May 4 00:56:31 2010 UTC (14 years, 6 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
added to the repository

1 wakaba 1.1 #!/usr/bin/perl
2     use strict;
3     use warnings;
4    
5     use Encode::EUCJPSW;
6    
7     my @entry;
8     while (<>) {
9     if (s/^([^:]+)://) {
10     my $path = $1;
11     if ($path =~ s[^page/][]) {
12     $path =~ s/\.txt$//;
13     $path =~ s[\.ns/][//]g;
14     $path =~ s/([0-9A-Fa-f]{2})/pack 'C', hex $1/ge;
15     $path = Encode::decode ('euc-jp-sw', $path);
16     $path = "[[$path]]";
17     }
18     push @entry, [$path, Encode::decode ('euc-jp-sw', $_)];
19     } else {
20     warn $_;
21     }
22     }
23    
24     sub e ($) {
25     my $s = shift;
26     $s =~ s/([\[\]']|^[,-=*])/+{qw[' 1 , 1 - 1 = 1 * 1]}->{$1} ? "[SPAN[$1]]" : "'''$1'''"/ge;
27     return $s;
28     } # e
29    
30     binmode STDOUT, ':encoding(utf8)';
31     for (1..$#entry) {
32     printf "[%d] %s\n[PRE(code)[\n%s]PRE]\n\n", $_, $entry[$_]->[0], e ($entry[$_]->[1]);
33     }

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24