aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Letan <contact@thomasletan.fr>2019-08-04 12:56:14 +0200
committerThomas Letan <contact@thomasletan.fr>2019-08-04 12:56:14 +0200
commitce2a45e8acba91a79d7bca4e7d2b096d092562a4 (patch)
tree624d1b688b9a6844beca256479ffe9f21caa0415
parentfeature: Support optional title in rendering (diff)
feature: Embed a CCS file in the generated EPUB
-rw-r--r--src/epub.rs7
-rw-r--r--templates/chapter.xhtml7
-rw-r--r--templates/content.opf1
-rw-r--r--templates/main.css51
4 files changed, 64 insertions, 2 deletions
diff --git a/src/epub.rs b/src/epub.rs
index 2798083..4356f3d 100644
--- a/src/epub.rs
+++ b/src/epub.rs
@@ -83,5 +83,12 @@ pub fn generate(project : &Project<String>) -> Result<(), Error> {
&PathBuf::from("OEBPS/content.opf")
)?;
+ write_template_to(
+ &tera,
+ "main.css",
+ &Context::new(),
+ &PathBuf::from("OEBPS/Style/main.css")
+ )?;
+
Ok(())
}
diff --git a/templates/chapter.xhtml b/templates/chapter.xhtml
index d18b69d..d4f7c62 100644
--- a/templates/chapter.xhtml
+++ b/templates/chapter.xhtml
@@ -1,5 +1,6 @@
-<html>
+<html lang="fr">
<head>
+ <link rel="stylesheet" type="text/css" href="../Style/main.css" />
</head>
<body>
{% if chapter.title %}
@@ -7,6 +8,8 @@
{{ chapter.title }}
</h1>
{% endif %}
- {{ chapter.content }}
+ <div class="ogmarkup">
+ {{ chapter.content }}
+ </div>
</body>
</html>
diff --git a/templates/content.opf b/templates/content.opf
index f96ac34..90201bb 100644
--- a/templates/content.opf
+++ b/templates/content.opf
@@ -8,6 +8,7 @@
<dc:description>Ceci est une description</dc:description>
</metadata>
<manifest>
+ <item href="Style/main.css" id="main.css" media-type="text/css" />
<item href="toc.ncx" id="ncx" media-type="application/x-dtbncx+xml" />
{% for f in files %}
<item href="Text/{{ f }}" id="{{ f }}" media-type="application/xhtml+xml" />
diff --git a/templates/main.css b/templates/main.css
new file mode 100644
index 0000000..6e7eb83
--- /dev/null
+++ b/templates/main.css
@@ -0,0 +1,51 @@
+html, body {
+ font-size: 100%;
+ font-family: serif;
+ color: #222;
+ hyphens: auto;
+}
+
+h1 {
+ margin-top: 6rem;
+ margin-bottom: 2rem;
+ text-align: center;
+}
+
+p {
+ text-indent: 1rem;
+ padding: 0;
+ margin: 0;
+ line-height: 1.5em;
+ padding-bottom: .1em;
+}
+
+.ogmarkup {
+ text-align: justify;
+}
+
+.ogmarkup .date {
+ text-indent: 0;
+ text-align: right;
+ font-style: italic;
+ padding-bottom: 1rem;
+}
+
+.ogmarkup .date em {
+ font-style: normal;
+}
+
+.reply {
+ color: black;
+}
+
+.thought .reply {
+ font-style: italic;
+}
+
+.thought .reply em {
+ font-style: normal;
+}
+
+.story {
+ padding-bottom: 1.5em;
+}