]> www.wagner.pp.ru Git - fiction/Kate-the-Empress.git/commitdiff
work on fb2 formatting
authorVictor Wagner <wagner@atlas-card.ru>
Wed, 13 Nov 2013 08:51:33 +0000 (12:51 +0400)
committerVictor Wagner <wagner@atlas-card.ru>
Wed, 13 Nov 2013 08:51:33 +0000 (12:51 +0400)
Tex2fb2 [changed mode: 0644->0755]
book.tex
fb2meta.xml [new file with mode: 0644]

diff --git a/Tex2fb2 b/Tex2fb2
old mode 100644 (file)
new mode 100755 (executable)
index 2fe0580..2d644df
--- a/Tex2fb2
+++ b/Tex2fb2
@@ -1,4 +1,5 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -CDS
+use utf8;
 # char-level modes
 my $poetry = 0;
 my $verbatim = 0;
@@ -21,6 +22,7 @@ while (<F>) {
 close F;
 
 my $header =1;
+LINE:
 while (<>) {
 $environ = undef;
 if (/\\(begin|end){(\w+)}/) {
@@ -40,25 +42,41 @@ if (/\\(begin|end){(\w+)}/) {
        }
 }
 next LINE if $header;
-if (/^$/ && $environ && $buffer) {
+if ((/^$/ || $environ) && $buffer) {
 #output on empty line (p or stanza) depending on poetry mode
        add_to_section(tag($buffer,$poetry?"stanza":"p"));
        $buffer="";
 }
 next LINE if $environ;
 # Section headings
-if (/\\(part|chapter|section|subsection|subsubsection){(.*)}/) {
+if (/\\(part|chapter|section|subsection|subsubsection)\*?{(.*)}/) {
+       if ($buffer) {
+               add_to_section(tag($buffer,$poetry?"stanza":"p"));
+               $buffer="";
+       }
        pushsection($1,$2);
+       next LINE;
+}
+if (/\\vspace{/) {
+       add_to_section("<empty-line />");
+       next LINE;
 }
 #normal mode: 
 if (!$verbatim) {
 #strip TeX comments 
 s/([^\\])%.*$/$1/;
+s/^%.*$//;
+# strip \sloppy
+s/\\sloppy\s+//g;
+s/\\sloppy{}//g;
+s/\\sloppy([^\w])/$1/g;
 #replace TeX ligatures ~ --- << >> \% with appropriate unicode symbols
 s/~/\xA0/g;
 s/---/-/g;
 s/<</«/g;
 s/>>/»/g;
+s/\\%/%/g;
+s/\\dots/\x{2026}/g;
 }
 #replace ' and " with entities
 s/&/&amp;/g;
@@ -78,6 +96,7 @@ if ($poetry) {
 }
 if ($buffer) {
        add_to_section(tag($buffer,"p"));
+       $buffer="";
 }
 
 while (@sections) {
@@ -128,5 +147,6 @@ sub pushsection {
 
 sub tag {
        my ($content,$name) = @_;
+       return "" if ($content eq "\n");
        return "<$name>$content</$name>";
 }
index f39082b85cdfba2dd1dae3b021eeb64e72f1ba28..4b77e635f6c95e4d89069004c3e3e47c47dbe5c4 100644 (file)
--- a/book.tex
+++ b/book.tex
@@ -56,9 +56,9 @@
 \stars
 \input abordage.tex
 \chapter{Пушки Рамета тал Фипса}
-\input{reward.tex}
+\input reward.tex
 \stars
-\input{empie.tex}
+\input empie.tex
 \stars
 \input no-duel.tex
 \stars
diff --git a/fb2meta.xml b/fb2meta.xml
new file mode 100644 (file)
index 0000000..5755035
--- /dev/null
@@ -0,0 +1,2 @@
+<description>
+</descrition>