From: Victor Wagner Date: Wed, 13 Nov 2013 17:18:48 +0000 (+0400) Subject: Kate-the-Empress.fb2 validates X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=34aa8ee96c682061235ff8355841c2f0c59c123f;p=fiction%2FKate-the-Empress.git Kate-the-Empress.fb2 validates --- diff --git a/Makefile b/Makefile index c6aa90e..bef816b 100644 --- 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 929e957..12f50da 100755 --- 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; @@ -114,12 +114,15 @@ while (@sections) { } print "\n"; ## print footnotes -print "\n$footnotes\n" if $footnotes; +print "\n$footnotes\n" if $footnotes; print ""; sub add_to_section { my $data = shift; return if ($#sections<0) ; + if ($data =~ /^\s*
/ && $sections[$#sections]->{data} !~ /^\s*
/) { + $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 .= "

\n

"; + } 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"; } diff --git a/fb2meta.xml b/fb2meta.xml index 613c30b..1caa516 100644 --- a/fb2meta.xml +++ b/fb2meta.xml @@ -21,11 +21,15 @@ него одного.

1994-2014 - ru +ВикторВагнер Perl +12.11.2013 http://www.wagner.pp.ru/~vitus/fiction +00000 +0.8 +