Remove unused convert_entities function
[project-aon.git] / common / scripts / gbtoepub.pl
index 810b5e6..93586eb 100755 (executable)
@@ -17,7 +17,10 @@ my $TAR        = qx{which tar};
 my $ZIP        = qx{which zip};
 my $BZIP2      = qx{which bzip2};
 my $JAVA       = qx{which java};
+# Note: In Debian/Ubuntu the Xalan processor is provided in the package libxalan2-java
 my $XALAN_JAR  = '/usr/share/java/xalan2.jar';
+# Old version of Xalan processor (Xalan 1)
+#my $XALAN_JAR  = '/usr/share/ant/lib/xalan.jar';
 my $RM         = qx{which rm};
 my $CHMOD      = qx{which chmod};
 
@@ -64,7 +67,7 @@ my $ncxXSL       = 'common/xsl/epub-ncx.xsl';
 my $epubXSL      = 'common/xsl/epub-xhtml.xsl';
 my $metadataXSL  = 'common/xsl/epub-opf-metadata.xsl';
 my $spineXSL     = 'common/xsl/epub-opf-spine.xsl';
-my $fontFiles    = "$ENV{'HOME'}${FILENAME_SEPARATOR}souvenir";
+my $fontFiles    = "common/fonts";
 my $language     = 'en';
 
 my $verbose = 0;
@@ -233,7 +236,7 @@ foreach my $cssTemplate (split( /:/, $rulesHash{'csst'} )) {
 unless( -e $fontFiles && -d $fontFiles ) {
     die "$PROGRAM_NAME: font files directory does not exist or is not a directory \"$fontFiles\": $!\n";
 }
-print qx{$CP $fontFiles${FILENAME_SEPARATOR}*.otf $outPath{'oebps'}};
+print qx{$CP $fontFiles${FILENAME_SEPARATOR}*tf $outPath{'oebps'}};
 
 ### write NCX file
 
@@ -482,125 +485,6 @@ sub get_series_number {
     return $series_number;
 }
 
-# Determine the book title by reading the book meta information
-sub find_title {
-    my ($book) = @_;
-    my $title = ""; my $line = "";
-    open (BOOK, "head -100 $book | ") || die ("Could not read $book: $!");
-    while ($title eq "" && ( $line = <BOOK> ) ) {
-        chomp $line;
-        if ( $line =~ /<title>(.*?)<\/title>/ ) {
-            $title = $1;
-        }
-    }
-    close BOOK;
-
-    if ( $title eq "" ) {
-        print STDERR "WARN: Cannot find title for book '$book'\n";
-        $title = "[Undefined]";
-    }
-
-    return convert_entities($title);
-}
-
-# Determine the book author by reading the book meta information
-sub find_author {
-    my ($book) = @_;
-    my $author = ""; 
-    my $line = "";
-    open (BOOK, "head -100 $book |") || die ("Could not read $book: $!");
-
-    my $find_line = 0;
-    while ($author eq "" && ( $line = <BOOK> ) ) {
-        chomp $line;
-        if ( $find_line == 1 && $line =~ /<line>(.*?)<\/line>/ ) {
-            $author = $1;
-        }
-        $find_line = 1 if ( $line =~ /<creator class="medium">/ );
-        $find_line = 0 if ( $line =~ /<\/creator>/ );
-        if ( $line =~ /<creator class="author">(.*?)<\/title>/ ) {
-            $author = $1;
-        }
-    }
-    close BOOK;
-
-    if ( $author eq "" ) {
-        print STDERR "WARN: Cannot find author for book '$book'\n";
-        $author = "[Undefined]";
-    }
-
-
-    return $author;
-}
-
-# Determine the book illustrator by reading the book meta information
-sub find_illustrator {
-    my ($book) = @_;
-    my $illustrator = "";
-    my $line = "";
-    open (BOOK, "head -100 $book | ") || die ("Could not read $book: $!");
-
-    my $find_line = 0;
-    while ($illustrator eq "" && ( $line = <BOOK> ) ) {
-        chomp $line;
-        if ( $find_line == 1 && $line =~ /<line>Illustrated by (.*?)<\/line>/ ) {
-            $illustrator = $1;
-        }
-        $find_line = 1 if ( $line =~ /<creator class="medium">/ );
-        $find_line = 0 if ( $line =~ /<\/creator>/ );
-        if ( $line =~ /<creator class="illustrator">(.*?)<\/title>/ ) {
-            $illustrator = $1;
-        }
-    }
-    close BOOK;
-
-    if ( $illustrator eq "" ) {
-        print STDERR "WARN: Cannot find illustrator for book '$book'\n";
-        $illustrator = "[Undefined]";
-    }
-    if ( $language eq "en" ) {
-        $illustrator = "Illustrated by ".$illustrator;
-    } elsif ( $language eq "es" ) {
-        $illustrator = "Illustrado por ".$illustrator;
-    }
-
-    return $illustrator;
-}
-
-sub convert_entities {
-# Convert character entities to their correspondent values
-    my ($text) = @_;
-
-    $text =~ s/\<ch.apos\/\>/'/g; 
-    $text =~ s/\<ch.nbsp\/\>/ /g;
-    $text =~ s/\<ch.plusmn\/\>/+-/g;
-    $text =~ s/\<ch.aacute\/\>/á/g;
-    $text =~ s/\<ch.eacute\/\>/é/g;
-    $text =~ s/\<ch.iacute\/\>/í/g;
-    $text =~ s/\<ch.oacute\/\>/ó/g;
-    $text =~ s/\<ch.uacute\/\>/ú/g;
-    $text =~ s/\<ch.ntilde\/\>/ñ/g;
-    $text =~ s/\<ch.Aacute\/\>/Á/g;
-    $text =~ s/\<ch.Eacute\/\>/É/g;
-    $text =~ s/\<ch.Iacute\/\>/Í/g;
-    $text =~ s/\<ch.Oacute\/\>/Ó/g;
-    $text =~ s/\<ch.Uacute\/\>/Ú/g;
-    $text =~ s/\<ch.auml\/\>/ä/g;
-    $text =~ s/\<ch.euml\/\>/ë/g;
-    $text =~ s/\<ch.iuml\/\>/ï/g;
-    $text =~ s/\<ch.ouml\/\>/ö/g;
-    $text =~ s/\<ch.uuml\/\>/ü/g;
-    $text =~ s/\<ch.Ntilde\/\>/Ñ/g;
-    $text =~ s/\<ch.acute\/\>/´/g;
-    $text =~ s/\<ch.iexcl\/\>/¡/g;
-    $text =~ s/\<ch.iquest\/\>/¿/g;
-    $text =~ s/\<ch.laquo\/\>/«/g;
-    $text =~ s/\<ch.raquo\/\>/»/g;
-    $text =~ s/\<ch.ampersand\/\>/&/g;
-
-    return $text;
-}
-
 # Quote metacaracters for shell use
 sub quote_shell {
     my ($text) = @_;