制作一本精品的电子书

2023.05.19 11:18

博客

Epub使用工具:Sigil,下载地址
文本校对工具:txtFormat

TXT小说文件准备

章节分章

格式优化

封面

css
body.bookcover {
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
  background-image: url(../Images/cover.jpg);
}
xhtml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>封面</title>
    <link href="../Styles/stylesheet.css" type="text/css" rel="stylesheet"/>
</head>

<body class="bookcover"/>
</html>

版权页

css
h2.booktitle {
  font-weight: bold;
  font-size: xx-large;
  text-indent: 0em !important;
  text-align: center;
  padding: 25% 5px 5px 5px;
}

p.bookversion {
  margin-top: 3em;
  color: #ffab18;
  font-weight: bold;
  font-size: medium;
  text-indent: 0em !important;
  text-align: center;
}

p.bookauthor {
  margin-top: 1em;
  text-indent: 0em !important;
  text-align: center;
}

p.bookauthor span {
  color: #e32d2d;
}

div.chubanshe {
    margin-top: 12em;
    text-align: center;
}

img.chaungshi {
    width: 290px;
    height: 121px;
}

img.qidian {
    width: 256px;
    height: 61px;
}
xhtml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>版权声明</title>
    <link href="../Styles/stylesheet.css" type="text/css" rel="stylesheet"/>
</head>

<body>
<h2 class="booktitle" title="版权声明">小说名称</h2>

<p class="bookversion">掌阅版</p>

<p class="bookauthor">作者 <span>著</span></p>

<div class="chubanshe">
    <img alt="qidian" class="qidian" src="../Images/qidian.png"/>
</div>
</body>
</html>

卷/章

css
h2.section {
  font-family: "ZY-LIBIAN", "方正隶变";
  font-size: 2.5em;
  padding-top: 3em;
  text-align: center;
  margin: 0 auto;
}

span.section-num {
  font-size: 0.8em;
  text-align: center;
}

h3.chapter,h2.chapter {
  padding: 0 4px 0 4px;
  /*margin: 1em auto 2em auto;*/
  margin: 10em auto 2em auto;
  font-size: 1.1em;
  color: #b50a02;
  text-align: center;
  line-height: 130%;
  text-indent: 0em;
}

span.num {
  padding: 2px 4px 2px 4px;
  font-size: small;
  text-align: center;
}

span.num-2 {
  padding: 2px 4px 2px 4px;
  font-size: small;
  text-align: center;
}
xhtml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>第一卷 卷名</title>
    <link href="../Styles/stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<h2 title="第一卷 卷名" class="section"><span>第一卷</span><br/>卷名</h2>
</body>
</html>

正文

xhtml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>第一章 章节</title>
    <link href="../Styles/stylesheet.css" rel="stylesheet" type="text/css"/>
</head>

<body>

<h3 class="chapter"><span class="num">第一章</span><br/>章节</h3>

<p>正文</p>

</body>
</html>

诗歌

css
p.shige {
  text-indent: 0em;
  text-align: center;
  font-family: "ZY-LIBIAN", "方正隶变";
}

注解

xhtml
<img zy-footnote="○菡萏:古人称未开的荷花为菡萏,即花苞。" style="width: 0.8em" src="../Images/note.png"/>

拼音

xhtml
<ruby> 菡 <rt> hàn </rt></ruby><ruby> 萏 <rt> dàn </rt></ruby>

图片

css
div.image-box {
  text-align: center;
}

div.image-box p {
  text-indent: 0em;
}

书评

css
div.quote-box {
  margin: 1em 0;
  padding: 1em 0.5em 1em;
  background: #D1E3DE;
  border-radius: 1em;
}

div.quote-box p {
  font-family: "ZY-LIBIAN", "方正隶变";
  margin: 0;
  color: black;
}

字体声明

css
@font-face {
    font-family: "DongFangDaKai";
    src: url("../Fonts/DongFangDaKai.ttf");
}

正则表达式

添加title

regexp
.*<h3 class="chapter">(.*)</h3>

<h3 class="chapter" title="\1">\1</h3>

章节号换行

regexp
>(.*) (.*)</h3>

><span class="num">\1</span><br/>\2</h3>

上下换行

regexp
(上)</h3>

<br/><span class="num">(上)</span></h3>

目录