Skip to content

Instantly share code, notes, and snippets.

@osamu2001
Created January 18, 2010 08:33
Show Gist options
  • Save osamu2001/279886 to your computer and use it in GitHub Desktop.
Save osamu2001/279886 to your computer and use it in GitHub Desktop.
#!/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/</&lt;/g;
$h =~ s/>/&gt;/g;
$h =~ s/&/&amp;/g;
$c =~ s/</&lt;/g;
$c =~ s/>/&gt;/g;
$c =~ s/&/&amp;/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/</&lt;/g;
$cat =~ s/>/&gt;/g;
$cat =~ s/&/&amp;/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