From d2929ecef2acf9faa957b4bffd76f808fe8f8e52 Mon Sep 17 00:00:00 2001 From: Victor Wagner Date: Sat, 21 Dec 2013 15:33:42 +0400 Subject: [PATCH] Tex2fb2 with cover page support --- Tex2fb2 | 23 +++++++++++++++++++++++ fb2meta.xml | 1 + 2 files changed, 24 insertions(+) diff --git a/Tex2fb2 b/Tex2fb2 index 3098808..96279b3 100755 --- a/Tex2fb2 +++ b/Tex2fb2 @@ -1,6 +1,7 @@ #!/usr/bin/perl -CDS use utf8; use POSIX qw(strftime); +use MIME::Base64; # char-level modes my $poetry = 0; my $verbatim = 0; @@ -19,6 +20,7 @@ print "\n"; my $metadata = shift @ARGV; open F,"<",$metadata; +my $pics = ""; while () { # Replace empty date with current date if (// || /\s*<\/date>/) { @@ -30,6 +32,15 @@ while () { my $ver = $1+time()/1E10; $_=tag(sprintf("%g",$ver),"version")."\n"; } + # Если существует cover.png, добавляем coverpage + if (//) { + $_=""; + if (-f "cover.png") { + my $id = "cover_png"; + $_ = "\n\n\n"; + $pics .= mkbinary("cover.png",$id); + } + } print $_; } close F; @@ -137,6 +148,7 @@ while (@sections) { print "\n"; ## print footnotes print "\n$footnotes\n" if $footnotes; +print $pics; print ""; sub add_to_section { @@ -207,3 +219,14 @@ sub push_footnote { $footnotes.="
".tag(shift,'p')."
\n"; return "$idseq"; } + +sub mkbinary { + my ($filename,$id) = @_; + my $f; + open $f,"<",$filename; + binmode $f; + local $/; + my $data = encode_base64(<$f>); + return "$data\n"; + close $f; +} diff --git a/fb2meta.xml b/fb2meta.xml index f1d2f9d..058f114 100644 --- a/fb2meta.xml +++ b/fb2meta.xml @@ -21,6 +21,7 @@ него одного.

1994-2014 + ru -- 2.39.5