asciidoctor-epub3 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f20a42a377b9277de98224e2b6d8d5ac7ff356b46a02ba8ca481a80935d59eba
4
- data.tar.gz: 35306c465c033aca6377d510b8b3ce55133a48ae79aed950e6cf3029c48e9186
3
+ metadata.gz: ff785d4225d6fea9ffa77155a0c285b89991daf507429aec38b40ff6c65f7083
4
+ data.tar.gz: b2824f59d264f41ba14ceb3d7b9ad196de08a1ba2faffba99bec15f0012b1b8c
5
5
  SHA512:
6
- metadata.gz: 2d0c281acdc88326415f1e308a8ee6c6f6dae93868d04af0381fa80f11836fcecf7e20e7ff5b1894711f72538bf5fc8fe599b98441f517197c87890b826ad3a3
7
- data.tar.gz: ba7e9532b6df5dbdf09dd87e4c96bb0fffe0485b0113d62970fd980b12e209c435084ebd0d0e1c38b7da340dc5e63a59dbd3d025a4cefd6aaf5f6946501ad8fc
6
+ metadata.gz: 9dded16c8740dfd72d35f8bc34fa88abbd66a45110793731783c375ff55f344095234637e43709196e5d0ba0240a98e74701f570d8e09847ad30b950ed4e812b
7
+ data.tar.gz: dd63ed0c15a768e0c6224a7ca8345a05fef6512ca0a09a0e7f64da8fd998ab16b1b88160c2d893ac49bedbed07cd1983e4cda0f03272383f4b5241a99198cb9d
data/CHANGELOG.adoc CHANGED
@@ -5,6 +5,11 @@
5
5
  This document provides a high-level view of the changes to the {project-name} by release.
6
6
  For a detailed view of what has changed, refer to the {uri-repo}/commits/master[commit history] on GitHub.
7
7
 
8
+ == 2.1.0 (2024-02-04) - @slonopotamus
9
+
10
+ * drop MOBI support
11
+ * add support for blocks in callouts (#463)
12
+
8
13
  == 2.0.1 (2024-01-13) - @slonopotamus
9
14
 
10
15
  * restore styling of `<strong>` and `<em>` (#461)
data/Gemfile CHANGED
@@ -9,8 +9,4 @@ group :optional do
9
9
  # epubcheck-ruby might be safe to be converted into runtime dependency,
10
10
  # but could have issues when packaged into asciidoctorj-epub3
11
11
  gem 'epubcheck-ruby', '~> 5.1.0.0'
12
-
13
- # Kindlegen is unavailable neither for 64-bit x86 macOS nor for ARM
14
- # Also, skip JRuby on Windows for now. See https://github.com/jruby/jruby/issues/7171
15
- gem 'kindlegen', '~> 3.1.0' unless RUBY_PLATFORM =~ /darwin/ || (Gem.win_platform? && RUBY_ENGINE == 'jruby')
16
12
  end
data/README.adoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = {project-name}: A _native_ EPUB3 converter for AsciiDoc
2
2
  Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>
3
- v2.0.1, 2024-01-13
3
+ v2.1.0, 2024-02-04
4
4
  :project-name: Asciidoctor EPUB3
5
5
  :project-handle: asciidoctor-epub3
6
6
  :uri-project: https://github.com/asciidoctor/{project-handle}
@@ -13,7 +13,7 @@ image:https://img.shields.io/badge/zulip-join_chat-brightgreen.svg[project chat,
13
13
  image:https://img.shields.io/gem/v/asciidoctor-epub3.svg[Latest Release,link={uri-gem}]
14
14
  image:{uri-project}/workflows/CI/badge.svg?branch=main[GitHub Actions,link={uri-ci}]
15
15
 
16
- {project-name} is a set of Asciidoctor extensions for converting AsciiDoc documents directly to the EPUB3 and KF8/MOBI e-book formats.
16
+ {project-name} is a set of Asciidoctor extensions for converting AsciiDoc documents directly to the EPUB3 e-book format.
17
17
 
18
18
  == Documentation
19
19
 
@@ -54,15 +54,6 @@ $ asciidoctor-epub3 -D output path/to/book.adoc
54
54
  When the script completes, you'll see the file [file]_book.epub_ appear in the [path]_output_ directory.
55
55
  Open that file with an EPUB3 reader to view the result.
56
56
 
57
- You may also produce KF8/MOBI file by setting `ebook-format` attribute to `kf8`.
58
-
59
- [source,shell script]
60
- ----
61
- $ asciidoctor-epub3 -D output -a ebook-format=kf8 path/to/book.adoc
62
- ----
63
-
64
- When the script completes, the file [file]_book.mobi_ will appear in [path]_output_ directory.
65
-
66
57
  == Contributing
67
58
 
68
59
  In the spirit of free software, _everyone_ is encouraged to help improve this project.
@@ -7,9 +7,9 @@ Gem::Specification.new do |s|
7
7
  s.name = 'asciidoctor-epub3'
8
8
  s.version = Asciidoctor::Epub3::VERSION
9
9
 
10
- s.summary = 'Converts AsciiDoc documents to EPUB3 and KF8/MOBI (Kindle) e-book formats'
10
+ s.summary = 'Converts AsciiDoc documents to EPUB3 e-book format'
11
11
  s.description = <<~EOS
12
- An extension for Asciidoctor that converts AsciiDoc documents to EPUB3 and KF8/MOBI (Kindle) e-book archives.
12
+ An extension for Asciidoctor that converts AsciiDoc documents to EPUB3 e-book format.
13
13
  EOS
14
14
 
15
15
  s.authors = ['Dan Allen', 'Sarah White']
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
  Dir['**/*']
26
26
  end
27
27
  s.files = files.grep %r{^(?:(?:data/(?:fonts|images|styles)|lib)/.+|Gemfile|Rakefile|LICENSE|(?:CHANGELOG|NOTICE|README)\.adoc|\.yardopts|#{s.name}\.gemspec)$}
28
- s.executables = %w[asciidoctor-epub3 adb-push-ebook]
28
+ s.executables = %w[asciidoctor-epub3]
29
29
 
30
30
  s.require_paths = ['lib']
31
31
 
@@ -32,6 +32,7 @@ body code, body kbd, body :not(.verse) > pre, :not(.verse) > pre :not(code) {
32
32
  font-family: "M+ 1mn", monospace !important;
33
33
  }
34
34
 
35
+ /* TODO: DO we still need this? */
35
36
  @media amzn-kf8 {
36
37
  /* Kindle does its own margin management, so don't use an explicit margin */
37
38
  /*body {
@@ -841,7 +841,7 @@ div.verse {
841
841
  page-break-inside: avoid;
842
842
  }
843
843
 
844
- /* TODO we may want to reenable hyphens here, but not for kf8 */
844
+ /* TODO we may want to reenable hyphens here */
845
845
  div.verse > pre {
846
846
  font-family: "M+ 1p", sans-serif;
847
847
  background-color: transparent;
@@ -1160,7 +1160,10 @@ nav[hidden~="hidden"] {
1160
1160
  }
1161
1161
 
1162
1162
  @media amzn-mobi {
1163
- /* NOTE mobi7 doesn't support custom fonts, so revert to generic ones */
1163
+ /*
1164
+ NOTE mobi7 doesn't support custom fonts, so revert to generic ones.
1165
+ See https://github.com/asciidoctor/asciidoctor-epub3/issues/56.
1166
+ */
1164
1167
  body p, ul, ol, li, dl, dt, dd, figcaption, caption, footer,
1165
1168
  table.table th, table.table td, div.verse .attribution {
1166
1169
  font-family: serif;
@@ -7,8 +7,7 @@ require_relative 'font_icon_map'
7
7
 
8
8
  module Asciidoctor
9
9
  module Epub3
10
- # Public: The main converter for the epub3 backend that handles packaging the
11
- # EPUB3 or KF8 publication file.
10
+ # Public: The main converter for the epub3 backend that handles packaging the EPUB3 publication file.
12
11
  class Converter
13
12
  include ::Asciidoctor::Converter
14
13
  include ::Asciidoctor::Logging
@@ -17,15 +16,14 @@ module Asciidoctor
17
16
  register_for 'epub3'
18
17
 
19
18
  def write(output, target)
20
- epub_file = @format == :kf8 ? %(#{::Asciidoctor::Helpers.rootname target}-kf8.epub) : target
21
- output.generate_epub epub_file
22
- logger.debug %(Wrote #{@format.upcase} to #{epub_file})
19
+ output.generate_epub target
20
+ logger.debug %(Wrote to #{target})
23
21
  if @extract
24
- extract_dir = epub_file.sub EPUB_EXTENSION_RX, ''
22
+ extract_dir = target.sub EPUB_EXTENSION_RX, ''
25
23
  ::FileUtils.remove_dir extract_dir if ::File.directory? extract_dir
26
24
  ::Dir.mkdir extract_dir
27
25
  ::Dir.chdir extract_dir do
28
- ::Zip::File.open epub_file do |entries|
26
+ ::Zip::File.open target do |entries|
29
27
  entries.each do |entry|
30
28
  next unless entry.file?
31
29
 
@@ -36,15 +34,12 @@ module Asciidoctor
36
34
  end
37
35
  end
38
36
  end
39
- logger.debug %(Extracted #{@format.upcase} to #{extract_dir})
37
+ logger.debug %(Extracted to #{extract_dir})
40
38
  end
41
39
 
42
- if @format == :kf8
43
- # QUESTION: shouldn't we validate this epub file too?
44
- distill_epub_to_mobi epub_file, target, @compress
45
- elsif @validate
46
- validate_epub epub_file
47
- end
40
+ return unless @validate
41
+
42
+ validate_epub target
48
43
  end
49
44
 
50
45
  CSV_DELIMITED_RX = /\s*,\s*/.freeze
@@ -80,14 +75,6 @@ module Asciidoctor
80
75
  TO_HTML_SPECIAL_CHARS_RX = /[#{TO_HTML_SPECIAL_CHARS_MAP.keys.join}]/.freeze
81
76
 
82
77
  EPUB_EXTENSION_RX = /\.epub$/i.freeze
83
- KINDLEGEN_COMPRESSION = {
84
- '0' => '-c0',
85
- '1' => '-c1',
86
- '2' => '-c2',
87
- 'none' => '-c0',
88
- 'standard' => '-c1',
89
- 'huffdic' => '-c2'
90
- }.freeze
91
78
 
92
79
  QUOTE_TAGS = begin
93
80
  tags = {
@@ -109,7 +96,7 @@ module Asciidoctor
109
96
  def initialize(backend, opts = {})
110
97
  super
111
98
  basebackend 'html'
112
- outfilesuffix '.epub' # dummy outfilesuffix since it may be .mobi
99
+ outfilesuffix '.epub'
113
100
  htmlsyntax 'xml'
114
101
  end
115
102
 
@@ -158,19 +145,16 @@ module Asciidoctor
158
145
  end
159
146
 
160
147
  def convert_document(node)
161
- @format = node.attr('ebook-format').to_sym
162
-
163
148
  @validate = node.attr? 'ebook-validate'
164
149
  @extract = node.attr? 'ebook-extract'
165
150
  @compress = node.attr 'ebook-compress'
166
- @kindlegen_path = node.attr 'ebook-kindlegen-path'
167
151
  @epubcheck_path = node.attr 'ebook-epubcheck-path'
168
152
  @xrefs_seen = ::Set.new
169
153
  @media_files = {}
170
154
  @footnotes = []
171
155
 
172
156
  @book = GEPUB::Book.new 'EPUB/package.opf'
173
- @book.epub_backward_compat = @format != :kf8
157
+ @book.epub_backward_compat = true
174
158
  @book.language node.attr('lang', 'en'), id: 'pub-language'
175
159
 
176
160
  if node.attr? 'uuid'
@@ -239,7 +223,7 @@ module Asciidoctor
239
223
  landmarks = []
240
224
 
241
225
  front_cover = add_cover_page node, 'front-cover'
242
- if front_cover.nil? && @format != :kf8 && node.doctype == 'book'
226
+ if front_cover.nil? && node.doctype == 'book'
243
227
  # TODO(#352): add textual front cover similar to PDF
244
228
  end
245
229
 
@@ -289,9 +273,9 @@ module Asciidoctor
289
273
  }
290
274
  end
291
275
 
292
- nav_item.add_content postprocess_xhtml(nav_doc(node, toc_items, landmarks, outlinelevels))
276
+ nav_item.add_content nav_doc(node, toc_items, landmarks, outlinelevels).to_ios
293
277
  # User is not supposed to see landmarks, so pass empty array here
294
- toc_item&.add_content postprocess_xhtml(nav_doc(node, toc_items, [], toclevels))
278
+ toc_item&.add_content nav_doc(node, toc_items, [], toclevels).to_ios
295
279
 
296
280
  # NOTE: gepub doesn't support building a ncx TOC with depth > 1, so do it ourselves
297
281
  toc_ncx = ncx_doc node, toc_items, outlinelevels
@@ -406,10 +390,8 @@ module Asciidoctor
406
390
  end
407
391
 
408
392
  header = if title || subtitle
409
- %(<header>
410
- <div class="chapter-header">
393
+ %(<header class="chapter-header">
411
394
  #{byline}<h1 class="chapter-title">#{title}#{subtitle ? %(<small class="subtitle">#{subtitle}</small>) : ''}</h1>
412
- </div>
413
395
  </header>)
414
396
  else
415
397
  ''
@@ -419,7 +401,6 @@ module Asciidoctor
419
401
  # in order to avoid style duplication across chapter files
420
402
  linkcss = true
421
403
 
422
- # NOTE: kindlegen seems to mangle the <header> element, so we wrap its content in a div
423
404
  lines = [%(<?xml version='1.0' encoding='utf-8'?>
424
405
  <!DOCTYPE html>
425
406
  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:mml="http://www.w3.org/1998/Math/MathML" xml:lang="#{lang = node.document.attr 'lang',
@@ -455,9 +436,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
455
436
  unless (fns = node.document.footnotes - @footnotes).empty?
456
437
  @footnotes += fns
457
438
 
458
- # NOTE: kindlegen seems to mangle the <footer> element, so we wrap its content in a div
459
- lines << '<footer>
460
- <div class="chapter-footer">
439
+ lines << '<footer class="chapter-footer">
461
440
  <div class="footnotes">'
462
441
  fns.each do |footnote|
463
442
  lines << %(<aside id="note-#{footnote.index}" epub:type="footnote">
@@ -465,7 +444,6 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
465
444
  </aside>)
466
445
  end
467
446
  lines << '</div>
468
- </div>
469
447
  </footer>'
470
448
  end
471
449
 
@@ -479,7 +457,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
479
457
  lines << '</body>
480
458
  </html>'
481
459
 
482
- chapter_item.add_content postprocess_xhtml lines * LF
460
+ chapter_item.add_content((lines * LF).to_ios)
483
461
  epub_properties = node.attr 'epub-properties'
484
462
  chapter_item.add_property 'svg' if epub_properties&.include? 'svg'
485
463
 
@@ -856,7 +834,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
856
834
  <ol>']
857
835
  num = CALLOUT_START_NUM
858
836
  node.items.each_with_index do |item, i|
859
- lines << %(<li><i class="conum" data-value="#{i + 1}">#{num}</i> #{item.text}</li>)
837
+ lines << %(<li><i class="conum" data-value="#{i + 1}">#{num}</i> #{item.text}#{item.content if item.blocks?}</li>)
860
838
  num = num.next
861
839
  end
862
840
  lines << '</ol>
@@ -1386,7 +1364,6 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
1386
1364
  end
1387
1365
 
1388
1366
  def add_theme_assets(doc)
1389
- format = @format
1390
1367
  workdir = if doc.attr? 'epub3-stylesdir'
1391
1368
  stylesdir = doc.attr 'epub3-stylesdir'
1392
1369
  # FIXME: make this work for Windows paths!!
@@ -1404,13 +1381,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
1404
1381
  # TODO: improve design/UX of custom theme functionality, including custom fonts
1405
1382
  %w[epub3 epub3-css3-only].each do |f|
1406
1383
  css = load_css_file File.join(workdir, %(#{f}.scss))
1407
- if format == :kf8
1408
- # NOTE: add layer of indirection so Kindle Direct Publishing (KDP) doesn't strip font-related CSS rules
1409
- @book.add_item %(styles/#{f}.css), content: %(@import url("#{f}-proxied.css");).to_ios
1410
- @book.add_item %(styles/#{f}-proxied.css), content: css.to_ios
1411
- else
1412
- @book.add_item %(styles/#{f}.css), content: css.to_ios
1413
- end
1384
+ @book.add_item %(styles/#{f}.css), content: css.to_ios
1414
1385
  end
1415
1386
 
1416
1387
  syntax_hl = doc.syntax_highlighter
@@ -1433,15 +1404,12 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
1433
1404
  @book.add_item 'styles/epub3-fonts.css', content: font_css.to_ios
1434
1405
  unless font_files.empty?
1435
1406
  # NOTE: metadata property in oepbs package manifest doesn't work; must use proprietary iBooks file instead
1436
- # (@book.metadata.add_metadata 'meta', 'true')['property'] = 'ibooks:specified-fonts' unless format == :kf8
1437
- unless format == :kf8
1438
- @book.add_optional_file 'META-INF/com.apple.ibooks.display-options.xml', '<?xml version="1.0" encoding="UTF-8"?>
1407
+ @book.add_optional_file 'META-INF/com.apple.ibooks.display-options.xml', '<?xml version="1.0" encoding="UTF-8"?>
1439
1408
  <display_options>
1440
1409
  <platform name="*">
1441
1410
  <option name="specified-fonts">true</option>
1442
1411
  </platform>
1443
1412
  </display_options>'.to_ios
1444
- end
1445
1413
 
1446
1414
  font_files.each do |font_file|
1447
1415
  @book.add_item font_file, content: File.join(DATA_DIR, font_file)
@@ -1486,8 +1454,6 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
1486
1454
  return nil
1487
1455
  end
1488
1456
 
1489
- return nil if @format == :kf8
1490
-
1491
1457
  unless !image_attrs.empty? && (width = image_attrs['width']) && (height = image_attrs['height'])
1492
1458
  width = 1050
1493
1459
  height = 1600
@@ -1522,9 +1488,9 @@ body > svg {
1522
1488
  width="100%" height="100%" viewBox="0 0 #{width} #{height}" preserveAspectRatio="xMidYMid meet">
1523
1489
  <image width="#{width}" height="#{height}" xlink:href="#{image_href}"/>
1524
1490
  </svg></body>
1525
- </html>).to_ios
1491
+ </html>)
1526
1492
 
1527
- @book.add_ordered_item %(#{name}.xhtml), content: content, id: name
1493
+ @book.add_ordered_item %(#{name}.xhtml), content: content.to_ios, id: name
1528
1494
  end
1529
1495
 
1530
1496
  def get_frontmatter_files(doc, workdir)
@@ -1559,7 +1525,7 @@ body > svg {
1559
1525
  front_matter_content = ::File.read front_matter
1560
1526
 
1561
1527
  front_matter_file = File.basename front_matter, '.html'
1562
- item = @book.add_ordered_item "#{front_matter_file}.xhtml", content: (postprocess_xhtml front_matter_content)
1528
+ item = @book.add_ordered_item "#{front_matter_file}.xhtml", content: front_matter_content.to_ios
1563
1529
  item.add_property 'svg' if SVG_IMG_SNIFF_RX =~ front_matter_content
1564
1530
  # Store link to first frontmatter page
1565
1531
  result = item if result.nil?
@@ -1615,8 +1581,8 @@ body > svg {
1615
1581
  </head>
1616
1582
  <body>
1617
1583
  <section class="chapter">
1618
- <header>
1619
- <div class="chapter-header"><h1 class="chapter-title"><small class="subtitle">#{doc.attr 'toc-title'}</small></h1></div>
1584
+ <header class="chapter-header">
1585
+ <h1 class="chapter-title"><small class="subtitle">#{doc.attr 'toc-title'}</small></h1>
1620
1586
  </header>
1621
1587
  <nav epub:type="toc" id="toc">)]
1622
1588
  lines << (nav_level items, [depth, 0].max)
@@ -1738,72 +1704,6 @@ body > svg {
1738
1704
  sass_engine.render
1739
1705
  end
1740
1706
 
1741
- def postprocess_xhtml(content)
1742
- return content.to_ios unless @format == :kf8
1743
-
1744
- # TODO: convert regular expressions to constants
1745
- content
1746
- .gsub(/<img([^>]+) style="width: (\d\d)%;"/, '<img\1 style="width: \2%; height: \2%;"')
1747
- .gsub(%r{<script type="text/javascript">.*?</script>\n?}m, '')
1748
- .to_ios
1749
- end
1750
-
1751
- def build_kindlegen_command
1752
- unless @kindlegen_path.nil?
1753
- logger.debug %(Using ebook-kindlegen-path attribute: #{@kindlegen_path})
1754
- return [@kindlegen_path]
1755
- end
1756
-
1757
- unless (result = ENV.fetch('KINDLEGEN', nil)).nil?
1758
- logger.debug %(Using KINDLEGEN env variable: #{result})
1759
- return [result]
1760
- end
1761
-
1762
- begin
1763
- require 'kindlegen' unless defined? ::Kindlegen
1764
- result = ::Kindlegen.command.to_s
1765
- logger.debug %(Using KindleGen from gem: #{result})
1766
- [result]
1767
- rescue LoadError => e
1768
- logger.debug %(#{e}; Using KindleGen from PATH)
1769
- [%(kindlegen#{::Gem.win_platform? ? '.exe' : ''})]
1770
- end
1771
- end
1772
-
1773
- def distill_epub_to_mobi(epub_file, target, compress)
1774
- mobi_file = ::File.basename target.sub(EPUB_EXTENSION_RX, '.mobi')
1775
- compress_flag = KINDLEGEN_COMPRESSION[if compress
1776
- compress.empty? ? '1' : compress.to_s
1777
- else
1778
- '0'
1779
- end]
1780
-
1781
- argv = build_kindlegen_command + ['-dont_append_source', compress_flag, '-o', mobi_file, epub_file].compact
1782
- begin
1783
- # This duplicates Kindlegen.run, but we want to override executable
1784
- out, err, res = Open3.capture3(*argv) do |r|
1785
- r.force_encoding 'UTF-8' if ::Gem.win_platform? && r.respond_to?(:force_encoding)
1786
- end
1787
- rescue Errno::ENOENT => e
1788
- raise 'Unable to run KindleGen. Either install the kindlegen gem or place `kindlegen` executable on PATH or set KINDLEGEN environment variable with path to it',
1789
- cause: e
1790
- end
1791
-
1792
- out.each_line do |line|
1793
- log_line line
1794
- end
1795
- err.each_line do |line|
1796
- log_line line
1797
- end
1798
-
1799
- output_file = ::File.join ::File.dirname(epub_file), mobi_file
1800
- if res.success?
1801
- logger.debug %(Wrote MOBI to #{output_file})
1802
- else
1803
- logger.error %(KindleGen failed to write MOBI to #{output_file})
1804
- end
1805
- end
1806
-
1807
1707
  def build_epubcheck_command
1808
1708
  unless @epubcheck_path.nil?
1809
1709
  logger.debug %(Using ebook-epubcheck-path attribute: #{@epubcheck_path})
@@ -1875,27 +1775,6 @@ body > svg {
1875
1775
  end
1876
1776
  end
1877
1777
 
1878
- class NumericIdGenerator
1879
- def initialize
1880
- @counter = 1
1881
- end
1882
-
1883
- # @param node [Asciidoctor::AbstractNode]
1884
- # @return [void]
1885
- def generate_id(node)
1886
- if node.chapter? || node.is_a?(Asciidoctor::Document)
1887
- node.id = %(_generated_id_#{@counter})
1888
- @counter += 1
1889
- end
1890
-
1891
- # Recurse
1892
- node.blocks.each do |subnode|
1893
- # dlist contains array of *arrays* of blocks, so just skip them
1894
- generate_id subnode if subnode.is_a?(Asciidoctor::AbstractBlock)
1895
- end
1896
- end
1897
- end
1898
-
1899
1778
  Extensions.register do
1900
1779
  if (document = @document).backend == 'epub3'
1901
1780
  document.set_attribute 'listing-caption', 'Listing'
@@ -1904,33 +1783,22 @@ body > svg {
1904
1783
  document.set_attribute 'pygments-style', 'bw' unless document.attr? 'pygments-style'
1905
1784
  document.set_attribute 'rouge-style', 'bw' unless document.attr? 'rouge-style'
1906
1785
 
1907
- case (ebook_format = document.attributes['ebook-format'])
1908
- when 'epub3', 'kf8'
1909
- # all good
1910
- when 'mobi'
1911
- ebook_format = document.attributes['ebook-format'] = 'kf8'
1912
- else
1913
- # QUESTION: should we display a warning?
1914
- ebook_format = document.attributes['ebook-format'] = 'epub3'
1915
- end
1916
- document.attributes[%(ebook-format-#{ebook_format})] = ''
1786
+ # Backward compatibility for documents that were created before we dropped MOBI support
1787
+ document.set_attribute 'ebook-format', 'epub3'
1788
+ document.set_attribute 'ebook-format-epub3', ''
1917
1789
 
1918
1790
  # Enable generation of section ids because we use them for chapter filenames
1919
1791
  document.set_attribute 'sectids'
1920
1792
  treeprocessor do
1921
1793
  process do |doc|
1922
- if ebook_format == 'kf8'
1923
- # Kindlegen doesn't support unicode ids
1924
- NumericIdGenerator.new.generate_id doc
1925
- else
1926
- # :sectids: doesn't generate id for top-level section (why?), do it manually
1927
- doc.id = Section.generate_id(doc.first_section&.title || doc.attr('docname') || 'document', doc) if doc.id.nil_or_empty?
1794
+ # :sectids: doesn't generate id for top-level section (why?), do it manually
1795
+ doc.id = Section.generate_id(doc.first_section&.title || doc.attr('docname') || 'document', doc) if doc.id.nil_or_empty?
1928
1796
 
1929
- if (preamble = doc.blocks[0]) && preamble.context == :preamble && preamble.id.nil_or_empty?
1930
- # :sectids: doesn't generate id for preamble (because it is not a section), do it manually
1931
- preamble.id = Section.generate_id(preamble.title || 'preamble', doc)
1932
- end
1797
+ if (preamble = doc.blocks[0]) && preamble.context == :preamble && preamble.id.nil_or_empty?
1798
+ # :sectids: doesn't generate id for preamble (because it is not a section), do it manually
1799
+ preamble.id = Section.generate_id(preamble.title || 'preamble', doc)
1933
1800
  end
1801
+
1934
1802
  nil
1935
1803
  end
1936
1804
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module Epub3
5
- VERSION = '2.0.1'
5
+ VERSION = '2.1.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-epub3
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Allen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-01-13 00:00:00.000000000 Z
12
+ date: 2024-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: asciidoctor-diagram
@@ -208,13 +208,12 @@ dependencies:
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
210
  description: 'An extension for Asciidoctor that converts AsciiDoc documents to EPUB3
211
- and KF8/MOBI (Kindle) e-book archives.
211
+ e-book format.
212
212
 
213
213
  '
214
214
  email: dan@opendevise.com
215
215
  executables:
216
216
  - asciidoctor-epub3
217
- - adb-push-ebook
218
217
  extensions: []
219
218
  extra_rdoc_files: []
220
219
  files:
@@ -225,7 +224,6 @@ files:
225
224
  - README.adoc
226
225
  - Rakefile
227
226
  - asciidoctor-epub3.gemspec
228
- - bin/adb-push-ebook
229
227
  - bin/asciidoctor-epub3
230
228
  - data/fonts/assorted-icons.ttf
231
229
  - data/fonts/awesome/LICENSE.txt
@@ -307,5 +305,5 @@ requirements: []
307
305
  rubygems_version: 3.5.3
308
306
  signing_key:
309
307
  specification_version: 4
310
- summary: Converts AsciiDoc documents to EPUB3 and KF8/MOBI (Kindle) e-book formats
308
+ summary: Converts AsciiDoc documents to EPUB3 e-book format
311
309
  test_files: []
data/bin/adb-push-ebook DELETED
@@ -1,37 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- ADB = ENV['ADB'] || 'adb'
5
- TARGETS = {
6
- '.epub' => '/sdcard/',
7
- '.mobi' => '/sdcard/Android/data/com.amazon.kindle/files/'
8
- }.freeze
9
-
10
- unless File.executable? ADB
11
- warn %(adb-push-ebook: `adb` not found.\nPlease set the ADB environment variable or add `adb` to your PATH.)
12
- exit 1
13
- end
14
-
15
- require 'open3'
16
- require 'shellwords'
17
-
18
- payload_file = ARGV[0] || '_output/sample-book'
19
-
20
- transfers = if (payload_file_ext = File.extname payload_file).empty?
21
- TARGETS.map do |(ext, target_dir)|
22
- {
23
- src: %(#{payload_file}#{ext}),
24
- dest: target_dir
25
- }
26
- end
27
- else
28
- [{ src: payload_file, dest: TARGETS[payload_file_ext] }]
29
- end
30
-
31
- transfers.each do |transfer|
32
- next unless File.file? transfer[:src]
33
-
34
- Open3.popen2e Shellwords.join([ADB, 'push', transfer[:src], transfer[:dest]]) do |_input, output, _wait_thr|
35
- output.each { |line| puts line }
36
- end
37
- end