epub-parser 0.4.3 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22b0c7a7a4fb22182c41f6217122834955ef051f226eee8e14b42e8a8fa40c1e
4
- data.tar.gz: 2a1bc2ef861abf2ce1667d853503205aa334c3c47b07166ded676313c34f3800
3
+ metadata.gz: d9291e2d914a2318697ab1303feb9a2f04080c1f30d329c0e5a16cc3bf27591a
4
+ data.tar.gz: 606db4cc875875e0d4ababcba1b38cee841e64cf18535904a46397af030f691d
5
5
  SHA512:
6
- metadata.gz: 5bf25532e42f17130e300090393cb25d58fafe2f7c6bac6a68ae7d814f01973f10b4f0eba450fc03521b9829ae664b5ca27b60fec56821e2340f9768149464eb
7
- data.tar.gz: 6caf668c9ff71c7d2a12abc285103020763a984aeb90d85fbb897ca505bd95ed7c3ee407b7901a55df61fc2518de1387e636c4c52c901e8442bba7d7b768d0d8
6
+ metadata.gz: a834f8c3859d8970252d6d1d70e24f3f2c034468e4bb5b198218c5813bad0884a0cac25e229f2285ef1c7f9f9c37c8962eb242b5db2323392ceb84f340c293c3
7
+ data.tar.gz: 34badc2b282ab04c1a9aeb218e359c69d7d6042713b3bcc7851f80882dac01a847cb94b9787241f832960d0b3586e8adeed8d70b7caf6293e66a7c3cc8075dec
@@ -1,5 +1,10 @@
1
1
  = CHANGELOG
2
2
 
3
+ == 0.4.4
4
+
5
+ * [BUG FIX]Fix navigation type check bug
6
+ * Add feature to show navigations to `epubinfo` command-line tool
7
+
3
8
  == 0.4.3
4
9
 
5
10
  * Encode file name passed from file system on Unix
@@ -2,7 +2,7 @@
2
2
 
3
3
  = {doctitle}
4
4
 
5
- image:https://gitlab.com/KitaitiMakoto/epub-parser/badges/master/build.svg[link="https://gitlab.com/KitaitiMakoto/epub-parser/commits/master", title="pipeline status"]
5
+ image:https://gitlab.com/KitaitiMakoto/epub-parser/badges/master/pipeline.svg[link="https://gitlab.com/KitaitiMakoto/epub-parser/commits/master",title="pipeline status"]
6
6
  image:https://badge.fury.io/rb/epub-parser.svg[link="https://gemnasium.com/KitaitiMakoto/epub-parser",title="Gem Version"]
7
7
  image:https://gitlab.com/KitaitiMakoto/epub-parser/badges/master/coverage.svg[link="https://kitaitimakoto.gitlab.io/epub-parser/coverage/",title="coverage report"]
8
8
 
@@ -46,25 +46,27 @@ See document's {file:docs/Home.markdown} or https://kitaitimakoto.gitlab.io/epub
46
46
  `epubinfo` tool extracts and shows the metadata of specified EPUB book.
47
47
 
48
48
  ----
49
- $ epubinfo ~/Documebts/Books/build_awesome_command_line_applications_in_ruby.epub
50
- Title: Build Awesome Command-Line Applications in Ruby (for KITAITI MAKOTO)
51
- Identifiers: 978-1-934356-91-3
52
- Titles: Build Awesome Command-Line Applications in Ruby (for KITAITI MAKOTO)
49
+ % epubinfo ./linear-algebra.epub
50
+ Title: A First Course in Linear Algebra
51
+ Identifiers: code.google.com.epub-samples.linear-algebra
52
+ Titles: A First Course in Linear Algebra
53
53
  Languages: en
54
- Contributors:
55
- Coverages:
56
- Creators: David Bryant Copeland
57
- Dates:
58
- Descriptions:
59
- Formats:
60
- Publishers: The Pragmatic Bookshelf, LLC (338304)
61
- Relations:
62
- Rights: Copyright © 2012 Pragmatic Programmers, LLC
63
- Sources:
64
- Subjects: Pragmatic Bookshelf
65
- Types:
66
- Unique identifier: 978-1-934356-91-3
67
- Epub version: 2.0
54
+ Contributors:
55
+ Coverages:
56
+ Creators: Robert A. Beezer
57
+ Dates:
58
+ Descriptions:
59
+ Formats:
60
+ Publishers:
61
+ Relations:
62
+ Rights: This work is shared with the public using the GNU Free Documentation License, Version 1.2., © 2004 by Robert A. Beezer.
63
+ Sources:
64
+ Subjects:
65
+ Types:
66
+ Modified: 2012-03-05T12:47:00Z
67
+ Unique identifier: code.google.com.epub-samples.linear-algebra
68
+ Epub version: 3.0
69
+ Navigations: toc, landmarks
68
70
  ----
69
71
 
70
72
  See {file:docs/Epubinfo.markdown} for more info.
@@ -174,6 +176,11 @@ If you find other gems, please tell me or request a pull request.
174
176
 
175
177
  == RECENT CHANGES
176
178
 
179
+ === 0.4.4
180
+
181
+ * [BUG FIX]Fix navigation type check bug
182
+ * Add feature to show navigations to `epubinfo` command-line tool
183
+
177
184
  === 0.4.3
178
185
 
179
186
  * Encode file name passed from file system on Unix
@@ -4,6 +4,11 @@ require 'epub/parser'
4
4
  using EPUB::Parser::XMLDocument::Refinements
5
5
 
6
6
  options = {:format => :line}
7
+ navigation_types = {
8
+ :toc => "table of contents",
9
+ :"page-list" => "page list",
10
+ :landmarks => "landmarks"
11
+ }
7
12
  opt = OptionParser.new do |opt|
8
13
  opt.banner = <<EOB
9
14
  Show metadata of an EPUB file
@@ -22,6 +27,20 @@ EOB
22
27
  opt.on '--chars', 'count charactors of content documents' do
23
28
  options[:chars] = true
24
29
  end
30
+ opt.on "--navigation[=TYPE]",navigation_types.keys, "show specified type of navigation(#{navigation_types.keys[0..-2].join(', ')} or #{navigation_types.keys.last})", "If TYPE is omitted, show all types of navigations.", "Can specify multiple times." do |type|
31
+ if type
32
+ options[type] = true
33
+ else
34
+ navigation_types.keys.each do |type|
35
+ options[type] = true
36
+ end
37
+ end
38
+ end
39
+ navigation_types.each_pair do |key, name|
40
+ opt.on "--#{key}", "show #{name} navigation(in line format only)" do
41
+ options[key] = true
42
+ end
43
+ end
25
44
  end
26
45
  opt.parse!(ARGV)
27
46
 
@@ -46,6 +65,7 @@ data.merge!(book.metadata.to_h)
46
65
  data['modified'] = book.modified
47
66
  data['unique identifier'] = book.metadata.unique_identifier
48
67
  data['epub version'] = book.package.version
68
+ data["navigations"] = book.manifest.navs.first&.content_document.navigations.collect(&:type).join(", ")
49
69
 
50
70
  data.each_pair do |(key, value)|
51
71
  data[key] = value.respond_to?(:join) ? value.join(", ") : value.to_s
@@ -75,6 +95,21 @@ if options[:format] == :line
75
95
  data.each_pair do |k, v|
76
96
  puts (k.to_s.capitalize + ':').ljust(key_width) + v.to_s
77
97
  end
98
+ navigation_types.each_pair do |key, name|
99
+ if options[key]
100
+ puts ""
101
+ puts "=== #{name} ==="
102
+ nav = book.manifest.nav.content_document.navigations.find {|nav| nav.type == key.to_s.sub("-", "_")}
103
+ if nav
104
+ nav.traverse do |item, depth|
105
+ text = item.text || "(No heading)"
106
+ puts "#{' ' * depth}#{text}"
107
+ end
108
+ else
109
+ puts "(No #{name})"
110
+ end
111
+ end
112
+ end
78
113
  else
79
114
  require options[:format].to_s
80
115
  puts data.__send__("to_#{options[:format]}")
@@ -12,29 +12,31 @@ Usage
12
12
 
13
13
  Example:
14
14
 
15
- $ epubinfo ~/Documebts/Books/build_awesome_command_line_applications_in_ruby_fo.epub
16
- Title: Build Awesome Command-Line Applications in Ruby (for KITAITI MAKOTO)
17
- Identifiers: 978-1-934356-91-3
18
- Titles: Build Awesome Command-Line Applications in Ruby (for KITAITI MAKOTO)
15
+ % epubinfo ./linear-algebra.epub
16
+ Title: A First Course in Linear Algebra
17
+ Identifiers: code.google.com.epub-samples.linear-algebra
18
+ Titles: A First Course in Linear Algebra
19
19
  Languages: en
20
- Contributors:
21
- Coverages:
22
- Creators: David Bryant Copeland
23
- Dates:
24
- Descriptions:
25
- Formats:
26
- Publishers: The Pragmatic Bookshelf, LLC (338304)
27
- Relations:
28
- Rights: Copyright © 2012 Pragmatic Programmers, LLC
29
- Sources:
30
- Subjects: Pragmatic Bookshelf
31
- Types:
32
- Unique identifier: 978-1-934356-91-3
33
- Epub version: 2.0
20
+ Contributors:
21
+ Coverages:
22
+ Creators: Robert A. Beezer
23
+ Dates:
24
+ Descriptions:
25
+ Formats:
26
+ Publishers:
27
+ Relations:
28
+ Rights: This work is shared with the public using the GNU Free Documentation License, Version 1.2., © 2004 by Robert A. Beezer.
29
+ Sources:
30
+ Subjects:
31
+ Types:
32
+ Modified: 2012-03-05T12:47:00Z
33
+ Unique identifier: code.google.com.epub-samples.linear-algebra
34
+ Epub version: 3.0
35
+ Navigations: toc, landmarks
34
36
 
35
37
  To see help:
36
38
 
37
- $ epubinfo -h
39
+ % epubinfo -h
38
40
  Show metadata of an EPUB file
39
41
 
40
42
  Usage: epubinfo [options] EPUBFILE
@@ -42,6 +44,12 @@ To see help:
42
44
  -f, --format=FORMAT format of output(line, json or yaml), defaults to line(for console)
43
45
  --words count words of content documents
44
46
  --chars count charactors of content documents
47
+ --navigation[=TYPE] show specified type of navigation(toc, page-list or landmarks)
48
+ If TYPE is omitted, show all types of navigations.
49
+ Can specify multiple times.
50
+ --toc show table of contents navigation(in line format only)
51
+ --page-list show page list navigation(in line format only)
52
+ --landmarks show landmarks navigation(in line format only)
45
53
 
46
54
  Output formats
47
55
  --------------
@@ -126,3 +134,126 @@ Note that this makes process slower because it will read all the document.
126
134
  Epub version: 2.0
127
135
  Words: 65006
128
136
  Characters: 445924
137
+
138
+ Navigations
139
+ -----------
140
+
141
+ `epubinfo` can coutput navigations in EPUB document such as table of contents and landmarks. Pass `--navigation` option to the command. This option is available only in line format, for now.
142
+
143
+ % epubinfo --navigation ./linear-algebra.epub
144
+ (snip)
145
+ === table of contents ===
146
+ Table of Contents
147
+ A First Course in Linear Algebra
148
+ Copyright
149
+ Author Biography
150
+ Edition
151
+ Publisher
152
+ Table of Contents
153
+ Dedication
154
+ Chapter 1. Theorems
155
+ Chapter 2. Notation
156
+ Chapter 3. Diagrams
157
+ Chapter 4. Examples
158
+ Preface
159
+ Acknowledgements
160
+ Part I. Part C  Core
161
+ Chapter 1. Chapter SLE  Systems of Linear Equations
162
+ Section WILA  What is Linear Algebra?
163
+ Section SSLE  Solving Systems of Linear Equations
164
+ Section RREF  Reduced Row-Echelon Form
165
+ Section HSE  Homogeneous Systems of Equations
166
+ Section NM  Nonsingular Matrices
167
+ Chapter 2. Chapter V  Vectors
168
+ Section SS  Spanning Sets
169
+ Section O  Orthogonality
170
+ Chapter 3. Chapter M  Matrices
171
+ Section MM  Matrix Multiplication
172
+ Section MISLE  Matrix Inverses and Systems of Linear Equations
173
+ Section MINM  Matrix Inverses and Nonsingular Matrices
174
+ Section CRS  Column and Row Spaces
175
+ Chapter 4. Chapter VS  Vector Spaces
176
+ Chapter 5. Chapter D  Determinants
177
+ Section PDM  Properties of Determinants of Matrices
178
+ Chapter 6. Chapter E  Eigenvalues
179
+ Section PEE  Properties of Eigenvalues and Eigenvectors
180
+ Chapter 7. Chapter LT  Linear Transformations
181
+ Section ILT  Injective Linear Transformations
182
+ Section SLT  Surjective Linear Transformations
183
+ Section IVLT  Invertible Linear Transformations
184
+ Chapter 8. Chapter R  Representations
185
+ Section CB  Change of Basis
186
+ Section OD  Orthonormal Diagonalization
187
+ Section NLT  Nilpotent Linear Transformations
188
+ Section IS  Invariant Subspaces
189
+ Section JCF  Jordan Canonical Form
190
+ Chapter 9. Appendix CN  Computation Notes
191
+ Section MMA  Mathematica
192
+ Section TI86  Texas Instruments 86
193
+ Section TI83  Texas Instruments 83
194
+ Section SAGE  SAGE: Open Source Mathematics Software
195
+ Chapter 10. Appendix P  Preliminaries
196
+ Section CNO  Complex Number Operations
197
+ Section SET  Sets
198
+ Section PT  Proof Techniques
199
+ Chapter 11. Appendix A  Archetypes
200
+ Archetype A
201
+ Archetype B
202
+ Archetype C
203
+ Archetype D
204
+ Archetype E
205
+ Archetype F
206
+ Archetype G
207
+ Archetype H
208
+ Archetype I
209
+ Archetype J
210
+ Archetype K
211
+ Archetype L
212
+ Archetype M
213
+ Archetype N
214
+ Archetype O
215
+ Archetype P
216
+ Archetype Q
217
+ Archetype R
218
+ Archetype S
219
+ Archetype T
220
+ Archetype U
221
+ Archetype V
222
+ Archetype W
223
+ Archetype X
224
+ Chapter 12. Appendix GFDL  GNU Free Documentation License
225
+ Part II. Part T  Topics
226
+ Chapter 14. Section T  Trace
227
+ Chapter 15. Section HP  Hadamard Product
228
+ Chapter 16. Section VM  Vandermonde Matrix
229
+ Chapter 17. Section PSM  Positive Semi-definite Matrices
230
+ Chapter 18. Chapter MD  Matrix Decompositions
231
+ Section ROD  Rank One Decomposition
232
+ Section TD  Triangular Decomposition
233
+ Section SVD  Singular Value Decomposition
234
+ Section SR  Square Roots
235
+ Section POD  Polar Decomposition
236
+ Part III. Part A  Applications
237
+ Chapter 19. Section CF  Curve Fitting
238
+ Chapter 20. Section SAS  Sharing A Secret
239
+ Chapter 21. Contributors
240
+ Chapter 22. Definitions
241
+
242
+ === page list ===
243
+ (No page list)
244
+
245
+ === landmarks ===
246
+ (No heading)
247
+ Part I. Part C  Core
248
+
249
+ If you need only one type of navigation, tell it to `navigation` option:
250
+
251
+ % epubinfo --navigation=toc ./linear-algebra.epub
252
+
253
+ You can specify multiple typs by pass the option multiple times:
254
+
255
+ % epubinfo --navigation=toc --navigation=landmarks ./linear-algebra.epub
256
+
257
+ Short cut options `--toc`, `--page-list` and `--landmarks` are also available. `--toc` is, for example, equivalent to `--navigation=toc`:
258
+
259
+ % epubinfo --toc ./linear-algebra.epub
@@ -4,7 +4,7 @@
4
4
 
5
5
  EPUB Parser gem parses EPUB 3 book loosely.
6
6
 
7
- image:https://gitlab.com/KitaitiMakoto/epub-parser/badges/master/build.svg[link="https://gitlab.com/KitaitiMakoto/epub-parser/commits/master", title="pipeline status"]
7
+ image:https://gitlab.com/KitaitiMakoto/epub-parser/badges/master/pipeline.svg[link="https://gitlab.com/KitaitiMakoto/epub-parser/commits/master",title="pipeline status"]
8
8
  image:https://badge.fury.io/rb/epub-parser.svg[link="https://gemnasium.com/KitaitiMakoto/epub-parser",title="Gem Version"]
9
9
  image:https://gitlab.com/KitaitiMakoto/epub-parser/badges/master/coverage.svg[link="https://kitaitimakoto.gitlab.io/epub-parser/coverage/",title="coverage report"]
10
10
 
@@ -41,4 +41,17 @@ module EPUB
41
41
  ]
42
42
  CORE = IMAGE + APPLICATION + AUDIO + TEXT
43
43
  end
44
+
45
+ # @see https://idpf.github.io/epub-vocabs/structure/
46
+ module Type
47
+ DOCUMENT_NAVIGATION = %w[
48
+ toc
49
+ landmarks
50
+ ]
51
+ PAGINATION = %w[
52
+ pagebreak
53
+ page_list
54
+ ]
55
+ TYPES = DOCUMENT_NAVIGATION + PAGINATION
56
+ end
44
57
  end
@@ -1,8 +1,10 @@
1
- require "set"
1
+ require "epub/content_document/typable"
2
2
 
3
3
  module EPUB
4
4
  module ContentDocument
5
5
  class Navigation < XHTML
6
+ include Typable
7
+
6
8
  attr_accessor :navigations
7
9
 
8
10
  def initialize
@@ -72,6 +74,7 @@ module EPUB
72
74
 
73
75
  class Item
74
76
  include Hidable
77
+ include Typable
75
78
 
76
79
  attr_accessor :items, :text,
77
80
  :content_document, :item
@@ -92,49 +95,40 @@ module EPUB
92
95
  item.traverse depth + 1, &block
93
96
  end
94
97
  end
95
- end
96
-
97
- class Navigation < Item
98
- module Type
99
- TOC = 'toc'
100
- PAGE_LIST = 'page_list'
101
- LANDMARKS = 'landmarks'
102
- end
103
-
104
- attr_reader :types
105
- alias navigations items
106
- alias navigations= items=
107
- alias heading text
108
- alias heading= text=
109
-
110
- def initialize
111
- super
112
- @types = Set.new
113
- end
114
-
115
- def types=(ts)
116
- @types = ts.kind_of?(Set) ? ts : Set.new(ts)
117
- end
118
98
 
119
99
  # For backward compatibility
120
100
  def type
121
- @types.find {|t|
122
- %w[toc page_list landmarks].include? t
101
+ types.find {|t|
102
+ Type::TYPES.include? t
123
103
  }
124
104
  end
125
105
 
126
106
  # For backward compatibility
127
107
  def type=(t)
128
- @types << t
108
+ types << t
129
109
  end
130
110
 
131
111
  %w[toc page_list landmarks].each do |type|
132
112
  define_method "#{type}?" do
133
- type == Type.const_get(type.upcase)
113
+ types.include? type
134
114
  end
135
115
  end
136
116
  end
137
117
 
118
+ # @todo Implement method to represent navigation structure
119
+ class Navigation < Item
120
+ module Type
121
+ TOC = 'toc'
122
+ PAGE_LIST = 'page_list'
123
+ LANDMARKS = 'landmarks'
124
+ end
125
+
126
+ alias navigations items
127
+ alias navigations= items=
128
+ alias heading text
129
+ alias heading= text=
130
+ end
131
+
138
132
  class ItemList < Array
139
133
  include Hidable
140
134
 
@@ -0,0 +1,17 @@
1
+ require "set"
2
+
3
+ module EPUB
4
+ module ContentDocument
5
+ module Typable
6
+ attr_reader :types
7
+
8
+ def types
9
+ @types ||= Set.new
10
+ end
11
+
12
+ def types=(ts)
13
+ @types = ts.kind_of?(Set) ? ts : Set.new(ts)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -63,6 +63,7 @@ module EPUB
63
63
  return a_or_span if a_or_span.nil?
64
64
 
65
65
  item.text = a_or_span.content
66
+ item.types = a_or_span.attribute_with_prefix('type', 'epub')&.split(/\s+/)
66
67
  if a_or_span.name == 'a'
67
68
  if item.text.empty?
68
69
  embedded_content = a_or_span.each_element_by_xpath('./xhtml:audio[1]|xhtml:canvas[1]|xhtml:embed[1]|xhtml:iframe[1]|xhtml:img[1]|xhtml:math[1]|xhtml:object[1]|xhtml:svg[1]|xhtml:video[1]', EPUB::NAMESPACES).first
@@ -1,5 +1,5 @@
1
1
  module EPUB
2
2
  class Parser
3
- VERSION = "0.4.3"
3
+ VERSION = "0.4.4"
4
4
  end
5
5
  end
@@ -3,9 +3,9 @@
3
3
  <head>
4
4
  <title>Table of Contents for Example Book</title>
5
5
  </head>
6
- <body>
6
+ <body epub:type="frontmatter">
7
7
  <div>
8
- <nav epub:type="frontmatter toc" id="idid" hidden="">
8
+ <nav epub:type="toc" id="idid" hidden="">
9
9
  <hgroup>
10
10
  <h2>Sub Navigation</h2>
11
11
  <h1>Table of Contents</h1>
@@ -23,6 +23,13 @@
23
23
  </li>
24
24
  </ol>
25
25
  </nav>
26
+ <nav epub:type="landmarks">
27
+ <h2>Guide</h2>
28
+ <ol>
29
+ <li><a epub:type="toc" href="#idid">Table of Contents</a></li>
30
+ <li><a epub:type="bodymatter" href="日本語.xhtml">Body</a></li>
31
+ </ol>
32
+ </nav>
26
33
  </div>
27
34
  </body>
28
35
  </html>
@@ -22,10 +22,10 @@ class TestParserContentDocument < Test::Unit::TestCase
22
22
  navs = @parser.parse_navigations doc
23
23
  nav = navs.first
24
24
 
25
- assert_equal 1, navs.length
25
+ assert_equal 2, navs.length
26
26
  assert_equal 'Table of Contents', nav.heading
27
27
  assert_equal 'toc', nav.type
28
- assert_equal Set.new(["toc", "frontmatter"]), nav.types
28
+ assert_equal Set.new(["toc"]), nav.types
29
29
 
30
30
  assert_equal 2, nav.items.length
31
31
  assert_equal @manifest.items.first, nav.items.first.item
@@ -36,4 +36,22 @@ class TestParserContentDocument < Test::Unit::TestCase
36
36
 
37
37
  assert_true nav.hidden?
38
38
  end
39
+
40
+ def test_landmarks
41
+ epub = EPUB::Parser.parse("#{@dir}.epub")
42
+ manifest = epub.manifest
43
+ landmarks = epub.nav.content_document.landmarks
44
+
45
+ assert_equal "Guide", landmarks.heading
46
+ assert_equal "landmarks", landmarks.type
47
+ assert_equal Set.new(["landmarks"]), landmarks.types
48
+
49
+ assert_equal 2, landmarks.items.length
50
+
51
+ assert_equal manifest["nav"], landmarks.items.first.item
52
+ assert_equal manifest["japanese-filename"], landmarks.items[1].item
53
+
54
+ assert_equal "Body", landmarks.items.last.text
55
+ assert_equal "bodymatter", landmarks.items.last.types.first
56
+ end
39
57
  end
@@ -26,7 +26,8 @@ class TestSearcher < Test::Unit::TestCase
26
26
  assert_equal(
27
27
  results([
28
28
  [[[:element, 2, {:name => 'spine', :id => nil}], [:itemref, 0, {:id => nil}], [:element, 0, {:name => 'head', :id => nil}], [:element, 0, {:name => 'title', :id => nil}], [:text, 0]], [[:character, 9]], [[:character, 16]]],
29
- [[[:element, 2, {:name => 'spine', :id => nil}], [:itemref, 0, {:id => nil}], [:element, 1, {:name => 'body', :id => nil}], [:element, 0, {:name => 'div', :id => nil}], [:element, 0, {:name => 'nav', :id => 'idid'}], [:element, 0, {:name => 'hgroup', :id => nil}], [:element, 1, {:name => 'h1', :id => nil}], [:text, 0]], [[:character, 9]], [[:character, 16]]]
29
+ [[[:element, 2, {:name => 'spine', :id => nil}], [:itemref, 0, {:id => nil}], [:element, 1, {:name => 'body', :id => nil}], [:element, 0, {:name => 'div', :id => nil}], [:element, 0, {:name => 'nav', :id => 'idid'}], [:element, 0, {:name => 'hgroup', :id => nil}], [:element, 1, {:name => 'h1', :id => nil}], [:text, 0]], [[:character, 9]], [[:character, 16]]],
30
+ [[[:element, 2, {:name => 'spine', :id => nil}], [:itemref, 0, {:id => nil}], [:element, 1, {:name => 'body', :id => nil}], [:element, 0, {:name => 'div', :id => nil}], [:element, 1, {:name => 'nav', :id => nil}], [:element, 1, {:name => 'ol', :id => nil}], [:element, 0, {:name => 'li', :id => nil}], [:element, 0, {:name => 'a', :id => nil}], [:text, 0]], [[:character, 9]], [[:character, 16]]]
30
31
  ]),
31
32
  EPUB::Searcher::Publication.search_text(@package, 'Content')
32
33
  )
@@ -39,7 +40,9 @@ class TestSearcher < Test::Unit::TestCase
39
40
  "epubcfi(/6/2!/4/2/2[idid]/4/4/4/2/2)",
40
41
  "epubcfi(/6/2!/4/2/2[idid]/4/4/4/4/2)",
41
42
  "epubcfi(/6/2!/4/2/2[idid]/4/4/4/6/2)",
42
- "epubcfi(/6/2!/4/2/2[idid]/4/4/4/8/2)"
43
+ "epubcfi(/6/2!/4/2/2[idid]/4/4/4/8/2)",
44
+ "epubcfi(/6/2!/4/2/4/4/2/2)",
45
+ "epubcfi(/6/2!/4/2/4/4/4/2)"
43
46
  ],
44
47
  EPUB::Searcher::Publication.search_element(@package, xpath: './/xhtml:a').collect {|result| result[:location]}.map(&:to_s)
45
48
  )
@@ -52,7 +55,9 @@ class TestSearcher < Test::Unit::TestCase
52
55
  "epubcfi(/6/2!/4/2/2[idid]/4/4/4/2/2)",
53
56
  "epubcfi(/6/2!/4/2/2[idid]/4/4/4/4/2)",
54
57
  "epubcfi(/6/2!/4/2/2[idid]/4/4/4/6/2)",
55
- "epubcfi(/6/2!/4/2/2[idid]/4/4/4/8/2)"
58
+ "epubcfi(/6/2!/4/2/2[idid]/4/4/4/8/2)",
59
+ "epubcfi(/6/2!/4/2/4/4/2/2)",
60
+ "epubcfi(/6/2!/4/2/4/4/4/2)"
56
61
  ],
57
62
  EPUB::Searcher::Publication.search_element(@package, xpath: './/customnamespace:a', namespaces: {'customnamespace' => 'http://www.w3.org/1999/xhtml'}).collect {|result| result[:location]}.map(&:to_s)
58
63
  )
@@ -66,7 +71,9 @@ class TestSearcher < Test::Unit::TestCase
66
71
  "epubcfi(/6/2!/4/2/2[idid]/4/4/4/2)",
67
72
  "epubcfi(/6/2!/4/2/2[idid]/4/4/4/4)",
68
73
  "epubcfi(/6/2!/4/2/2[idid]/4/4/4/6)",
69
- "epubcfi(/6/2!/4/2/2[idid]/4/4/4/8)"
74
+ "epubcfi(/6/2!/4/2/2[idid]/4/4/4/8)",
75
+ "epubcfi(/6/2!/4/2/4/4/2)",
76
+ "epubcfi(/6/2!/4/2/4/4/4)"
70
77
  ],
71
78
  EPUB::Searcher::Publication.search_element(@package, css: 'ol > li').collect {|result| result[:location]}.map(&:to_s)
72
79
  )
@@ -74,7 +81,7 @@ class TestSearcher < Test::Unit::TestCase
74
81
 
75
82
  class TesetResult < self
76
83
  def test_to_cfi
77
- assert_equal 'epubcfi(/6/2!/4/2/2[idid]/2/4/1,:9,:16)', EPUB::Searcher::Publication.search_text(@package, 'Content').last.to_cfi.to_s
84
+ assert_equal 'epubcfi(/6/2!/4/2/2[idid]/2/4/1,:9,:16)', EPUB::Searcher::Publication.search_text(@package, 'Content')[1].to_cfi.to_s
78
85
  end
79
86
  end
80
87
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epub-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - KITAITI Makoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-13 00:00:00.000000000 Z
11
+ date: 2020-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -356,6 +356,7 @@ files:
356
356
  - lib/epub/constants.rb
357
357
  - lib/epub/content_document.rb
358
358
  - lib/epub/content_document/navigation.rb
359
+ - lib/epub/content_document/typable.rb
359
360
  - lib/epub/content_document/xhtml.rb
360
361
  - lib/epub/inspector.rb
361
362
  - lib/epub/metadata.rb