Created
January 18, 2010 08:33
-
-
Save osamu2001/279886 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/perl | |
# ref:http://paranoids.sakura.ne.jp/kaworu/2007-12-31-2.php | |
use strict; | |
use warnings; | |
use ChangeLogReader; | |
my $stop_date = "0"; | |
my $cl = ChangeLogReader->new(stop_date => $stop_date); | |
my $fname = "ChangeLog.home"; | |
$cl->store_changelog_file($fname); | |
&print_head; | |
foreach my $ymd (sort keys %{$cl->{all}}) { | |
my $ent = \%{$cl->{all}->{$ymd}}; | |
for (my $i = $ent->{curid}; $i >= 1; $i--) { | |
my $h = $ent->{$i}->{ho}; | |
my $c = $ent->{$i}->{co}; | |
print "\n"; | |
$h =~ s/</</g; | |
$h =~ s/>/>/g; | |
$h =~ s/&/&/g; | |
$c =~ s/</</g; | |
$c =~ s/>/>/g; | |
$c =~ s/&/&/g; | |
print "<note>\n"; | |
print "<title>$h</title>"; | |
print "\n"; | |
&print_note_head; | |
print "<div>$h</div>\n"; | |
my @list = split(/\n/, $c); | |
foreach(@list){ | |
print "<div>$_</div>\n"; | |
} | |
print "</en-note>]]></content>\n"; | |
my $t = $ymd; | |
$t =~ s/-//g; | |
print "<created>${t}T000000Z</created>\n"; | |
print "<updated>${t}T000000Z</updated>\n"; | |
if (defined $ent->{$i}->{cat}){ | |
foreach my $cat(@{$ent->{$i}->{cat}}){ | |
$cat =~ s/</</g; | |
$cat =~ s/>/>/g; | |
$cat =~ s/&/&/g; | |
print "<tag>${cat}</tag>\n"; | |
} | |
} | |
print "</note>\n\n"; | |
} | |
} | |
print "</en-export>\n"; | |
sub print_note_head(){ | |
print << "HOGE"; | |
<content><![CDATA[<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml.dtd"> | |
<en-note> | |
HOGE | |
} | |
sub print_head(){ | |
print << "HOGE"; | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export.dtd"> | |
<en-export export-date="20100101T000000Z" application="Evernote/Windows" version="3.5"> | |
HOGE | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment