]> wagner.pp.ru Git - fiction/Kate-the-Empress.git/commitdiff
Kate-the-Empress.fb2 validates
authorVictor Wagner <vitus@wagner.pp.ru>
Wed, 13 Nov 2013 17:18:48 +0000 (21:18 +0400)
committerVictor Wagner <vitus@wagner.pp.ru>
Wed, 13 Nov 2013 17:18:48 +0000 (21:18 +0400)
Makefile
Tex2fb2
fb2meta.xml

index c6aa90e0af2fcfa86b3995c841450e839308b002..bef816b0d1a67aabd5a7efb37d6c6aff299f45bc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -12,10 +12,14 @@ Kate-the-Empress.html: onefile.tex
 Kate-the-Empress.epub: onefile.tex
        pandoc  -t epub --standalone -o $@ $+
 
-Kate-the-Empress.fb2.zip: onefile.zip
-       ./Tex2fb2 fb2meta.xml onefile.tex >Kate-the-Empress.fb2
+Kate-the-Empress.fb2.zip: Kate-the-Empress.fb2
        zip Kate-the-Empress.fb2.zip Kate-the-Empress.fb2
-       rm Kate-the-Empress.fb2
+
+Kate-the-Empress.fb2: onefile.tex Tex2fb2 fb2meta.xml
+       ./Tex2fb2 fb2meta.xml onefile.tex >Kate-the-Empress.fb2
+
+fb2lint: Kate-the-Empress.fb2 $(wildcard *.xsd)
+       xmllint --schema FictionBook2.1.xsd Kate-the-Empress.fb2 >/dev/null 2>$@
 
 onefile.tex: joinfiles.awk $(wildcard *.tex)
        awk -f joinfiles.awk book.tex >  $@
diff --git a/Tex2fb2 b/Tex2fb2
index 929e9576444bef247c3bd5b14ef17ab39410c098..12f50da94cbca1d0b11758a5f6f08b85455a621d 100755 (executable)
--- a/Tex2fb2
+++ b/Tex2fb2
@@ -81,7 +81,7 @@ s/\s+$//;
 s/(\s)\s+/$1/g;
 #replace TeX ligatures ~ --- << >> \% with appropriate unicode symbols
 s/~/\xA0/g;
-s/---/-/g;
+s/---//g;
 s/<</«/g;
 s/>>/»/g;
 s/\\%/%/g;
@@ -114,12 +114,15 @@ while (@sections) {
 }
 print "</body>\n";
 ## print footnotes
-print "<body id=\"notes\">\n$footnotes\n</body>" if $footnotes;
+print "<body>\n$footnotes\n</body>" if $footnotes;
 print "</FictionBook>";
 
 sub add_to_section {
        my $data = shift;
        return if ($#sections<0) ;
+       if ($data =~ /^\s*<section>/ && $sections[$#sections]->{data} !~ /^\s*<section>/) {
+               $sections[$#sections]->{data} = tag($sections[$#sections]->{data},"section")."\n";
+       }       
        $sections[$#sections]->{data}.=$data;
 }
 
@@ -130,7 +133,11 @@ sub flushsection {
        if ($str->{title}) {
                $content = tag($str->{title},"title");
        }
-       $content .=  $str->{data};
+       if ($str->{data} =~ /^\s*$/s) {
+               $content .= "<p>\n</p>";
+       } else {
+               $content .=  $str->{data};
+       }
        if ($#sections >=0) {
                add_to_section(tag($content,$tag)."\n");
        } else {
@@ -158,7 +165,8 @@ sub pushsection {
 
 sub tag {
        my ($content,$name) = @_;
-       return "" if $content =~ /^\s*$/s;
+       $content =~s/^\s+//s;
+       return "" unless $content;
        return "<$name>$content</$name>";
 }
 
index 613c30bef9aeaebe00725c640cce8d39f5ca6f98..1caa5168b6360953d5b897de34f7cecd132203c7 100644 (file)
 него одного.</p>
 </annotation>
 <date value="2014-01-01">1994-2014</date>
-<coverpage />
 <lang>ru</lang>
 </title-info>
 <document-info>
+<author><first-name>Виктор</first-name><last-name>Вагнер</last-name></author>
 <program-used>Perl</program-used>
+<date value="2013-11-12">12.11.2013</date>
 <src-url>http://www.wagner.pp.ru/~vitus/fiction</src-url>
+<id>00000</id>
+<version>0.8</version>
 </document-info>
+
 </description>