diff --git a/README.md b/README.md index c3b2d46..9c7ee2a 100644 --- a/README.md +++ b/README.md @@ -53,46 +53,51 @@ To create a new e-book, just run This command creates a directory `mybook` with the following structure: - . - ├── Gemfile - ├── Gemfile.lock - ├── Guardfile - ├── config - │ ├── helper.rb - │ ├── kitabu.yml - │ └── locales - │ └── en.yml - ├── fonts - ├── images - │ ├── cover.png - │ ├── kitabu.svg - │ ├── markdown.svg - │ └── up.svg - ├── templates - │ ├── epub - │ │ ├── cover.erb - │ │ ├── page.erb - │ │ └── toc.erb - │ ├── html - │ │ └── layout.erb - │ └── styles - │ ├── epub.css - │ ├── files - │ │ ├── normalize.css - │ │ ├── notes.css - │ │ └── toc.css - │ ├── html.css - │ ├── pdf.css - │ └── print.css - └── text - ├── 01_Getting_Started.md - ├── 02_Creating_Chapters.md - ├── 03_Syntax_Highlighting.md.erb - ├── 04_Dynamic_Content.md.erb - ├── 05_Exporting_Files.md - └── 06_Changelog.md - - 11 directories, 27 files +``` +. +├── Gemfile +├── Gemfile.lock +├── Guardfile +├── assets +│ ├── fonts +│ ├── images +│ │ ├── cover.png +│ │ ├── kitabu.svg +│ │ ├── markdown.svg +│ │ └── up.svg +│ ├── scripts +│ └── styles +│ ├── epub.css +│ ├── html.css +│ ├── pdf.css +│ ├── print.css +│ └── support +│ ├── kitabu.css +│ ├── normalize.css +│ ├── notes.css +│ └── toc.css +├── config +│ ├── helpers.rb +│ ├── kitabu.yml +│ └── locales +│ └── en.yml +├── templates +│ ├── epub +│ │ ├── cover.erb +│ │ ├── page.erb +│ │ └── toc.erb +│ └── html +│ └── layout.erb +└── text + ├── 01_Getting_Started.md + ├── 02_Creating_Chapters.md + ├── 03_Syntax_Highlighting.md.erb + ├── 04_Dynamic_Content.md.erb + ├── 05_Exporting_Files.md + └── 06_Changelog.md + +13 directories, 28 files +``` The `config/kitabu.yml` file holds some information about your book; so you'll always change it. @@ -193,7 +198,7 @@ be something like this: ``` -You book's helpers can be added to `config/helper.rb`, as this file is loaded +You book's helpers can be added to `config/helpers.rb`, as this file is loaded automatically by kitabu. You can see available helpers on @@ -254,11 +259,12 @@ end ### Using custom fonts -You can use custom fonts for your PDF. Just add them to the `fonts` directory +You can use custom fonts on your ebooks. Just add them to the `fonts` directory (you can create this directory on your book's root directory if it doesn't exist). -Then, on `templates/styles/pdf.css` you can add the `@font-face` declaration. +Then, on `assets/styles/support/fonts.css` you can add the `@font-face` +declaration. ```css @font-face { @@ -275,12 +281,46 @@ Finally, to use this font, do something like this: } ``` +Instead of doing the above manually, you can also use Prince's `--scanfonts` +option. + +```console +$ prince --scanfonts assets/fonts/* > assets/styles/support/fonts.css +``` + +Just remember to replace the generated path to be something like `../../fonts` +instead. + +> [!TIP] +> +> In most cases, it's easier to redefine `sans-serif`, `serif` and `monospace` +> fonts. To know more about how to do this, read Prince's +> [Redefining the generic font families](https://www.princexml.com/doc/styling/#redefining-the-generic-font-families) +> documentation. + +If you're unsure if fonts are actually being used on PDF files, use the +environment variable `PRINCEOPT` to disable system fonts. + +```console +$ PRINCEOPT='--no-system-fonts --debug --log output/prince.log' kitabu export --only pdf +=> e-book couldn't be exported + +$ tail -n10 output/prince.log +Sat Jan 27 18:39:10 2024: debug: font request: Caslon, serif +Sat Jan 27 18:39:10 2024: warning: Ensure fonts are available on the system or load them via a @font-face rule. +Sat Jan 27 18:39:10 2024: warning: For more information see: +Sat Jan 27 18:39:10 2024: warning: https://www.princexml.com/doc/help-install/#missing-glyphs-or-fonts +Sat Jan 27 18:39:10 2024: internal error: Unable to find any available fonts. +Sat Jan 27 18:39:10 2024: finished: failure +Sat Jan 27 18:39:10 2024: ---- end +``` + ### Configuring Markdown Kitabu uses [Redcarpet](https://github.com/vmg/redcarpet) as the Markdown engine. You can override the default processor by setting `Kitabu::Markdown.processor`. This can be done by adding something like the -following to `config/helper.rb`: +following to `config/helpers.rb`: ```ruby Kitabu::Markdown.processor = Redcarpet::Markdown.new( diff --git a/lib/kitabu.rb b/lib/kitabu.rb index da5b3e5..729962a 100644 --- a/lib/kitabu.rb +++ b/lib/kitabu.rb @@ -33,6 +33,7 @@ module Kitabu require "kitabu/version" require "kitabu/generator" require "kitabu/cli" + require "kitabu/css" require "kitabu/markdown" require "kitabu/source_list" require "kitabu/exporter" @@ -41,7 +42,6 @@ module Kitabu require "kitabu/exporter/epub" require "kitabu/exporter/mobi" require "kitabu/exporter/pdf" - require "kitabu/exporter/css" require "kitabu/footnotes/base" require "kitabu/footnotes/html" require "kitabu/footnotes/pdf" diff --git a/lib/kitabu/css.rb b/lib/kitabu/css.rb new file mode 100644 index 0000000..da45913 --- /dev/null +++ b/lib/kitabu/css.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +module Kitabu + class CSS + def self.create_file(root_dir:, config:) + buffer = StringIO.new + buffer << accent_color(config:) + buffer << "\n\n" + buffer << syntax_highlight(config:) + buffer << "\n\n" + buffer << translations(config:) + + support_dir = root_dir.join("assets/styles/support") + + FileUtils.mkdir_p(support_dir) + support_dir.join("kitabu.css").open("w") do |file| + file << buffer.tap(&:rewind).read + end + end + + def self.accent_color(config:) + accent_color = config.fetch(:css_accent_color, "#000") + + <<~CSS + :root { + --accent-color: #{accent_color}; + } + CSS + end + + def self.syntax_highlight(config:) + Rouge::Theme.find( + config.fetch(:syntax_highlight_theme, :github) + ).render(scope: ".highlight") + end + + def self.translations(config:) + backend = I18n.backend.translations + + translations = + backend.each_with_object([]) do |(lang, dict), buffer| + buffer << "html[lang='#{lang}'] {" + + dict.each do |key, value| + next unless value.is_a?(String) && value.lines.count == 1 + + buffer << "--#{key.to_s.tr('_', '-')}-text: #{value.inspect};" + end + + buffer << "}\n" + end + + translations.join("\n") + end + end +end diff --git a/lib/kitabu/exporter.rb b/lib/kitabu/exporter.rb index a4cb9cf..e47f6e7 100644 --- a/lib/kitabu/exporter.rb +++ b/lib/kitabu/exporter.rb @@ -19,7 +19,7 @@ def ui end def export! - helper = root_dir.join("config/helper.rb") + helper = root_dir.join("config/helpers.rb") load(helper) if helper.exist? FileUtils.rm_rf root_dir.join("output").to_s diff --git a/lib/kitabu/exporter/base.rb b/lib/kitabu/exporter/base.rb index 976c5ef..fdfdefa 100644 --- a/lib/kitabu/exporter/base.rb +++ b/lib/kitabu/exporter/base.rb @@ -2,6 +2,16 @@ module Kitabu class Exporter + def self.load_translations(root_dir:) + I18n.load_path += Dir[ + File.expand_path(File.join(__dir__, "../../../templates/en.yml")), + root_dir.join("config/locales/**/*.{yml,rb}").to_s + ] + + I18n.backend.reload! + I18n.backend.eager_load! + end + class Base # The e-book directory. # @@ -12,11 +22,7 @@ class Base attr_accessor :source def self.export(root_dir) - I18n.backend.eager_load! - I18n.load_path += Dir[ - root_dir.join("config/locales/**/*.{yml,rb}").to_s - ] - + Exporter.load_translations(root_dir:) new(root_dir).export end diff --git a/lib/kitabu/exporter/css.rb b/lib/kitabu/exporter/css.rb deleted file mode 100644 index 0732606..0000000 --- a/lib/kitabu/exporter/css.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -module Kitabu - class Exporter - class CSS < Base - attr_reader :root_dir - - def export - super - - FileUtils.cp_r( - root_dir.join("templates/styles").to_s, - root_dir.join("output").to_s - ) - end - end - end -end diff --git a/lib/kitabu/exporter/epub.rb b/lib/kitabu/exporter/epub.rb index 81d2373..2a5163d 100644 --- a/lib/kitabu/exporter/epub.rb +++ b/lib/kitabu/exporter/epub.rb @@ -42,16 +42,23 @@ def html def export super - copy_styles! - copy_images! + copy_assets write_sections! write_cover! write_toc! + ignore_files = [ + tmp_dir.join("assets/styles/html.css"), + tmp_dir.join("assets/styles/print.css"), + tmp_dir.join("assets/styles/pdf.css") + ].map(&:to_s) + epub.files += [tmp_dir.join("cover.html"), tmp_dir.join("toc.html")] epub.files += tmp_dir.glob("**/*").select do |entry| - !epub.files.include?(entry) && entry.file? + !epub.files.include?(entry) && + entry.file? && + !ignore_files.include?(entry.to_s) end epub.save(epub_path) @@ -62,13 +69,8 @@ def export false end - def copy_styles! - copy_files("output/styles/epub.css", "output/epub/styles") - copy_files("output/styles/files/*.css", "output/epub/styles") - end - - def copy_images! - copy_directory("output/images", "output/epub/images") + def copy_assets + copy_directory("output/assets", "output/epub/assets") end def write_toc! diff --git a/lib/kitabu/exporter/html.rb b/lib/kitabu/exporter/html.rb index c3cdefa..f8eefaf 100644 --- a/lib/kitabu/exporter/html.rb +++ b/lib/kitabu/exporter/html.rb @@ -8,9 +8,8 @@ class HTML < Base # def export super - copy_images! - copy_fonts! - export_stylesheets! + copy_assets + export_kitabu_css File.open(root_dir.join("output/#{name}.html"), "w") do |file| file << render_layout @@ -97,22 +96,17 @@ def content buffer.join end - # Copy images + # Copy assets # - private def copy_images! - copy_directory("images", "output/images") + private def copy_assets + copy_directory("assets", "output/assets") end - # Copy font files + # Export css with utilities for syntax highlighting, translations, and + # accent color. # - private def copy_fonts! - copy_directory("fonts", "output/fonts") - end - - # Export all root stylesheets. - # - private def export_stylesheets! - Exporter::CSS.new(root_dir).export + private def export_kitabu_css + CSS.create_file(config:, root_dir:) end end end diff --git a/lib/kitabu/exporter/pdf.rb b/lib/kitabu/exporter/pdf.rb index 9f10d54..969edd6 100644 --- a/lib/kitabu/exporter/pdf.rb +++ b/lib/kitabu/exporter/pdf.rb @@ -7,6 +7,7 @@ def export super apply_footnotes! args = Shellwords.split(ENV.fetch("PRINCEOPT", "")) + args += Array(config[:prince_args]) spawn_command( ["prince", *args, html_for_pdf.to_s, "-o", pdf_file.to_s] @@ -29,7 +30,7 @@ def create_html_file(target, html, class_name) html .css("link[rel=stylesheet]") .first - .set_attribute "href", "styles/#{class_name}.css" + .set_attribute "href", "assets/styles/#{class_name}.css" File.open(target, "w") {|f| f << html.to_html } end diff --git a/lib/kitabu/generator.rb b/lib/kitabu/generator.rb index 01ef9bc..6f4a41a 100644 --- a/lib/kitabu/generator.rb +++ b/lib/kitabu/generator.rb @@ -16,16 +16,12 @@ def self.source_root "#{File.dirname(__FILE__)}/../../templates" end - def copy_templates - directory "templates", "templates" - end - - def copy_sample_texts - directory "text", "text" + def copy_i18n_file + copy_file "en.yml", "config/locales/en.yml" end - def copy_images - directory "images", "images" + def copy_templates + directory "templates", "templates" end def copy_config_file @@ -35,29 +31,34 @@ def copy_config_file template "config.erb", "config/kitabu.yml" end - def copy_i18n_file - copy_file "en.yml", "config/locales/en.yml" + def copy_assets + directory "assets", "assets" + + Exporter.load_translations(root_dir:) + + CSS.create_file( + root_dir:, + config: YAML.load_file(root_dir.join("config/kitabu.yml")) + .with_indifferent_access + ) + end + + def copy_texts + directory "text", "text" end def copy_helper_file - copy_file "helper.rb", "config/helper.rb" + copy_file "helpers.rb", "config/helpers.rb" end def copy_gemfile copy_file "Gemfile" end - def create_directories - empty_directory "output" - empty_directory "fonts" - end - def create_git_files create_file ".gitignore" do "/output" end - - create_file "fonts/.keep" end def copy_guardfile @@ -71,6 +72,12 @@ def bundle_install end no_commands do + # The root directory + # + def root_dir + @root_dir ||= Pathname.new(destination_root) + end + # Retrieve user's name using finger. # Defaults to John Doe. # diff --git a/lib/kitabu/helpers.rb b/lib/kitabu/helpers.rb index 7dadcef..60f003a 100644 --- a/lib/kitabu/helpers.rb +++ b/lib/kitabu/helpers.rb @@ -2,39 +2,14 @@ module Kitabu module Helpers - def css_translations - backend = I18n.backend.translations - - translations = - backend.each_with_object([]) do |(lang, dict), buffer| - buffer << ":root[lang='#{lang}'] {" - - dict.each do |key, value| - next unless value.is_a?(String) && value.lines.count == 1 - - buffer << "--#{key.to_s.tr('_', '-')}-text: #{value.inspect};" - end - - buffer << "}" - end - - translations.join("\n") - end - - def highlight_theme(name = theme) - html = '" - html - end - def image_tag(path, _attributes = {}) - %[] + %[] end def escape_html(content) CGI.escape_html(content.to_s) end + alias h escape_html def note(class_name = :info, &block) content = block_content(block) diff --git a/lib/kitabu/syntax/highlight.rb b/lib/kitabu/syntax/highlight.rb deleted file mode 100644 index 5865191..0000000 --- a/lib/kitabu/syntax/highlight.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -module Kitabu - class Syntax - class Highlight - def self.apply(code, language) - coderay(code, language) - end - - def self.coderay(code, language) - html = Nokogiri::HTML(CodeRay.scan(code, language).div(css: :class)) - coderay = html.css("div.CodeRay").first - coderay.set_attribute "class", "CodeRay #{language}" - pre = html.css("pre").first - pre.replace Nokogiri.make("
#{pre.inner_html}
")
-
- coderay.to_xhtml
- end
- end
- end
-end
diff --git a/spec/kitabu/exporter/css_spec.rb b/spec/kitabu/exporter/css_spec.rb
deleted file mode 100644
index 2deb06f..0000000
--- a/spec/kitabu/exporter/css_spec.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-require "spec_helper"
-
-describe Kitabu::Exporter::CSS do
- let(:root) { SPECDIR.join("support/mybook") }
-
- before do
- Kitabu::Exporter::CSS.export(root)
- end
-
- it "generates css files" do
- expect(root.join("output/styles/epub.css")).to be_file
- expect(root.join("output/styles/pdf.css")).to be_file
- expect(root.join("output/styles/print.css")).to be_file
- expect(root.join("output/styles/html.css")).to be_file
- end
-end
diff --git a/spec/kitabu/exporter/html_spec.rb b/spec/kitabu/exporter/html_spec.rb
index 35d9afb..1a2f35d 100644
--- a/spec/kitabu/exporter/html_spec.rb
+++ b/spec/kitabu/exporter/html_spec.rb
@@ -67,15 +67,15 @@
expect(html).to have_tag("div.note.info > p", "This is a note!")
end
- it "copies fonts" do
- expect(root.join("output/fonts/OpenSans-CondBold.ttf")).to be_file
- end
-
- it "exports css files" do
- expect(root.join("output/styles/epub.css")).to be_file
- expect(root.join("output/styles/html.css")).to be_file
- expect(root.join("output/styles/pdf.css")).to be_file
- expect(root.join("output/styles/print.css")).to be_file
+ it "copies assets" do
+ expect(root.join("output/assets/images/cover.png")).to be_file
+ expect(root.join("output/assets/images/logo.gif")).to be_file
+ expect(root.join("output/assets/fonts/OpenSans-CondBold.ttf")).to be_file
+ expect(root.join("output/assets/styles/epub.css")).to be_file
+ expect(root.join("output/assets/styles/html.css")).to be_file
+ expect(root.join("output/assets/styles/pdf.css")).to be_file
+ expect(root.join("output/assets/styles/print.css")).to be_file
+ expect(root.join("output/assets/scripts")).to be_directory
end
end
end
diff --git a/spec/kitabu/exporter/pdf_spec.rb b/spec/kitabu/exporter/pdf_spec.rb
index bc7b366..ce43c96 100644
--- a/spec/kitabu/exporter/pdf_spec.rb
+++ b/spec/kitabu/exporter/pdf_spec.rb
@@ -16,12 +16,12 @@
end
it "sets stylesheet for print pdf" do
- selector = 'link[rel=stylesheet][href="styles/print.css"]'
+ selector = 'link[rel=stylesheet][href="assets/styles/print.css"]'
expect(root.join("output/mybook.print.html").read).to have_tag(selector)
end
it "sets stylesheet for pdf" do
- selector = 'link[rel=stylesheet][href="styles/pdf.css"]'
+ selector = 'link[rel=stylesheet][href="assets/styles/pdf.css"]'
expect(root.join("output/mybook.pdf.html").read).to have_tag(selector)
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 86741a7..ac8b268 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -46,7 +46,10 @@ def bundle_install
)
cleaner = proc do
- [TMPDIR, SPECDIR.join("support/mybook/output")].each do |i|
+ [
+ TMPDIR
+ # SPECDIR.join("support/mybook/output")
+ ].each do |i|
FileUtils.rm_rf(i)
end
diff --git a/spec/support/mybook/assets/fonts/LibertinusSerif-Bold.otf b/spec/support/mybook/assets/fonts/LibertinusSerif-Bold.otf
new file mode 100644
index 0000000..60466f4
Binary files /dev/null and b/spec/support/mybook/assets/fonts/LibertinusSerif-Bold.otf differ
diff --git a/spec/support/mybook/assets/fonts/LibertinusSerif-BoldItalic.otf b/spec/support/mybook/assets/fonts/LibertinusSerif-BoldItalic.otf
new file mode 100644
index 0000000..4d5f11a
Binary files /dev/null and b/spec/support/mybook/assets/fonts/LibertinusSerif-BoldItalic.otf differ
diff --git a/spec/support/mybook/assets/fonts/LibertinusSerif-Italic.otf b/spec/support/mybook/assets/fonts/LibertinusSerif-Italic.otf
new file mode 100644
index 0000000..1851d94
Binary files /dev/null and b/spec/support/mybook/assets/fonts/LibertinusSerif-Italic.otf differ
diff --git a/spec/support/mybook/assets/fonts/LibertinusSerif-Regular.otf b/spec/support/mybook/assets/fonts/LibertinusSerif-Regular.otf
new file mode 100644
index 0000000..110efd1
Binary files /dev/null and b/spec/support/mybook/assets/fonts/LibertinusSerif-Regular.otf differ
diff --git a/spec/support/mybook/assets/fonts/LibertinusSerif-Semibold.otf b/spec/support/mybook/assets/fonts/LibertinusSerif-Semibold.otf
new file mode 100644
index 0000000..5281388
Binary files /dev/null and b/spec/support/mybook/assets/fonts/LibertinusSerif-Semibold.otf differ
diff --git a/spec/support/mybook/assets/fonts/LibertinusSerif-SemiboldItalic.otf b/spec/support/mybook/assets/fonts/LibertinusSerif-SemiboldItalic.otf
new file mode 100644
index 0000000..19f440d
Binary files /dev/null and b/spec/support/mybook/assets/fonts/LibertinusSerif-SemiboldItalic.otf differ
diff --git a/spec/support/mybook/fonts/OpenSans-CondBold.ttf b/spec/support/mybook/assets/fonts/OpenSans-CondBold.ttf
similarity index 100%
rename from spec/support/mybook/fonts/OpenSans-CondBold.ttf
rename to spec/support/mybook/assets/fonts/OpenSans-CondBold.ttf
diff --git a/spec/support/mybook/templates/epub/cover.png b/spec/support/mybook/assets/images/cover.png
similarity index 100%
rename from spec/support/mybook/templates/epub/cover.png
rename to spec/support/mybook/assets/images/cover.png
diff --git a/spec/support/mybook/images/logo.gif b/spec/support/mybook/assets/images/logo.gif
similarity index 100%
rename from spec/support/mybook/images/logo.gif
rename to spec/support/mybook/assets/images/logo.gif
diff --git a/spec/support/mybook/code/.gitkeep b/spec/support/mybook/assets/scripts/.keep
similarity index 100%
rename from spec/support/mybook/code/.gitkeep
rename to spec/support/mybook/assets/scripts/.keep
diff --git a/spec/support/mybook/templates/styles/epub.css b/spec/support/mybook/assets/styles/epub.css
similarity index 50%
rename from spec/support/mybook/templates/styles/epub.css
rename to spec/support/mybook/assets/styles/epub.css
index b8013ef..7b6bb9b 100644
--- a/spec/support/mybook/templates/styles/epub.css
+++ b/spec/support/mybook/assets/styles/epub.css
@@ -1,3 +1,5 @@
+@import "support/kitabu.css";
+
.epub {
background: yellow;
}
diff --git a/spec/support/mybook/assets/styles/html.css b/spec/support/mybook/assets/styles/html.css
new file mode 100644
index 0000000..5e37ab0
--- /dev/null
+++ b/spec/support/mybook/assets/styles/html.css
@@ -0,0 +1,5 @@
+@import "support/kitabu.css";
+
+.html {
+ background: red;
+}
diff --git a/spec/support/mybook/assets/styles/pdf.css b/spec/support/mybook/assets/styles/pdf.css
new file mode 100644
index 0000000..2269f10
--- /dev/null
+++ b/spec/support/mybook/assets/styles/pdf.css
@@ -0,0 +1,15 @@
+@import "support/kitabu.css";
+
+.pdf {
+ background: blue;
+}
+
+h1,
+h2 {
+ font-family: "Open Sans Condensed";
+ text-transform: uppercase;
+}
+
+body {
+ font-family: "Libertinus Serif";
+}
diff --git a/spec/support/mybook/templates/styles/print.css b/spec/support/mybook/assets/styles/print.css
similarity index 50%
rename from spec/support/mybook/templates/styles/print.css
rename to spec/support/mybook/assets/styles/print.css
index e9fbee0..e012554 100644
--- a/spec/support/mybook/templates/styles/print.css
+++ b/spec/support/mybook/assets/styles/print.css
@@ -1,3 +1,5 @@
+@import "support/kitabu.css";
+
.print {
background: green;
}
diff --git a/spec/support/mybook/assets/styles/support/fonts.css b/spec/support/mybook/assets/styles/support/fonts.css
new file mode 100644
index 0000000..b6e214a
--- /dev/null
+++ b/spec/support/mybook/assets/styles/support/fonts.css
@@ -0,0 +1,62 @@
+/* Libertinus Serif, Bold */
+@font-face {
+ font-family: "Libertinus Serif";
+ font-weight: bold;
+ font-style: normal;
+ font-stretch: normal;
+ src: url("../../fonts/LibertinusSerif-Bold.otf");
+}
+
+/* Libertinus Serif, Bold Italic */
+@font-face {
+ font-family: "Libertinus Serif";
+ font-weight: bold;
+ font-style: italic;
+ font-stretch: normal;
+ src: url("../../fonts/LibertinusSerif-BoldItalic.otf");
+}
+
+/* Libertinus Serif, Italic */
+@font-face {
+ font-family: "Libertinus Serif";
+ font-weight: normal;
+ font-style: italic;
+ font-stretch: normal;
+ src: url("../../fonts/LibertinusSerif-Italic.otf");
+}
+
+/* Libertinus Serif, Regular */
+@font-face {
+ font-family: "Libertinus Serif";
+ font-weight: normal;
+ font-style: normal;
+ font-stretch: normal;
+ src: url("../../fonts/LibertinusSerif-Regular.otf");
+}
+
+/* Libertinus Serif, Semibold */
+@font-face {
+ font-family: "Libertinus Serif";
+ font-weight: 600;
+ font-style: normal;
+ font-stretch: normal;
+ src: url("assets/fonts/LibertinusSerif-Semibold.otf");
+}
+
+/* Libertinus Serif, Semibold Italic */
+@font-face {
+ font-family: "Libertinus Serif";
+ font-weight: 600;
+ font-style: italic;
+ font-stretch: normal;
+ src: url("assets/fonts/LibertinusSerif-SemiboldItalic.otf");
+}
+
+/* Open Sans Condensed, Bold */
+@font-face {
+ font-family: "Open Sans Condensed";
+ font-weight: bold;
+ font-style: normal;
+ font-stretch: condensed;
+ src: url("assets/fonts/OpenSans-CondBold.ttf");
+}
diff --git a/spec/support/mybook/assets/styles/support/kitabu.css b/spec/support/mybook/assets/styles/support/kitabu.css
new file mode 100644
index 0000000..735b518
--- /dev/null
+++ b/spec/support/mybook/assets/styles/support/kitabu.css
@@ -0,0 +1,123 @@
+:root {
+ --accent-color: #5091b1;
+}
+
+
+.highlight table td { padding: 5px; }
+.highlight table pre { margin: 0; }
+.highlight, .highlight .w {
+ color: #24292f;
+ background-color: #f6f8fa;
+}
+.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kt, .highlight .kv {
+ color: #cf222e;
+}
+.highlight .gr {
+ color: #f6f8fa;
+}
+.highlight .gd {
+ color: #82071e;
+ background-color: #ffebe9;
+}
+.highlight .nb {
+ color: #953800;
+}
+.highlight .nc {
+ color: #953800;
+}
+.highlight .no {
+ color: #953800;
+}
+.highlight .nn {
+ color: #953800;
+}
+.highlight .sr {
+ color: #116329;
+}
+.highlight .na {
+ color: #116329;
+}
+.highlight .nt {
+ color: #116329;
+}
+.highlight .gi {
+ color: #116329;
+ background-color: #dafbe1;
+}
+.highlight .kc {
+ color: #0550ae;
+}
+.highlight .l, .highlight .ld, .highlight .m, .highlight .mb, .highlight .mf, .highlight .mh, .highlight .mi, .highlight .il, .highlight .mo, .highlight .mx {
+ color: #0550ae;
+}
+.highlight .sb {
+ color: #0550ae;
+}
+.highlight .bp {
+ color: #0550ae;
+}
+.highlight .ne {
+ color: #0550ae;
+}
+.highlight .nl {
+ color: #0550ae;
+}
+.highlight .py {
+ color: #0550ae;
+}
+.highlight .nv, .highlight .vc, .highlight .vg, .highlight .vi, .highlight .vm {
+ color: #0550ae;
+}
+.highlight .o, .highlight .ow {
+ color: #0550ae;
+}
+.highlight .gh {
+ color: #0550ae;
+ font-weight: bold;
+}
+.highlight .gu {
+ color: #0550ae;
+ font-weight: bold;
+}
+.highlight .s, .highlight .sa, .highlight .sc, .highlight .dl, .highlight .sd, .highlight .s2, .highlight .se, .highlight .sh, .highlight .sx, .highlight .s1, .highlight .ss {
+ color: #0a3069;
+}
+.highlight .nd {
+ color: #8250df;
+}
+.highlight .nf, .highlight .fm {
+ color: #8250df;
+}
+.highlight .err {
+ color: #f6f8fa;
+ background-color: #82071e;
+}
+.highlight .c, .highlight .ch, .highlight .cd, .highlight .cm, .highlight .cp, .highlight .cpf, .highlight .c1, .highlight .cs {
+ color: #6e7781;
+}
+.highlight .gl {
+ color: #6e7781;
+}
+.highlight .gt {
+ color: #6e7781;
+}
+.highlight .ni {
+ color: #24292f;
+}
+.highlight .si {
+ color: #24292f;
+}
+.highlight .ge {
+ color: #24292f;
+ font-style: italic;
+}
+.highlight .gs {
+ color: #24292f;
+ font-weight: bold;
+}
+
+html[lang='en'] {
+--contents-text: "Contents";
+--left-blank-text: "This page intentionally left blank";
+--chapter-text: "Chapter";
+}
diff --git a/spec/support/mybook/text/.gitkeep b/spec/support/mybook/code/.keep
similarity index 100%
rename from spec/support/mybook/text/.gitkeep
rename to spec/support/mybook/code/.keep
diff --git a/spec/support/mybook/config/kitabu.yml b/spec/support/mybook/config/kitabu.yml
index 3b8ae99..97170d5 100644
--- a/spec/support/mybook/config/kitabu.yml
+++ b/spec/support/mybook/config/kitabu.yml
@@ -49,8 +49,8 @@ creators:
contributors: []
# Syntax highlight theme. Can be any of supported by Rouge.
-theme: github
+syntax_highlight_theme: github
# Accent color. This will be set as a CSS variable, so you can use it on all
# CSS files like `color: var(--accent-color)`.
-accent_color: "#5091b1"
+css_accent_color: "#5091b1"
diff --git a/spec/support/mybook/config/locales/en.yml b/spec/support/mybook/config/locales/en.yml
index f73757f..e065fa6 100644
--- a/spec/support/mybook/config/locales/en.yml
+++ b/spec/support/mybook/config/locales/en.yml
@@ -1,3 +1,12 @@
---
en:
+ contents: Contents
+ left_blank: This page intentionally left blank
chapter: Chapter
+
+ notes:
+ warning: Warning!
+ note: Just so you know…
+ tip: Here’s a tip!
+ caution: Caution!
+ important: Important!
diff --git a/spec/support/mybook/templates/epub/cover.erb b/spec/support/mybook/templates/epub/cover.erb
index a5c3fbe..385b370 100644
--- a/spec/support/mybook/templates/epub/cover.erb
+++ b/spec/support/mybook/templates/epub/cover.erb
@@ -1,17 +1,28 @@
-
-
-
+
+
+
+
+