Aozora2Epub

 view release on metacpan or  search on metacpan

lib/Aozora2Epub/XHTML.pm  view on Meta::CPAN

    my $utf8 = decode('euc-jp-2004', $euc);
    return $utf8;
}

sub kindle_jis2chr {
    my ($men, $ku, $ten) = @_;

    # 半濁点付きカタカナ フ kindleだと2文字に見えるのなんとかならんか?
    return if $men == 1 && $ku == 6 && $ten == 88;

    # kindle font of these characters are broken.
    return if $men == 1 && $ku == 90 && $ten == 61;
    return if $men == 2 && $ku == 15 && $ten == 73;
    return jisx0213_to_utf8($men, $ku, $ten);
}

# kindle font of these characters are broken.
our %kindle_broken_font_unicode = map { $_ => 1 } (
    0x2152,
    0x2189,
    0x26bd,
    0x26be,
    0x3244,
);

our %kindle_ok_font_over0xffff = map { $_ => 1 } (
    0x20d58, 0x20e97, 0x20ed7, 0x210e4, 0x2124f, 0x2296b,
    0x22d07, 0x22e42, 0x22feb, 0x233fe, 0x23cbe, 0x249ad,
    0x24e04, 0x24ff2, 0x2546e, 0x2567f, 0x259cc, 0x2688a,
    0x279b4, 0x280e9, 0x28e17, 0x29170, 0x2a2b2,
);

sub kindle_unicode_hex2chr {
    my $unicode_hex = shift;
    my $unicode = hex($unicode_hex);

    return if $kindle_broken_font_unicode{$unicode};

    # kindle font is almost not avaliable in this range.
    return if $unicode > 0xffff && !$kindle_ok_font_over0xffff{$unicode};

    return chr($unicode);
}

sub _conv_gaiji_title_author {
    my ($unicode, $men, $ku, $ten) = @_;
    if ($unicode) {
        my $ch = kindle_unicode_hex2chr($unicode);
        return $ch if $ch;
        return;

share/basic/EPUB/styles/style.css  view on Meta::CPAN

}

.dogyo-o-midashi { display:inline;}
.dogyo-naka-midashi { display:inline;}
.dogyo-ko-midashi { display:inline;}
.mado-o-midashi { display:inline;}
.mado-naka-midashi { display:inline;}
.mado-ko-midashi {
    display: inline;
    margin:0; padding:0;
    font-size: 1.1em;
}

figure {
    writing-mode: horizontal-tb;
    -epub-writing-mode: horizontal-tb;
    -webkit-writing-mode: horizontal-tb;
}

figure figcaption {
    text-align: center;
}

h1.tobira {
    padding-right: 3em; 
    padding-top: 3em;
    font-size: 1.2em;
}

h1 {
    padding-top: 3em;
    font-size: 1.2em;
    padding-right: 1em;
}

h2 {
    padding-top: 4em;
    font-size: 1.1em;
    padding-right: 1em;
}

.subscript { font-size: small; }
.superscript { font-size: small; }
.kaeriten { font-size: small; }
.okurigana { font-size: small; }

span.notes {font-size: 0.8em;}
img.gaiji { width: 1em; height: 1em; align: top; }

.gaiji_list {margin-left: 3em;}

.keigakomi {border: solid 1px;}
div.keigakomi{padding-top: 0.5em;
              padding-bottom: 0.5em;
              padding-right: 0.5em;
              padding-left: 1em;}

.futoji { font-weight: bold;}
.shatai { font-style: italic;}

.sesame_dot {
    font-style: normal;
    text-emphasis-style: filled sesame;
    -webkit-text-emphasis-style: filled sesame;
    -epub-text-emphasis-style: filled sesame;
}

.white_sesame_dot {
    font-style: normal;
    text-emphasis-style: open sesame;
    -webkit-text-emphasis-style: open sesame;
    -epub-text-emphasis-style: open sesame;
}

.black_circle {
    font-style: normal;
    text-emphasis-style: filled circle;
    -webkit-text-emphasis-style: filled circle;
    -epub-text-emphasis-style: filled circle;
}

.white_circle {
    font-style: normal;
    text-emphasis-style: open circle;
    -webkit-text-emphasis-style: open circle;
    -epub-text-emphasis-style: open circle;
}

.black_up-pointing_triangle {
    font-style: normal;
    text-emphasis-style: filled triangle;
    -webkit-text-emphasis-style: filled triangle;
    -epub-text-emphasis-style: filled triangle;
}

.white_up-pointing_triangle {
    font-style: normal;
    text-emphasis-style: open triangle;
    -webkit-text-emphasis-style: open triangle;
    -epub-text-emphasis-style: open triangle;
}

.saltire {
    font-style: normal;
    text-emphasis-style: 'x'
    -webkit-text-emphasis-style: 'x';
    -epub-text-emphasis-style: 'x';
}

.underline_solid  {
    font-style: normal;
    text-decoration: underline solid;
}

.underline_double {
    font-style: normal;
    text-decoration: underline double;
}

.underline_dotted {
    font-style: normal;
    text-decoration: underline dotted;
}

.underline_dashed {
    font-style: normal;
    text-decoration: underline dashed;
}

.underline_wave   {
    font-style: normal;
    text-decoration: underline wavy;
}

.overline_solid  {
    font-style: normal;
    text-decoration: overline solid;
}

.overline_double {
    font-style: normal;
    text-decoration: overline double;
}

.overline_dotted {
    font-style: normal;
    text-decoration: overline dotted;
}

.overline_dashed {
    font-style: normal;
    text-decoration: overline dashed;
}

.overline_wave   {
    font-style: normal;
    text-decoration: overline wavy;
}

share/basic/EPUB/text/okuzuke.xhtml  view on Meta::CPAN

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="ja-JP" xml:lang="ja-JP">
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="aozora2epub" />
  <title><: $name :></title>
  <style>
    div.okuzuke { font-size: 0.7em; }
    h5 { font-size: 1em; margin:1.75em 0 0.5em 0; padding:0; }
  </style>
</head>
<body epub:type="bodymatter">
<section id="start" class="level1 unnumbered">
<div class="okuzuke">
  <: $bib_info :>
</div>
</section>
</body>
</html>

share/basic/EPUB/text/title_page.xhtml  view on Meta::CPAN

  <meta charset="utf-8" />
  <meta name="generator" content="aozora2epub" />
  <title><: $title :></title>
  <style>
    .title { margin-top: 3em; text-align: center; }
    .author { margin-top: 4em; text-align: center; }
    #aozora {
	margin-bottom: 5em;
	width: 100%;
	text-align: center;
	font-size: 0.8em;
    }
  </style>
</head>
<body epub:type="frontmatter">
<section epub:type="titlepage" class="titlepage">
  <div id="aozora">青空文庫</div>    
  <h1 class="title"><: $title :></h1>
  <p class="author"><: $author :></p>

</section>

share/basic/EPUB/toc.xhtml  view on Meta::CPAN

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="ja-JP" xml:lang="ja-JP">
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="aozora2epub" />
  <title><: $title :></title>
  <style>
    h1 { font-size: 1.25em; }
    div.level1 { margin-top: 2em; }
    div.level2 { margin-top: 4em; }
  </style>
  <link rel="stylesheet" type="text/css" href="styles/style.css" />
</head>
<body epub:type="bodymatter">
  <h1>目次</h1>
  : for $sections -> $s {
      <div class="level1"><a href="text/<: $s.file :>.xhtml#<:$s.id :>"><: $s.title :></a></div>
    : if $s.children  {

share/basic/META-INF/com.apple.ibooks.display-options.xml  view on Meta::CPAN

<?xml version="1.0" encoding="UTF-8"?>
<display_options>
  <platform name="*">
    <option name="specified-fonts">true</option>
  </platform>
</display_options>

t/gaiji-replace.t  view on Meta::CPAN

ああ<span class="notes">[#「さんずい+鼾のへん」、第4水準2-79-37]</span>
--- expected
ああ<span class="notes">[#「さんずい+鼾のへん」、第4水準2-79-37]</span>

=== image gaiji in rb
--- html
博物学者は<ruby><rb>※<img src="../../../gaiji/1-91/1-91-65.png" alt="※(「虫+斯」、第3水準1-91-65)" class="gaiji" /></rb><rp>(</rp><rt>けむし</rt><rp>)</rp></ruby><span class="notes">[#「虫+占」、U+86C5、18-5]</...
--- expected
博物学者は<ruby><rb>\x{86c5}\x{87d6}</rb><rp>(</rp><rt>けむし</rt><rp>)</rp></ruby>の変じ

=== kindle font broken jis
--- html
<img src="../../../gaiji/1-90/1-90-61.png" />
--- expected
<img src="../gaiji/1-90/1-90-61.png" />

=== kindle font broken jis 2
--- html
<img src="../../../gaiji/2-15/2-15-73.png" />
--- expected
<img src="../gaiji/2-15/2-15-73.png" />

=== kindle font broken jis 3
--- html
<img src="../../../gaiji/1-06/1-06-88.png" />
--- expected
<img src="../gaiji/1-06/1-06-88.png" />

=== kindle font broken unicode
--- html
※<span class="notes">[#「あああ」、U+2152、369-2]</span>
--- expected
※<span class="notes">[#「あああ」、U+2152、369-2]</span>

=== kindle font broken unicode 2
--- html
※<span class="notes">[#「あああ」、U+2189、369-2]</span>
--- expected
※<span class="notes">[#「あああ」、U+2189、369-2]</span>

=== kindle font broken unicode 3
--- html
※<span class="notes">[#「あああ」、U+26BD、369-2]</span>
--- expected
※<span class="notes">[#「あああ」、U+26BD、369-2]</span>

=== kindle font broken unicode 4
--- html
※<span class="notes">[#「あああ」、U+26BE、369-2]</span>
--- expected
※<span class="notes">[#「あああ」、U+26BE、369-2]</span>

=== kindle font broken unicode 5
--- html
※<span class="notes">[#「あああ」、U+3244、369-2]</span>
--- expected
※<span class="notes">[#「あああ」、U+3244、369-2]</span>

=== kindle font broken unicode over 0xffff
--- html
※<span class="notes">[#「あああ」、U+1F130、369-2]</span>
--- expected
※<span class="notes">[#「あああ」、U+1F130、369-2]</span>

=== kindle font broken unicode over 0xffff but ok
--- html
※<span class="notes">[#「あああ」、U+2a2b2、369-2]</span>
--- expected
\x{2a2b2}

t/gaiji-title-author.t  view on Meta::CPAN

(2[#「2」はローマ数字、1-13-22])
--- expected
(\x{2161})

=== unicode
--- input
たま※[#「ころもへん+攀」、U+897B]
--- expected
たま\x{897b}

=== unicode bad font
--- input
失※[#「人がしら/二/心」、U+2B779、表紙]術講義
--- expected
失※[#「人がしら/二/心」、U+2B779、表紙]術講義
--- note
2b779はkindleだと豆腐になる

=== no chuuki
--- input
あいうえお



( run in 2.450 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )