kitabu 1.0.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -3
- data/.travis.yml +18 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +67 -50
- data/README.md +235 -0
- data/attachments/browser-version.png +0 -0
- data/attachments/cover.png +0 -0
- data/attachments/kitabu.epub +0 -0
- data/attachments/kitabu.mobi +0 -0
- data/attachments/kitabu.pdf +0 -0
- data/{spec/support/mybook/output → examples/kitabu/output/epub/images}/.gitkeep +0 -0
- data/examples/kitabu/output/epub/images/kitabu-icon.png +0 -0
- data/examples/kitabu/output/epub/images/kitabu-icon.svg +19 -0
- data/examples/kitabu/output/epub/images/kitabu-word.png +0 -0
- data/examples/kitabu/output/epub/images/kitabu-word.svg +14 -0
- data/examples/kitabu/output/epub/images/kitabu.png +0 -0
- data/examples/kitabu/output/epub/images/kitabu.svg +20 -0
- data/examples/kitabu/output/epub/section_0.html +266 -0
- data/examples/kitabu/output/epub/section_1.html +246 -0
- data/examples/kitabu/output/epub/section_2.html +520 -0
- data/examples/kitabu/output/epub/section_3.html +282 -0
- data/examples/kitabu/output/epub/section_4.html +276 -0
- data/examples/kitabu/output/epub/styles/epub.css +437 -0
- data/examples/kitabu/output/epub/styles/html.css +712 -0
- data/examples/kitabu/output/epub/styles/pdf.css +840 -0
- data/examples/kitabu/output/epub/styles/print.css +1278 -0
- data/examples/kitabu/output/epub/toc.html +37 -0
- data/{spec/support/mybook/templates/epub/style.css → examples/kitabu/output/images/.gitkeep} +0 -0
- data/examples/kitabu/output/images/kitabu-icon.png +0 -0
- data/examples/kitabu/output/images/kitabu-icon.svg +19 -0
- data/examples/kitabu/output/images/kitabu-word.png +0 -0
- data/examples/kitabu/output/images/kitabu-word.svg +14 -0
- data/examples/kitabu/output/images/kitabu.png +0 -0
- data/examples/kitabu/output/images/kitabu.svg +20 -0
- data/examples/kitabu/output/kitabu.epub +0 -0
- data/examples/kitabu/output/kitabu.html +513 -0
- data/examples/kitabu/output/kitabu.mobi +0 -0
- data/examples/kitabu/output/kitabu.pdf +0 -0
- data/examples/kitabu/output/kitabu.pdf.html +729 -0
- data/examples/kitabu/output/kitabu.print.html +729 -0
- data/examples/kitabu/output/kitabu.print.pdf +0 -0
- data/examples/kitabu/output/kitabu.txt +440 -0
- data/examples/kitabu/output/styles/epub.css +437 -0
- data/examples/kitabu/output/styles/html.css +712 -0
- data/examples/kitabu/output/styles/pdf.css +840 -0
- data/examples/kitabu/output/styles/print.css +1278 -0
- data/kitabu.gemspec +7 -5
- data/lib/kitabu.rb +10 -20
- data/lib/kitabu/cli.rb +0 -5
- data/lib/kitabu/dependency.rb +0 -4
- data/lib/kitabu/exporter.rb +2 -0
- data/lib/kitabu/extensions/rouge.rb +9 -0
- data/lib/kitabu/generator.rb +9 -21
- data/lib/kitabu/helpers.rb +47 -0
- data/lib/kitabu/markdown.rb +31 -0
- data/lib/kitabu/parser.rb +21 -3
- data/lib/kitabu/parser/epub.rb +31 -18
- data/lib/kitabu/parser/html.rb +48 -29
- data/lib/kitabu/parser/mobi.rb +1 -1
- data/lib/kitabu/parser/pdf.rb +52 -8
- data/lib/kitabu/version.rb +2 -2
- data/spec/kitabu/cli/export_spec.rb +4 -4
- data/spec/kitabu/cli/new_spec.rb +2 -2
- data/spec/kitabu/markdown_spec.rb +24 -0
- data/spec/kitabu/parser/html_spec.rb +20 -25
- data/spec/kitabu/parser/mobi_spec.rb +14 -0
- data/spec/kitabu/parser/pdf_spec.rb +18 -1
- data/spec/kitabu/parser/txt_spec.rb +14 -0
- data/spec/spec_helper.rb +10 -6
- data/spec/support/mybook/config/helper.rb +4 -29
- data/spec/support/mybook/config/kitabu.yml +0 -10
- data/spec/support/mybook/templates/epub/cover.erb +4 -3
- data/{templates → spec/support/mybook/templates/epub}/cover.png +0 -0
- data/spec/support/mybook/templates/epub/page.erb +3 -2
- data/spec/support/mybook/templates/html/layout.erb +10 -13
- data/spec/support/mybook/templates/styles/epub.scss +3 -0
- data/spec/support/mybook/templates/styles/html.scss +3 -0
- data/spec/support/mybook/templates/styles/pdf.scss +3 -0
- data/spec/support/mybook/templates/styles/print.scss +3 -0
- data/spec/support/mybook/text/{01_Markdown_Chapter.markdown → 01_Markdown_Chapter.md} +2 -3
- data/spec/support/mybook/text/02_ERB_Chapter.md.erb +7 -0
- data/spec/support/mybook/text/{04_With_Directory/Some_Chapter.mkdn → 03_With_Directory/Some_Chapter.md} +0 -0
- data/spec/support/mybook/text/{CHANGELOG.textile → CHANGELOG.md} +2 -2
- data/spec/support/mybook/text/{TOC.textile → TOC.md} +0 -0
- data/spec/support/mybook/text/{_00_Introduction.markdown → _00_Introduction.md} +0 -0
- data/spec/support/shared.rb +14 -10
- data/templates/Gemfile +3 -3
- data/templates/Guardfile +1 -5
- data/templates/config.erb +5 -5
- data/templates/cover.erb +4 -3
- data/templates/epub.erb +3 -2
- data/templates/helper.rb +28 -29
- data/templates/images/.gitkeep +0 -0
- data/templates/images/kitabu-icon.png +0 -0
- data/templates/images/kitabu-icon.svg +19 -0
- data/templates/images/kitabu-word.png +0 -0
- data/templates/images/kitabu-word.svg +14 -0
- data/templates/images/kitabu.png +0 -0
- data/templates/images/kitabu.svg +20 -0
- data/{examples/RailsGuides/templates → templates/templates/epub}/cover.erb +4 -3
- data/templates/templates/epub/cover.png +0 -0
- data/templates/templates/epub/page.erb +16 -0
- data/templates/{layout.erb → templates/html/layout.erb} +22 -11
- data/templates/templates/styles/epub.scss +1 -0
- data/templates/templates/styles/files/_normalize.scss +427 -0
- data/templates/templates/styles/html.scss +252 -0
- data/templates/templates/styles/pdf.scss +371 -0
- data/templates/templates/styles/print.scss +2 -0
- data/templates/text/01_Getting_Started.md +26 -0
- data/templates/text/02_Creating_Chapters.md +22 -0
- data/templates/text/03_Syntax_Highlighting.erb +69 -0
- data/templates/text/04_Dynamic_Content.erb +64 -0
- data/templates/text/05_Exporting_Files.md +49 -0
- metadata +143 -83
- data/README.rdoc +0 -218
- data/examples/RailsGuides/config/helper.rb +0 -29
- data/examples/RailsGuides/config/kitabu.yml +0 -44
- data/examples/RailsGuides/images/challenge.png +0 -0
- data/examples/RailsGuides/images/posts_index.png +0 -0
- data/examples/RailsGuides/images/rails_welcome.png +0 -0
- data/examples/RailsGuides/output/RailsGuides.epub +0 -0
- data/examples/RailsGuides/output/RailsGuides.html +0 -1556
- data/examples/RailsGuides/output/RailsGuides.pdf +3 -4934
- data/examples/RailsGuides/templates/layout.css +0 -352
- data/examples/RailsGuides/templates/layout.erb +0 -43
- data/examples/RailsGuides/templates/syntax.css +0 -62
- data/examples/RailsGuides/templates/user.css +0 -19
- data/examples/RailsGuides/text/01_Guide_Assumptions.mkdn +0 -13
- data/examples/RailsGuides/text/02_What_is_Rails.mkdn +0 -106
- data/examples/RailsGuides/text/03_Creating_a_new_Rails_project.mkdn +0 -200
- data/examples/RailsGuides/text/04_Hello_Rails.mkdn +0 -62
- data/examples/RailsGuides/text/05_Getting_Up_and_Running_Quickly_with_Scaffolding.mkdn +0 -4
- data/examples/RailsGuides/text/06_Creating_a_resource.mkdn +0 -503
- data/examples/RailsGuides/text/07_Adding_a_second_model.mkdn +0 -232
- data/examples/RailsGuides/text/08_Refactoring.mkdn +0 -123
- data/examples/RailsGuides/text/09_Deleting_comments.mkdn +0 -57
- data/examples/RailsGuides/text/09_Security.mkdn +0 -56
- data/examples/RailsGuides/text/10_Building_a_multi_model_form.mkdn +0 -130
- data/examples/RailsGuides/text/11_View_helpers.mkdn +0 -50
- data/examples/RailsGuides/text/12_Whats_next.mkdn +0 -14
- data/examples/RailsGuides/text/13_Configuration_gotchas.mkdn +0 -10
- data/lib/kitabu/adapters/markdown.rb +0 -34
- data/lib/kitabu/extensions/redcloth.rb +0 -69
- data/lib/kitabu/syntax.rb +0 -130
- data/spec/kitabu/extensions/redcloth_spec.rb +0 -57
- data/spec/kitabu/syntax_spec.rb +0 -106
- data/spec/support/mybook/templates/html/layout.css +0 -353
- data/spec/support/mybook/templates/html/syntax.css +0 -58
- data/spec/support/mybook/templates/html/user.css +0 -1
- data/spec/support/mybook/text/02_Textile_Chapter.textile +0 -3
- data/spec/support/mybook/text/03_HTML_Chapter.html +0 -3
- data/templates/epub.css +0 -500
- data/templates/layout.css +0 -353
- data/templates/sample.md +0 -6
- data/templates/syntax.css +0 -58
- data/templates/user.css +0 -1
data/lib/kitabu/parser/mobi.rb
CHANGED
data/lib/kitabu/parser/pdf.rb
CHANGED
@@ -3,11 +3,13 @@ module Kitabu
|
|
3
3
|
class PDF < Base
|
4
4
|
def parse
|
5
5
|
apply_footnotes!
|
6
|
-
spawn_command ["prince",
|
6
|
+
spawn_command ["prince", html_for_pdf.to_s, "-o", pdf_file.to_s]
|
7
|
+
spawn_command ["prince", html_for_print.to_s, "-o", print_file.to_s]
|
7
8
|
end
|
8
9
|
|
9
10
|
def apply_footnotes!
|
10
11
|
html = Nokogiri::HTML(html_file.read)
|
12
|
+
footnote_count = 1
|
11
13
|
|
12
14
|
# https://github.com/sparklemotion/nokogiri/issues/339
|
13
15
|
html.css("html").first.tap do |element|
|
@@ -16,22 +18,60 @@ module Kitabu
|
|
16
18
|
element.delete("xml:lang")
|
17
19
|
end
|
18
20
|
|
19
|
-
html.css("
|
20
|
-
fn.node_name = "span"
|
21
|
-
fn.set_attribute("class", "fn")
|
21
|
+
chapters = html.css(".chapter")
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
chapters.each do |chapter|
|
24
|
+
footnotes = chapter.css(".footnotes li")
|
25
|
+
|
26
|
+
footnotes.each do |fn|
|
27
|
+
# Get current footnote number
|
28
|
+
footnote_number = footnote_count
|
29
|
+
footnote_count += 1
|
30
|
+
|
31
|
+
# Remove rev links
|
32
|
+
fn.css('[rev=footnote]').map(&:remove)
|
33
|
+
|
34
|
+
# Create an element for storing the footnote description
|
35
|
+
fn_desc = Nokogiri::XML::Node.new('span', Nokogiri::HTML::DocumentFragment.parse(''))
|
36
|
+
fn_desc.set_attribute 'class', 'fn-desc'
|
37
|
+
fn_desc.inner_html = fn.css('p').map(&:inner_html).join("\n")
|
38
|
+
|
39
|
+
# Find ref based on footnote's id
|
40
|
+
fn_id = fn.get_attribute('id')
|
41
|
+
ref = chapter.css("a[href='##{fn_id}']").first
|
42
|
+
|
43
|
+
# Go up to parent and reformat it.
|
44
|
+
sup = ref.parent
|
45
|
+
sup.delete("id")
|
46
|
+
sup.set_attribute 'class', 'fn-ref'
|
47
|
+
sup.inner_html = ''
|
48
|
+
|
49
|
+
# Finally, add the description after the <sup> tag.
|
50
|
+
sup.after(fn_desc)
|
25
51
|
end
|
52
|
+
|
53
|
+
# Remove the footnotes element
|
54
|
+
chapter.css('.footnotes').map(&:remove)
|
26
55
|
end
|
27
56
|
|
28
|
-
|
57
|
+
create_html_file(html_for_print, html, 'print')
|
58
|
+
create_html_file(html_for_pdf, html, 'pdf')
|
29
59
|
end
|
30
60
|
|
31
|
-
def
|
61
|
+
def create_html_file(target, html, class_name)
|
62
|
+
html.css("html").first.set_attribute "class", class_name
|
63
|
+
html.css("link[name=stylesheet]").first.set_attribute "href", "styles/#{class_name}.css"
|
64
|
+
File.open(target, "w") {|f| f << html.to_html }
|
65
|
+
end
|
66
|
+
|
67
|
+
def html_for_pdf
|
32
68
|
root_dir.join("output/#{name}.pdf.html")
|
33
69
|
end
|
34
70
|
|
71
|
+
def html_for_print
|
72
|
+
root_dir.join("output/#{name}.print.html")
|
73
|
+
end
|
74
|
+
|
35
75
|
def html_file
|
36
76
|
root_dir.join("output/#{name}.html")
|
37
77
|
end
|
@@ -39,6 +79,10 @@ module Kitabu
|
|
39
79
|
def pdf_file
|
40
80
|
root_dir.join("output/#{name}.pdf")
|
41
81
|
end
|
82
|
+
|
83
|
+
def print_file
|
84
|
+
root_dir.join("output/#{name}.print.pdf")
|
85
|
+
end
|
42
86
|
end
|
43
87
|
end
|
44
88
|
end
|
data/lib/kitabu/version.rb
CHANGED
@@ -3,15 +3,15 @@ require "spec_helper"
|
|
3
3
|
describe Kitabu::Cli do
|
4
4
|
context "while running export" do
|
5
5
|
it "exits with status 1 when an invalid --only option is provided" do
|
6
|
-
expect
|
6
|
+
expect(->{
|
7
7
|
capture(:stderr){ Kitabu::Cli.start(["export", "--only=invalid"]) }
|
8
|
-
}.to exit_with_code(1)
|
8
|
+
}).to exit_with_code(1)
|
9
9
|
end
|
10
10
|
|
11
11
|
it "exits with status 1 when no config file is found" do
|
12
|
-
expect
|
12
|
+
expect(->{
|
13
13
|
capture(:stderr){ Kitabu::Cli.start(["export"]) }
|
14
|
-
}.to exit_with_code(1)
|
14
|
+
}).to exit_with_code(1)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/spec/kitabu/cli/new_spec.rb
CHANGED
@@ -13,9 +13,9 @@ describe Kitabu::Cli do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "exits with status 1 when no path is provided" do
|
16
|
-
expect
|
16
|
+
expect(->{
|
17
17
|
capture(:stderr){ Kitabu::Cli.start(["new"]) }
|
18
|
-
}.to exit_with_code(1)
|
18
|
+
}).to exit_with_code(1)
|
19
19
|
|
20
20
|
expect(File).not_to be_directory(tmpdir.join("mybook"))
|
21
21
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kitabu::Markdown do
|
4
|
+
it 'enables fenced code blocks' do
|
5
|
+
html = Kitabu::Markdown.render <<-TEXT.strip_heredoc
|
6
|
+
```ruby
|
7
|
+
class User
|
8
|
+
end
|
9
|
+
```
|
10
|
+
TEXT
|
11
|
+
|
12
|
+
expect(html).to include('<pre class="highlight ruby">')
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'enables options' do
|
16
|
+
html = Kitabu::Markdown.render <<-TEXT.strip_heredoc
|
17
|
+
```php?start_inline=true
|
18
|
+
echo 'Hello';
|
19
|
+
```
|
20
|
+
TEXT
|
21
|
+
|
22
|
+
expect(html).to include('<span class="k">echo</span>')
|
23
|
+
end
|
24
|
+
end
|
@@ -18,24 +18,23 @@ describe Kitabu::Parser::HTML do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it "skips files that start with underscore" do
|
21
|
-
expect(relative).not_to include("_00_Introduction.
|
21
|
+
expect(relative).not_to include("_00_Introduction.md")
|
22
22
|
end
|
23
23
|
|
24
24
|
it "skips other files" do
|
25
|
-
expect(relative).not_to include("CHANGELOG.
|
26
|
-
expect(relative).not_to include("TOC.
|
25
|
+
expect(relative).not_to include("CHANGELOG.md")
|
26
|
+
expect(relative).not_to include("TOC.md")
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns only first-level entries" do
|
30
|
-
expect(relative).not_to include("
|
30
|
+
expect(relative).not_to include("03_With_Directory/Some_Chapter.md")
|
31
31
|
end
|
32
32
|
|
33
33
|
it "returns entries" do
|
34
|
-
expect(relative.first).to eq("01_Markdown_Chapter.
|
35
|
-
expect(relative.second).to eq("
|
36
|
-
expect(relative.third).to eq("
|
37
|
-
expect(relative.fourth).to
|
38
|
-
expect(relative.fifth).to be_nil
|
34
|
+
expect(relative.first).to eq("01_Markdown_Chapter.md")
|
35
|
+
expect(relative.second).to eq("02_ERB_Chapter.md.erb")
|
36
|
+
expect(relative.third).to eq("03_With_Directory")
|
37
|
+
expect(relative.fourth).to be_nil
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
@@ -44,24 +43,12 @@ describe Kitabu::Parser::HTML do
|
|
44
43
|
let(:html) { File.read(file) }
|
45
44
|
before { parser.parse }
|
46
45
|
|
47
|
-
it "
|
48
|
-
expect(
|
49
|
-
end
|
50
|
-
|
51
|
-
it "renders .markdown" do
|
52
|
-
expect(html).to have_tag("div.chapter > h2#markdown", "Markdown")
|
53
|
-
end
|
54
|
-
|
55
|
-
it "renders .mkdn" do
|
56
|
-
expect(html).to have_tag("div.chapter > h2#some-chapter", "Some Chapter")
|
57
|
-
end
|
58
|
-
|
59
|
-
it "renders .textile" do
|
60
|
-
expect(html).to have_tag("div.chapter > h2#textile", "Textile")
|
46
|
+
it "keeps html file around" do
|
47
|
+
expect(file).to be_file
|
61
48
|
end
|
62
49
|
|
63
|
-
it "
|
64
|
-
expect(html).to have_tag("div.chapter
|
50
|
+
it "has several chapters" do
|
51
|
+
expect(html).to have_tag("div.chapter", 3)
|
65
52
|
end
|
66
53
|
|
67
54
|
it "uses config file" do
|
@@ -71,5 +58,13 @@ describe Kitabu::Parser::HTML do
|
|
71
58
|
it "renders changelog" do
|
72
59
|
expect(html).to have_tag("div.changelog h2", "Revisions")
|
73
60
|
end
|
61
|
+
|
62
|
+
it "renders erb" do
|
63
|
+
expect(html).to have_tag("h2", "ERB")
|
64
|
+
end
|
65
|
+
|
66
|
+
it "renders erb blocks" do
|
67
|
+
expect(html).to have_tag("div.note.info > p", "This is a note!")
|
68
|
+
end
|
74
69
|
end
|
75
70
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Kitabu::Parser::Mobi, kindlegen: Kitabu::Dependency.kindlegen? do
|
4
|
+
let(:root) { SPECDIR.join("support/mybook") }
|
5
|
+
|
6
|
+
before do
|
7
|
+
Kitabu::Parser::HTML.parse(root)
|
8
|
+
Kitabu::Parser::Mobi.parse(root)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "generates mobi" do
|
12
|
+
expect(root.join("output/mybook.mobi")).to be_file
|
13
|
+
end
|
14
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Kitabu::Parser::PDF do
|
3
|
+
describe Kitabu::Parser::PDF, prince: Kitabu::Dependency.prince? do
|
4
4
|
let(:root) { SPECDIR.join("support/mybook") }
|
5
5
|
|
6
6
|
before do
|
@@ -8,6 +8,23 @@ describe Kitabu::Parser::PDF do
|
|
8
8
|
Kitabu::Parser::PDF.new(root).parse
|
9
9
|
end
|
10
10
|
|
11
|
+
it "creates html with css identifier" do
|
12
|
+
expect(root.join("output/mybook.pdf.html").read).to have_tag('html.pdf')
|
13
|
+
expect(root.join("output/mybook.print.html").read).to have_tag('html.print')
|
14
|
+
end
|
15
|
+
|
16
|
+
it "sets stylesheet for print pdf" do
|
17
|
+
expect(root.join("output/mybook.print.html").read).to have_tag('link[rel=stylesheet][href="styles/print.css"]')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "sets stylesheet for pdf" do
|
21
|
+
expect(root.join("output/mybook.pdf.html").read).to have_tag('link[rel=stylesheet][href="styles/pdf.css"]')
|
22
|
+
end
|
23
|
+
|
24
|
+
it "generates pdf file for print" do
|
25
|
+
expect(root.join("output/mybook.print.pdf")).to be_file
|
26
|
+
end
|
27
|
+
|
11
28
|
it "generates pdf file" do
|
12
29
|
expect(root.join("output/mybook.pdf")).to be_file
|
13
30
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Kitabu::Parser::Txt, html2text: Kitabu::Dependency.html2text? do
|
4
|
+
let(:root) { SPECDIR.join("support/mybook") }
|
5
|
+
|
6
|
+
before do
|
7
|
+
Kitabu::Parser::HTML.parse(root)
|
8
|
+
Kitabu::Parser::Txt.parse(root)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "generates text file" do
|
12
|
+
expect(root.join("output/mybook.txt")).to be_file
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
require "codeclimate-test-reporter"
|
2
|
+
CodeClimate::TestReporter.start
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
|
1
6
|
require "kitabu"
|
2
7
|
require "pathname"
|
3
8
|
|
@@ -17,15 +22,14 @@ RSpec.configure do |config|
|
|
17
22
|
config.include(SpecHelper)
|
18
23
|
config.include(Matchers)
|
19
24
|
|
25
|
+
config.filter_run_excluding html2text: false, kindlegen: false, prince: false
|
26
|
+
|
20
27
|
cleaner = proc do
|
21
|
-
[
|
22
|
-
TMPDIR,
|
23
|
-
SPECDIR.join("support/mybook/output/mybook.pdf"),
|
24
|
-
SPECDIR.join("support/mybook/output/mybook.epub"),
|
25
|
-
SPECDIR.join("support/mybook/output/mybook.html")
|
26
|
-
].each do |i|
|
28
|
+
[TMPDIR].each do |i|
|
27
29
|
FileUtils.rm_rf(i) if File.exist?(i)
|
28
30
|
end
|
31
|
+
|
32
|
+
Dir.chdir File.expand_path('../..', __FILE__)
|
29
33
|
end
|
30
34
|
|
31
35
|
config.before(&cleaner)
|
@@ -1,29 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# module Formatters
|
6
|
-
# module HTML
|
7
|
-
# def attention(options)
|
8
|
-
# %[<p class="attention">#{options[:text]}</p>]
|
9
|
-
# end
|
10
|
-
# end
|
11
|
-
# end
|
12
|
-
# end
|
13
|
-
#
|
14
|
-
# Then you can just use `attention. This is an important note!` on your text.
|
15
|
-
#
|
16
|
-
# You can add inline formatters as well. The approach is slightly different,
|
17
|
-
# but pretty straightforward.
|
18
|
-
#
|
19
|
-
# Add your formatter to `RedCloth::INLINE_FORMATTERS` and implement the method, making sure that it
|
20
|
-
# replaces the content using `String#gsub!`.
|
21
|
-
#
|
22
|
-
# module RedCloth
|
23
|
-
# def my_formatter(text)
|
24
|
-
# text.gsub!(/Hello/, "Hi")
|
25
|
-
# end
|
26
|
-
# end
|
27
|
-
#
|
28
|
-
# RedCloth::INLINE_FORMATTERS << :my_formatter
|
29
|
-
#
|
1
|
+
module Kitabu
|
2
|
+
module Helpers
|
3
|
+
end
|
4
|
+
end
|
@@ -43,13 +43,3 @@ authors:
|
|
43
43
|
|
44
44
|
# The base URL from your source code.
|
45
45
|
base_url: http://example.com
|
46
|
-
|
47
|
-
# You can rename your text structure automatically.
|
48
|
-
# All you have to do is using a list will all your chapters and
|
49
|
-
# then you can run `kitabu rearrange`.
|
50
|
-
structure:
|
51
|
-
- Markdown_Chapter.markdown
|
52
|
-
- Textile_Chapter.textile
|
53
|
-
- HTML_Chapter.html
|
54
|
-
- With_Directory
|
55
|
-
- Some_Chapter.mkdn
|
@@ -2,15 +2,16 @@
|
|
2
2
|
<!DOCTYPE html PUBLIC
|
3
3
|
"-//W3C//DTD XHTML 1.1//EN"
|
4
4
|
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
5
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= language %>">
|
5
|
+
<html class="epub" xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= language %>">
|
6
6
|
<head>
|
7
7
|
<title><%= title %></title>
|
8
|
-
<link rel="stylesheet" href="
|
8
|
+
<link rel="stylesheet" href="styles/epub.css" type="text/css" />
|
9
9
|
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
|
10
10
|
</head>
|
11
|
+
|
11
12
|
<body>
|
12
13
|
<div>
|
13
|
-
|
14
|
+
<h1><%= title %></h1>
|
14
15
|
</div>
|
15
16
|
</body>
|
16
17
|
</html>
|
File without changes
|
@@ -1,10 +1,11 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= language %>">
|
3
|
+
<html class="epub" xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= language %>">
|
4
4
|
<head>
|
5
5
|
<title></title>
|
6
6
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
7
|
-
<link rel="stylesheet" type="text/css" href="
|
7
|
+
<link rel="stylesheet" type="text/css" href="styles/epub.css"/>
|
8
|
+
<%= highlight_theme('github') %>
|
8
9
|
</head>
|
9
10
|
|
10
11
|
<body>
|
@@ -1,17 +1,14 @@
|
|
1
|
-
<!
|
2
|
-
|
3
|
-
<html>
|
1
|
+
<!doctype html>
|
2
|
+
<html class="html">
|
4
3
|
<head>
|
5
4
|
<title><%= title %></title>
|
6
5
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
7
|
-
<link rel="stylesheet" type="text/css" href="
|
8
|
-
<link rel="stylesheet" type="text/css" href="../templates/html/syntax.css"/>
|
9
|
-
<link rel="stylesheet" type="text/css" href="../templates/html/user.css"/>
|
10
|
-
|
6
|
+
<link name="stylesheet" rel="stylesheet" type="text/css" href="styles/html.css" />
|
11
7
|
<meta name="author" content="<%= authors.join(', ') %>" />
|
12
8
|
<meta name="subject" content="<%= subject %>" />
|
13
9
|
<meta name="keywords" content="<%= keywords %>" />
|
14
10
|
<meta name="date" content="<%= published_at %>" />
|
11
|
+
<%= highlight_theme('github') %>
|
15
12
|
</head>
|
16
13
|
<body>
|
17
14
|
<div class="frontcover container">
|
@@ -33,6 +30,12 @@
|
|
33
30
|
<%= content %>
|
34
31
|
</div>
|
35
32
|
|
33
|
+
<% if changelog %>
|
34
|
+
<div class="container changelog">
|
35
|
+
<%= changelog %>
|
36
|
+
</div>
|
37
|
+
<% end %>
|
38
|
+
|
36
39
|
<div class="imprint container">
|
37
40
|
<div>
|
38
41
|
<h2><%= title %></h2>
|
@@ -40,11 +43,5 @@
|
|
40
43
|
<p><%= copyright %></p>
|
41
44
|
</div>
|
42
45
|
</div>
|
43
|
-
|
44
|
-
<% if changelog %>
|
45
|
-
<div class="container changelog">
|
46
|
-
<%= changelog %>
|
47
|
-
</div>
|
48
|
-
<% end %>
|
49
46
|
</body>
|
50
47
|
</html>
|