kitabu 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +18 -0
- data/README.md +23 -2
- data/lib/kitabu.rb +3 -2
- data/lib/kitabu/exporter/base.rb +2 -0
- data/lib/kitabu/exporter/css.rb +1 -0
- data/lib/kitabu/exporter/epub.rb +1 -1
- data/lib/kitabu/exporter/html.rb +7 -0
- data/lib/kitabu/extensions/rouge.rb +2 -1
- data/lib/kitabu/generator.rb +3 -0
- data/lib/kitabu/toc/html.rb +7 -1
- data/lib/kitabu/toc/html/stream.rb +31 -0
- data/lib/kitabu/version.rb +1 -1
- data/spec/kitabu/exporter/html_spec.rb +11 -0
- data/spec/kitabu/markdown_spec.rb +10 -0
- data/spec/kitabu/toc/html_spec.rb +22 -18
- data/spec/support/mybook/fonts/OpenSans-CondBold.ttf +0 -0
- data/spec/support/shared.rb +4 -0
- metadata +5 -5
- data/Gemfile.lock +0 -108
- data/lib/kitabu/stream.rb +0 -27
- data/lib/kitabu/toc.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e80a74dc472390fc4a60fa9d1efcb58883ab3a8
|
4
|
+
data.tar.gz: 5d0ff304f818d482a9d7553b6d338f789c38b799
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7517d568da3ccbd2804f42c7fa9dc7905778acca3a26a82e58ffab6965dab7bd232b1bf2134f10fff62559a1e3fedbbb6471b51c1f0d48412775990c59c303f5
|
7
|
+
data.tar.gz: 1dc60c65a50467a337dd6db0b4da2a01da2260b0257810b315e336e4fdfc58f4b428e39561bcf43d55c0be76572b80b3da8ba8ad188634981170052bb51b0c5f
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v2.0.4
|
4
|
+
|
5
|
+
- Support fonts directory
|
6
|
+
- Allow having any element as the chapter title (e.g. h1). Previously you could only use h2.
|
7
|
+
- Bug fix: unknown Rouge lexer was raising an error.
|
8
|
+
|
9
|
+
## v2.0.3
|
10
|
+
|
11
|
+
- Bug fix: footnote label wasn't updated with current count
|
12
|
+
|
13
|
+
## v2.0.2
|
14
|
+
|
15
|
+
- Bug fix: generate valid HTML markup
|
16
|
+
|
17
|
+
## v2.0.1
|
18
|
+
|
19
|
+
- Improve footnote generation
|
20
|
+
|
3
21
|
## v2.0.0
|
4
22
|
|
5
23
|
- Remove support for different markdown processors; now using Redcarpet.
|
data/README.md
CHANGED
@@ -125,7 +125,7 @@ To print the TOC, you need to print a variable called `toc`, using the eRb tag.
|
|
125
125
|
|
126
126
|
<%= toc %>
|
127
127
|
|
128
|
-
|
128
|
+
### Using ERB
|
129
129
|
|
130
130
|
You can also have `.erb` files. You can mix Markdown and HTML, like the following:
|
131
131
|
|
@@ -189,7 +189,28 @@ The following Redcarpet options are enabled:
|
|
189
189
|
* `superscript`
|
190
190
|
* `tables`
|
191
191
|
|
192
|
-
###
|
192
|
+
### Using custom fonts
|
193
|
+
|
194
|
+
You can use custom fonts for your PDF. Just add them to the `fonts` directory (you can create this directory on your book's root directory if it doesn't exist).
|
195
|
+
|
196
|
+
Then, on `templates/styles/pdf.scss` you can add the `@font-face` declaration.
|
197
|
+
|
198
|
+
```css
|
199
|
+
@font-face {
|
200
|
+
font-family: 'Open Sans Condensed Bold';
|
201
|
+
src: url('../fonts/OpenSans-CondBold.ttf');
|
202
|
+
}
|
203
|
+
```
|
204
|
+
|
205
|
+
Finally, to use this font, do something like this:
|
206
|
+
|
207
|
+
```css
|
208
|
+
.chapter > h2 {
|
209
|
+
font-family: 'Open Sans Condensed Bold';
|
210
|
+
}
|
211
|
+
```
|
212
|
+
|
213
|
+
## References
|
193
214
|
|
194
215
|
* Markdown: <http://daringfireball.net/projects/markdown/syntax>
|
195
216
|
* Markdown PHP: <https://michelf.ca/projects/php-markdown/extra/>
|
data/lib/kitabu.rb
CHANGED
@@ -37,7 +37,6 @@ module Kitabu
|
|
37
37
|
require "kitabu/errors"
|
38
38
|
require "kitabu/version"
|
39
39
|
require "kitabu/generator"
|
40
|
-
require "kitabu/toc"
|
41
40
|
require "kitabu/cli"
|
42
41
|
require "kitabu/markdown"
|
43
42
|
require "kitabu/source_list"
|
@@ -52,7 +51,9 @@ module Kitabu
|
|
52
51
|
require "kitabu/footnotes/base"
|
53
52
|
require "kitabu/footnotes/html"
|
54
53
|
require "kitabu/footnotes/pdf"
|
55
|
-
require "kitabu/
|
54
|
+
require "kitabu/toc/html"
|
55
|
+
require "kitabu/toc/html/stream"
|
56
|
+
require "kitabu/toc/epub"
|
56
57
|
require "kitabu/dependency"
|
57
58
|
require "kitabu/stats"
|
58
59
|
require "kitabu/helpers"
|
data/lib/kitabu/exporter/base.rb
CHANGED
data/lib/kitabu/exporter/css.rb
CHANGED
data/lib/kitabu/exporter/epub.rb
CHANGED
data/lib/kitabu/exporter/html.rb
CHANGED
@@ -13,6 +13,7 @@ module Kitabu
|
|
13
13
|
#
|
14
14
|
def export
|
15
15
|
copy_images!
|
16
|
+
copy_fonts!
|
16
17
|
export_stylesheets!
|
17
18
|
|
18
19
|
File.open(root_dir.join("output/#{name}.html"), "w") do |file|
|
@@ -99,6 +100,12 @@ module Kitabu
|
|
99
100
|
copy_directory("images", "output/images")
|
100
101
|
end
|
101
102
|
|
103
|
+
# Copy font files
|
104
|
+
#
|
105
|
+
def copy_fonts!
|
106
|
+
copy_directory("fonts", "output/fonts")
|
107
|
+
end
|
108
|
+
|
102
109
|
# Export all root stylesheets.
|
103
110
|
#
|
104
111
|
def export_stylesheets!
|
@@ -2,7 +2,8 @@ module Rouge
|
|
2
2
|
module Plugins
|
3
3
|
module Redcarpet
|
4
4
|
def rouge_formatter(lexer)
|
5
|
-
|
5
|
+
options = lexer.respond_to?(:options) ? lexer.options : {}
|
6
|
+
Formatters::HTML.new({css_class: "highlight #{lexer.tag}"}.merge(options))
|
6
7
|
end
|
7
8
|
end
|
8
9
|
end
|
data/lib/kitabu/generator.rb
CHANGED
@@ -43,12 +43,15 @@ module Kitabu
|
|
43
43
|
|
44
44
|
def create_directories
|
45
45
|
empty_directory "output"
|
46
|
+
empty_directory "fonts"
|
46
47
|
end
|
47
48
|
|
48
49
|
def create_git_files
|
49
50
|
create_file ".gitignore" do
|
50
51
|
"/output"
|
51
52
|
end
|
53
|
+
|
54
|
+
create_file "fonts/.keep"
|
52
55
|
end
|
53
56
|
|
54
57
|
def copy_guardfile
|
data/lib/kitabu/toc/html.rb
CHANGED
@@ -69,7 +69,13 @@ module Kitabu
|
|
69
69
|
def to_html
|
70
70
|
String.new.tap do |html|
|
71
71
|
toc.each do |options|
|
72
|
-
html << %[
|
72
|
+
html << %[
|
73
|
+
<div class="level#{options[:level]} #{options[:permalink]}">
|
74
|
+
<a href="##{options[:permalink]}">
|
75
|
+
<span>#{CGI.escape_html(options[:text])}</span>
|
76
|
+
</a>
|
77
|
+
</div>
|
78
|
+
]
|
73
79
|
end
|
74
80
|
end
|
75
81
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Kitabu
|
2
|
+
module TOC
|
3
|
+
class HTML
|
4
|
+
class Stream
|
5
|
+
attr_accessor :listener, :content
|
6
|
+
attr_reader :html
|
7
|
+
|
8
|
+
def initialize(content, listener)
|
9
|
+
@content = content
|
10
|
+
@listener = listener
|
11
|
+
@html = Nokogiri::HTML.parse(content)
|
12
|
+
end
|
13
|
+
|
14
|
+
def parse
|
15
|
+
traverse(html)
|
16
|
+
end
|
17
|
+
|
18
|
+
def traverse(node)
|
19
|
+
node.children.each do |child|
|
20
|
+
emit(child)
|
21
|
+
traverse(child)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def emit(node)
|
26
|
+
listener.tag(node) if node.name =~ /h[1-6]/
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/kitabu/version.rb
CHANGED
@@ -42,5 +42,16 @@ describe Kitabu::Exporter::HTML do
|
|
42
42
|
it "renders erb blocks" do
|
43
43
|
expect(html).to have_tag("div.note.info > p", "This is a note!")
|
44
44
|
end
|
45
|
+
|
46
|
+
it "copies fonts" do
|
47
|
+
expect(root.join('output/fonts/OpenSans-CondBold.ttf')).to be_file
|
48
|
+
end
|
49
|
+
|
50
|
+
it "exports css files" do
|
51
|
+
expect(root.join('output/styles/epub.css')).to be_file
|
52
|
+
expect(root.join('output/styles/html.css')).to be_file
|
53
|
+
expect(root.join('output/styles/pdf.css')).to be_file
|
54
|
+
expect(root.join('output/styles/print.css')).to be_file
|
55
|
+
end
|
45
56
|
end
|
46
57
|
end
|
@@ -21,4 +21,14 @@ describe Kitabu::Markdown do
|
|
21
21
|
|
22
22
|
expect(html).to include('<span class="k">echo</span>')
|
23
23
|
end
|
24
|
+
|
25
|
+
it 'does not raise with unknown lexers' do
|
26
|
+
expect {
|
27
|
+
Kitabu::Markdown.render <<-TEXT.strip_heredoc
|
28
|
+
```terminal
|
29
|
+
Text plain.
|
30
|
+
```
|
31
|
+
TEXT
|
32
|
+
}.not_to raise_error
|
33
|
+
end
|
24
34
|
end
|
@@ -2,6 +2,10 @@
|
|
2
2
|
require "spec_helper"
|
3
3
|
|
4
4
|
describe Kitabu::TOC::HTML do
|
5
|
+
def regexp(text)
|
6
|
+
/#{Regexp.escape(text)}/
|
7
|
+
end
|
8
|
+
|
5
9
|
HTML = <<-HTML
|
6
10
|
<h1>Item 1</h1>
|
7
11
|
<h2>Item 1.2</h2>
|
@@ -26,30 +30,30 @@ describe Kitabu::TOC::HTML do
|
|
26
30
|
end
|
27
31
|
|
28
32
|
it "generates toc" do
|
29
|
-
expect(html).to have_tag("div.level1.item-1", "Item 1")
|
30
|
-
expect(html).to have_tag("div.level2.item-1-2", "Item 1.2")
|
31
|
-
expect(html).to have_tag("div.level3.item-1-1-3", "Item 1.1.3")
|
32
|
-
expect(html).to have_tag("div.level4.item-1-1-1-4", "Item 1.1.1.4")
|
33
|
-
expect(html).to have_tag("div.level5.item-1-1-1-1-5", "Item 1.1.1.1.5")
|
34
|
-
expect(html).to have_tag("div.level6.item-1-1-1-1-1-6", "Item 1.1.1.1.1.6")
|
33
|
+
expect(html).to have_tag("div.level1.item-1", regexp("Item 1"))
|
34
|
+
expect(html).to have_tag("div.level2.item-1-2", regexp("Item 1.2"))
|
35
|
+
expect(html).to have_tag("div.level3.item-1-1-3", regexp("Item 1.1.3"))
|
36
|
+
expect(html).to have_tag("div.level4.item-1-1-1-4", regexp("Item 1.1.1.4"))
|
37
|
+
expect(html).to have_tag("div.level5.item-1-1-1-1-5", regexp("Item 1.1.1.1.5"))
|
38
|
+
expect(html).to have_tag("div.level6.item-1-1-1-1-1-6", regexp("Item 1.1.1.1.1.6"))
|
35
39
|
|
36
|
-
expect(html).to have_tag("div.level2.item-2-1", "Item 2.1")
|
37
|
-
expect(html).to have_tag("div.level2.item-2-1-again", "Item 2.1 again")
|
40
|
+
expect(html).to have_tag("div.level2.item-2-1", regexp("Item 2.1"))
|
41
|
+
expect(html).to have_tag("div.level2.item-2-1-again", regexp("Item 2.1 again"))
|
38
42
|
|
39
|
-
expect(html).to have_tag("div.level2.internacionalizacao", "Internacionalização")
|
43
|
+
expect(html).to have_tag("div.level2.internacionalizacao", regexp("Internacionalização"))
|
40
44
|
end
|
41
45
|
|
42
46
|
it "adds id attribute to content" do
|
43
|
-
expect(content).to have_tag("h1#item-1", "Item 1")
|
44
|
-
expect(content).to have_tag("h2#item-1-2", "Item 1.2")
|
45
|
-
expect(content).to have_tag("h3#item-1-1-3", "Item 1.1.3")
|
46
|
-
expect(content).to have_tag("h4#item-1-1-1-4", "Item 1.1.1.4")
|
47
|
-
expect(content).to have_tag("h5#item-1-1-1-1-5", "Item 1.1.1.1.5")
|
48
|
-
expect(content).to have_tag("h6#item-1-1-1-1-1-6", "Item 1.1.1.1.1.6")
|
47
|
+
expect(content).to have_tag("h1#item-1", regexp("Item 1"))
|
48
|
+
expect(content).to have_tag("h2#item-1-2", regexp("Item 1.2"))
|
49
|
+
expect(content).to have_tag("h3#item-1-1-3", regexp("Item 1.1.3"))
|
50
|
+
expect(content).to have_tag("h4#item-1-1-1-4", regexp("Item 1.1.1.4"))
|
51
|
+
expect(content).to have_tag("h5#item-1-1-1-1-5", regexp("Item 1.1.1.1.5"))
|
52
|
+
expect(content).to have_tag("h6#item-1-1-1-1-1-6", regexp("Item 1.1.1.1.1.6"))
|
49
53
|
|
50
|
-
expect(content).to have_tag("h2#item-2-1", "Item 2.1")
|
51
|
-
expect(content).to have_tag("h2#item-2-1-again", "Item 2.1 again")
|
54
|
+
expect(content).to have_tag("h2#item-2-1", regexp("Item 2.1"))
|
55
|
+
expect(content).to have_tag("h2#item-2-1-again", regexp("Item 2.1 again"))
|
52
56
|
|
53
|
-
expect(content).to have_tag("h2#internacionalizacao", "Internacionalização")
|
57
|
+
expect(content).to have_tag("h2#internacionalizacao", regexp("Internacionalização"))
|
54
58
|
end
|
55
59
|
end
|
Binary file
|
data/spec/support/shared.rb
CHANGED
@@ -13,6 +13,10 @@ shared_examples_for "e-book" do
|
|
13
13
|
expect(mybook.join("text")).to be_directory
|
14
14
|
end
|
15
15
|
|
16
|
+
it "creates fonts directory" do
|
17
|
+
expect(mybook.join("fonts")).to be_directory
|
18
|
+
end
|
19
|
+
|
16
20
|
it "creates template directory" do
|
17
21
|
expect(mybook.join("templates")).to be_directory
|
18
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitabu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -250,7 +250,6 @@ files:
|
|
250
250
|
- ".travis.yml"
|
251
251
|
- CHANGELOG.md
|
252
252
|
- Gemfile
|
253
|
-
- Gemfile.lock
|
254
253
|
- README.md
|
255
254
|
- Rakefile
|
256
255
|
- attachments/browser-version.png
|
@@ -282,11 +281,10 @@ files:
|
|
282
281
|
- lib/kitabu/markdown.rb
|
283
282
|
- lib/kitabu/source_list.rb
|
284
283
|
- lib/kitabu/stats.rb
|
285
|
-
- lib/kitabu/stream.rb
|
286
284
|
- lib/kitabu/syntax/highlight.rb
|
287
|
-
- lib/kitabu/toc.rb
|
288
285
|
- lib/kitabu/toc/epub.rb
|
289
286
|
- lib/kitabu/toc/html.rb
|
287
|
+
- lib/kitabu/toc/html/stream.rb
|
290
288
|
- lib/kitabu/version.rb
|
291
289
|
- spec/kitabu/cli/export_spec.rb
|
292
290
|
- spec/kitabu/cli/new_spec.rb
|
@@ -315,6 +313,7 @@ files:
|
|
315
313
|
- spec/support/mybook/code/code.rb
|
316
314
|
- spec/support/mybook/config/helper.rb
|
317
315
|
- spec/support/mybook/config/kitabu.yml
|
316
|
+
- spec/support/mybook/fonts/OpenSans-CondBold.ttf
|
318
317
|
- spec/support/mybook/images/.gitkeep
|
319
318
|
- spec/support/mybook/images/logo.gif
|
320
319
|
- spec/support/mybook/templates/epub/cover.erb
|
@@ -417,6 +416,7 @@ test_files:
|
|
417
416
|
- spec/support/mybook/code/code.rb
|
418
417
|
- spec/support/mybook/config/helper.rb
|
419
418
|
- spec/support/mybook/config/kitabu.yml
|
419
|
+
- spec/support/mybook/fonts/OpenSans-CondBold.ttf
|
420
420
|
- spec/support/mybook/images/.gitkeep
|
421
421
|
- spec/support/mybook/images/logo.gif
|
422
422
|
- spec/support/mybook/templates/epub/cover.erb
|
data/Gemfile.lock
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
kitabu (2.0.3)
|
5
|
-
activesupport
|
6
|
-
eeepub-with-cover-support
|
7
|
-
i18n
|
8
|
-
nokogiri
|
9
|
-
notifier
|
10
|
-
redcarpet
|
11
|
-
rouge
|
12
|
-
rubyzip
|
13
|
-
sass
|
14
|
-
sass-globbing
|
15
|
-
thor
|
16
|
-
zip-zip
|
17
|
-
|
18
|
-
GEM
|
19
|
-
remote: https://rubygems.org/
|
20
|
-
specs:
|
21
|
-
activesupport (4.2.0)
|
22
|
-
i18n (~> 0.7)
|
23
|
-
json (~> 1.7, >= 1.7.7)
|
24
|
-
minitest (~> 5.1)
|
25
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
26
|
-
tzinfo (~> 1.1)
|
27
|
-
awesome_print (1.6.1)
|
28
|
-
builder (3.2.2)
|
29
|
-
byebug (3.5.1)
|
30
|
-
columnize (~> 0.8)
|
31
|
-
debugger-linecache (~> 1.2)
|
32
|
-
slop (~> 3.6)
|
33
|
-
codeclimate-test-reporter (0.4.7)
|
34
|
-
simplecov (>= 0.7.1, < 1.0.0)
|
35
|
-
coderay (1.1.0)
|
36
|
-
columnize (0.9.0)
|
37
|
-
debugger-linecache (1.2.0)
|
38
|
-
diff-lcs (1.2.5)
|
39
|
-
docile (1.1.5)
|
40
|
-
eeepub-with-cover-support (0.8.8)
|
41
|
-
builder
|
42
|
-
rubyzip
|
43
|
-
i18n (0.7.0)
|
44
|
-
json (1.8.2)
|
45
|
-
method_source (0.8.2)
|
46
|
-
mini_portile (0.6.2)
|
47
|
-
minitest (5.5.1)
|
48
|
-
multi_json (1.11.0)
|
49
|
-
nokogiri (1.6.6.2)
|
50
|
-
mini_portile (~> 0.6.0)
|
51
|
-
notifier (0.5.0)
|
52
|
-
pry (0.10.1)
|
53
|
-
coderay (~> 1.1.0)
|
54
|
-
method_source (~> 0.8.1)
|
55
|
-
slop (~> 3.4)
|
56
|
-
pry-byebug (3.0.1)
|
57
|
-
byebug (~> 3.4)
|
58
|
-
pry (~> 0.10)
|
59
|
-
pry-meta (0.0.10)
|
60
|
-
awesome_print
|
61
|
-
pry
|
62
|
-
pry-byebug
|
63
|
-
pry-remote
|
64
|
-
pry-remote (0.1.8)
|
65
|
-
pry (~> 0.9)
|
66
|
-
slop (~> 3.0)
|
67
|
-
rake (10.4.2)
|
68
|
-
redcarpet (3.2.2)
|
69
|
-
rouge (1.8.0)
|
70
|
-
rspec (3.2.0)
|
71
|
-
rspec-core (~> 3.2.0)
|
72
|
-
rspec-expectations (~> 3.2.0)
|
73
|
-
rspec-mocks (~> 3.2.0)
|
74
|
-
rspec-core (3.2.2)
|
75
|
-
rspec-support (~> 3.2.0)
|
76
|
-
rspec-expectations (3.2.0)
|
77
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
78
|
-
rspec-support (~> 3.2.0)
|
79
|
-
rspec-mocks (3.2.1)
|
80
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
-
rspec-support (~> 3.2.0)
|
82
|
-
rspec-support (3.2.2)
|
83
|
-
rubyzip (1.1.7)
|
84
|
-
sass (3.4.13)
|
85
|
-
sass-globbing (1.1.1)
|
86
|
-
sass (>= 3.1)
|
87
|
-
simplecov (0.9.2)
|
88
|
-
docile (~> 1.1.0)
|
89
|
-
multi_json (~> 1.0)
|
90
|
-
simplecov-html (~> 0.9.0)
|
91
|
-
simplecov-html (0.9.0)
|
92
|
-
slop (3.6.0)
|
93
|
-
thor (0.19.1)
|
94
|
-
thread_safe (0.3.5)
|
95
|
-
tzinfo (1.2.2)
|
96
|
-
thread_safe (~> 0.1)
|
97
|
-
zip-zip (0.3)
|
98
|
-
rubyzip (>= 1.0.0)
|
99
|
-
|
100
|
-
PLATFORMS
|
101
|
-
ruby
|
102
|
-
|
103
|
-
DEPENDENCIES
|
104
|
-
codeclimate-test-reporter
|
105
|
-
kitabu!
|
106
|
-
pry-meta
|
107
|
-
rake
|
108
|
-
rspec
|
data/lib/kitabu/stream.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
module Kitabu
|
2
|
-
class Stream
|
3
|
-
attr_accessor :listener, :content
|
4
|
-
attr_reader :html
|
5
|
-
|
6
|
-
def initialize(content, listener)
|
7
|
-
@content = content
|
8
|
-
@listener = listener
|
9
|
-
@html = Nokogiri::HTML.parse(content)
|
10
|
-
end
|
11
|
-
|
12
|
-
def parse
|
13
|
-
traverse(html)
|
14
|
-
end
|
15
|
-
|
16
|
-
def traverse(node)
|
17
|
-
node.children.each do |child|
|
18
|
-
emit(child)
|
19
|
-
traverse(child)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def emit(node)
|
24
|
-
listener.tag(node) if node.name =~ /h[1-6]/
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|