asciidoctor-epub3 1.5.0.alpha.18 → 1.5.0.alpha.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +15 -0
- data/Gemfile +0 -3
- data/README.adoc +1 -1
- data/data/styles/epub3.css +0 -13
- data/lib/asciidoctor-epub3/converter.rb +54 -54
- data/lib/asciidoctor-epub3/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30d660ed4a7fc21dc01c61ae77515dbba77dd8bbbd7618e45709f7048745040c
|
4
|
+
data.tar.gz: f3b2d04be71c163e9ed29ae907f2a2c2ab00ecd3e6ecb329775952b5853ebf9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06fb18e09b9ec33401e46168f85436c871accb1f3774b51a8f29373185ba1a538bb2f7a00663e37a43c778238b8bd55ac01883b58f8a173041b0fcb20acdea91
|
7
|
+
data.tar.gz: 248b718e05d9e8750dbb44117de81a04cdde271da64f96b720f145e54de61a19cf79d29e7f2dd4b2664f84b9c534c38d94ca84e6e87982839a31144c0cf0a3f2
|
data/CHANGELOG.adoc
CHANGED
@@ -5,6 +5,20 @@
|
|
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
|
+
== 1.5.0.alpha.19 (2020-10-21) - @slonopotamus
|
9
|
+
|
10
|
+
* add title and id support for literal blocks (#357)
|
11
|
+
* fix quotes not being properly escaped in section titles (#358)
|
12
|
+
* fix crash when encountering unsupported Asciidoctor node (#360)
|
13
|
+
* add support for 100%-wide table (#356)
|
14
|
+
* do not add multiple entries for same media files in book manifest (#370)
|
15
|
+
* do not add bogus entries to manifest when `:data-uri:` attribute is set (#371)
|
16
|
+
* add id support for listing blocks (#372)
|
17
|
+
* stop using deprecated `epub:type` for admonitions (#373)
|
18
|
+
* fix `epub:type` attributes for special sections (#374)
|
19
|
+
* fix font resize not working in iBooks (#368)
|
20
|
+
* fix visited link color in iBooks night mode (#366)
|
21
|
+
|
8
22
|
== 1.5.0.alpha.18 (2020-07-27) - @slonopotamus
|
9
23
|
|
10
24
|
* remove <b> from chapter subtitle (#123)
|
@@ -112,6 +126,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
|
|
112
126
|
* upgrade pygments.rb to 1.2.1 (#216)
|
113
127
|
* gepub dependency is no longer locked to 1.0.2 and will use latest 1.0.x version
|
114
128
|
* fix `-a ebook-validate` not working on Windows (#232)
|
129
|
+
* fix crash when inline pass macro `m` contains an icon (#375)
|
115
130
|
|
116
131
|
== 1.5.0.alpha.9 (2019-04-04) - @mojavelinux
|
117
132
|
|
data/Gemfile
CHANGED
@@ -14,7 +14,4 @@ end
|
|
14
14
|
group :optional do
|
15
15
|
# epubcheck-ruby might be safe to be converted into runtime dependency, but could have issues when packaged into asciidoctorj-epub3
|
16
16
|
gem 'epubcheck-ruby', '~> 4.2.4.0'
|
17
|
-
# We would like to make kindlegen a runtime dependency, but can't because of the way asciidoctorj-epub3 packaging works
|
18
|
-
# See https://github.com/asciidoctor/asciidoctor-epub3/issues/288
|
19
|
-
gem 'kindlegen', '~> 3.0.3'
|
20
17
|
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
|
-
v1.5.0.alpha.
|
3
|
+
v1.5.0.alpha.19, 2020-10-21
|
4
4
|
// Settings:
|
5
5
|
:experimental:
|
6
6
|
:idprefix:
|
data/data/styles/epub3.css
CHANGED
@@ -17,7 +17,6 @@ html {
|
|
17
17
|
/* set the em base (and relative em anchor) by setting the font-size on html */
|
18
18
|
/* TODO set font-size > 100% except for Kindle */
|
19
19
|
font-size: 100%;
|
20
|
-
-webkit-text-size-adjust: 100%;
|
21
20
|
}
|
22
21
|
|
23
22
|
/* don't set margin on body as that's how many readers frame reading area */
|
@@ -243,12 +242,6 @@ body:first-of-type a:link {
|
|
243
242
|
background-position: 0 1.2em;
|
244
243
|
}
|
245
244
|
|
246
|
-
body a:visited {
|
247
|
-
color: #333332;
|
248
|
-
/* hack for font color in iBooks */
|
249
|
-
-webkit-text-fill-color: #333332;
|
250
|
-
}
|
251
|
-
|
252
245
|
code.literal {
|
253
246
|
/* don't let it affect line spacing */
|
254
247
|
/* disable since M+ 1mn won't interrupt line height */
|
@@ -685,12 +678,6 @@ div.abstract > p {
|
|
685
678
|
line-height: 1.75;
|
686
679
|
}
|
687
680
|
|
688
|
-
div.abstract > p a:link {
|
689
|
-
color: #333332;
|
690
|
-
/* hack for font color in iBooks */
|
691
|
-
-webkit-text-fill-color: #333332;
|
692
|
-
}
|
693
|
-
|
694
681
|
div.abstract > p:first-child::first-line {
|
695
682
|
font-weight: bold;
|
696
683
|
-webkit-font-feature-settings: "kern" off;
|
@@ -39,9 +39,9 @@ module Asciidoctor
|
|
39
39
|
|
40
40
|
if @format == :kf8
|
41
41
|
# QUESTION shouldn't we validate this epub file too?
|
42
|
-
distill_epub_to_mobi epub_file, target, @compress
|
42
|
+
distill_epub_to_mobi epub_file, target, @compress
|
43
43
|
elsif @validate
|
44
|
-
validate_epub epub_file
|
44
|
+
validate_epub epub_file
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -105,7 +105,7 @@ module Asciidoctor
|
|
105
105
|
if respond_to? method_name
|
106
106
|
send method_name, node
|
107
107
|
else
|
108
|
-
logger.warn %(
|
108
|
+
logger.warn %(conversion missing in backend #{@backend} for #{name})
|
109
109
|
nil
|
110
110
|
end
|
111
111
|
end
|
@@ -143,6 +143,10 @@ module Asciidoctor
|
|
143
143
|
title
|
144
144
|
end
|
145
145
|
|
146
|
+
def icon_names
|
147
|
+
@icon_names ||= []
|
148
|
+
end
|
149
|
+
|
146
150
|
def convert_document node
|
147
151
|
@format = node.attr('ebook-format').to_sym
|
148
152
|
|
@@ -152,8 +156,7 @@ module Asciidoctor
|
|
152
156
|
@kindlegen_path = node.attr 'ebook-kindlegen-path'
|
153
157
|
@epubcheck_path = node.attr 'ebook-epubcheck-path'
|
154
158
|
@xrefs_seen = ::Set.new
|
155
|
-
@
|
156
|
-
@media_files = []
|
159
|
+
@media_files = {}
|
157
160
|
@footnotes = []
|
158
161
|
|
159
162
|
@book = GEPUB::Book.new 'EPUB/package.opf'
|
@@ -267,14 +270,14 @@ module Asciidoctor
|
|
267
270
|
docimagesdir = (node.attr 'imagesdir', '.').chomp '/'
|
268
271
|
docimagesdir = (docimagesdir == '.' ? nil : %(#{docimagesdir}/))
|
269
272
|
|
270
|
-
@media_files.each do |file|
|
271
|
-
if
|
272
|
-
logger.warn %(path is reserved for cover artwork: #{
|
273
|
+
@media_files.each do |name, file|
|
274
|
+
if name.start_with? %(#{docimagesdir}jacket/cover.)
|
275
|
+
logger.warn %(path is reserved for cover artwork: #{name}; skipping file found in content)
|
273
276
|
elsif file[:path].nil? || File.readable?(file[:path])
|
274
|
-
mime_types = MIME::Types.type_for
|
277
|
+
mime_types = MIME::Types.type_for name
|
275
278
|
mime_types.delete_if {|x| x.media_type != file[:media_type] }
|
276
279
|
preferred_mime_type = mime_types.empty? ? nil : mime_types[0].content_type
|
277
|
-
@book.add_item
|
280
|
+
@book.add_item name, content: file[:path], media_type: preferred_mime_type
|
278
281
|
else
|
279
282
|
logger.error %(#{File.basename node.attr('docfile')}: media file not found or not readable: #{file[:path]})
|
280
283
|
end
|
@@ -328,7 +331,7 @@ module Asciidoctor
|
|
328
331
|
chapter_item = @book.add_ordered_item %(#{docid}.xhtml)
|
329
332
|
|
330
333
|
doctitle = node.document.doctitle partition: true, use_fallback: true
|
331
|
-
|
334
|
+
chapter_title = doctitle.combined
|
332
335
|
|
333
336
|
if node.context == :document && doctitle.subtitle?
|
334
337
|
title = %(#{doctitle.main} )
|
@@ -337,7 +340,7 @@ module Asciidoctor
|
|
337
340
|
# HACK: until we get proper handling of title-only in CSS
|
338
341
|
title = ''
|
339
342
|
subtitle = get_numbered_title node
|
340
|
-
|
343
|
+
chapter_title = subtitle
|
341
344
|
else
|
342
345
|
title = nil
|
343
346
|
subtitle = nil
|
@@ -360,10 +363,10 @@ module Asciidoctor
|
|
360
363
|
|
361
364
|
# NOTE must run after content is resolved
|
362
365
|
# TODO perhaps create dynamic CSS file?
|
363
|
-
if
|
366
|
+
if icon_names.empty?
|
364
367
|
icon_css_head = ''
|
365
368
|
else
|
366
|
-
icon_defs =
|
369
|
+
icon_defs = icon_names.map {|name|
|
367
370
|
%(.i-#{name}::before { content: "#{FontIconMap.unicode name}"; })
|
368
371
|
} * LF
|
369
372
|
icon_css_head = %(<style>
|
@@ -387,7 +390,7 @@ module Asciidoctor
|
|
387
390
|
<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', 'en'}" lang="#{lang}">
|
388
391
|
<head>
|
389
392
|
<meta charset="UTF-8"/>
|
390
|
-
<title>#{
|
393
|
+
<title>#{chapter_title}</title>
|
391
394
|
<link rel="stylesheet" type="text/css" href="styles/epub3.css"/>
|
392
395
|
<link rel="stylesheet" type="text/css" href="styles/epub3-css3-only.css" media="(min-device-width: 0px)"/>
|
393
396
|
#{icon_css_head}<script type="text/javascript"><![CDATA[
|
@@ -401,11 +404,13 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
401
404
|
]]></script>)]
|
402
405
|
|
403
406
|
syntax_hl = node.document.syntax_highlighter
|
407
|
+
epub_type_attr = node.respond_to?(:section) && node.sectname != 'section' ? %( epub:type="#{node.sectname}") : ''
|
408
|
+
|
404
409
|
lines << (syntax_hl.docinfo :head, node, linkcss: linkcss, self_closing_tag_slash: '/') if syntax_hl&.docinfo? :head
|
405
410
|
|
406
411
|
lines << %(</head>
|
407
412
|
<body>
|
408
|
-
<section class="chapter" title
|
413
|
+
<section class="chapter" title=#{chapter_title.encode xml: :attr}#{epub_type_attr} id="#{docid}">
|
409
414
|
#{header}
|
410
415
|
#{content})
|
411
416
|
|
@@ -446,11 +451,10 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
446
451
|
def convert_section node
|
447
452
|
if add_chapter(node).nil?
|
448
453
|
hlevel = node.level
|
449
|
-
epub_type_attr = node.
|
454
|
+
epub_type_attr = node.sectname != 'section' ? %( epub:type="#{node.sectname}") : ''
|
450
455
|
div_classes = [%(sect#{node.level}), node.role].compact
|
451
456
|
title = get_numbered_title node
|
452
|
-
|
453
|
-
%(<section class="#{div_classes * ' '}" title="#{title_sanitized}"#{epub_type_attr}>
|
457
|
+
%(<section class="#{div_classes * ' '}" title=#{title.encode xml: :attr}#{epub_type_attr}>
|
454
458
|
<h#{hlevel} id="#{node.id}">#{title}</h#{hlevel}>#{(content = node.content).empty? ? '' : %(
|
455
459
|
#{content})}
|
456
460
|
</section>)
|
@@ -533,14 +537,12 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
533
537
|
type = node.attr 'name'
|
534
538
|
epub_type = case type
|
535
539
|
when 'tip'
|
536
|
-
'
|
537
|
-
when 'note'
|
538
|
-
'
|
539
|
-
when 'important', 'warning', 'caution'
|
540
|
-
'warning'
|
540
|
+
'tip'
|
541
|
+
when 'important', 'warning', 'caution', 'note'
|
542
|
+
'notice'
|
541
543
|
else
|
542
544
|
logger.warn %(unknown admonition type: #{type})
|
543
|
-
'
|
545
|
+
'notice'
|
544
546
|
end
|
545
547
|
%(<aside#{id_attr} class="admonition #{type}"#{title_attr} epub:type="#{epub_type}">
|
546
548
|
#{title_el}<div class="content">
|
@@ -567,6 +569,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
567
569
|
end
|
568
570
|
|
569
571
|
def convert_listing node
|
572
|
+
id_attribute = node.id ? %( id="#{node.id}") : ''
|
570
573
|
nowrap = (node.option? 'nowrap') || !(node.document.attr? 'prewrap')
|
571
574
|
if node.style == 'source'
|
572
575
|
lang = node.attr 'language'
|
@@ -589,7 +592,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
589
592
|
figure_classes = ['listing']
|
590
593
|
figure_classes << 'coalesce' if node.option? 'unbreakable'
|
591
594
|
title_div = node.title? ? %(<figcaption>#{node.captioned_title}</figcaption>) : ''
|
592
|
-
%(<figure class="#{figure_classes * ' '}">#{title_div}
|
595
|
+
%(<figure#{id_attribute} class="#{figure_classes * ' '}">#{title_div}
|
593
596
|
#{syntax_hl ? (syntax_hl.format node, lang, opts) : pre_open + (node.content || '') + pre_close}
|
594
597
|
</figure>)
|
595
598
|
end
|
@@ -617,9 +620,13 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
617
620
|
Helpers.require_library('asciimath', true, :warn).nil? ? :unavailable : :loaded
|
618
621
|
end
|
619
622
|
|
620
|
-
# QUESTION should we wrap the <pre> in either <div> or <figure>?
|
621
623
|
def convert_literal node
|
622
|
-
%(
|
624
|
+
id_attribute = node.id ? %( id="#{node.id}") : ''
|
625
|
+
title_element = node.title? ? %(<figcaption>#{node.captioned_title}</figcaption>) : ''
|
626
|
+
%(<figure#{id_attribute} class="literalblock#{prepend_space node.role}">
|
627
|
+
#{title_element}
|
628
|
+
<div class="content"><pre class="screen">#{node.content}</pre></div>
|
629
|
+
</figure>)
|
623
630
|
end
|
624
631
|
|
625
632
|
def convert_page_break _node
|
@@ -712,10 +719,8 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
712
719
|
table_styles = []
|
713
720
|
if (autowidth = node.option? 'autowidth') && !(node.attr? 'width')
|
714
721
|
table_classes << 'fit-content'
|
715
|
-
elsif (tablewidth = node.attr 'tablepcwidth') == 100
|
716
|
-
table_classes << 'stretch'
|
717
722
|
else
|
718
|
-
table_styles << %(width: #{
|
723
|
+
table_styles << %(width: #{node.attr 'tablepcwidth'}%;)
|
719
724
|
end
|
720
725
|
table_class_attr = %( class="#{table_classes * ' '}")
|
721
726
|
table_style_attr = !table_styles.empty? ? %( style="#{table_styles * '; '}") : ''
|
@@ -966,6 +971,8 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
966
971
|
epub_properties << 'svg' unless epub_properties.include? 'svg'
|
967
972
|
end
|
968
973
|
|
974
|
+
return if target.start_with? 'data:'
|
975
|
+
|
969
976
|
if Asciidoctor::Helpers.uriish? target
|
970
977
|
# We need to add both local and remote media files to manifest
|
971
978
|
fs_path = nil
|
@@ -978,7 +985,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
978
985
|
end
|
979
986
|
end
|
980
987
|
# We need *both* virtual and physical image paths. Unfortunately, references[:images] only has one of them.
|
981
|
-
@media_files
|
988
|
+
@media_files[target] ||= { path: fs_path, media_type: media_type }
|
982
989
|
end
|
983
990
|
|
984
991
|
def resolve_image_attrs node
|
@@ -1165,7 +1172,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
|
|
1165
1172
|
|
1166
1173
|
def convert_inline_image node
|
1167
1174
|
if node.type == 'icon'
|
1168
|
-
|
1175
|
+
icon_names << (icon_name = node.target)
|
1169
1176
|
i_classes = ['icon', %(i-#{icon_name})]
|
1170
1177
|
i_classes << %(icon-#{node.attr 'size'}) if node.attr? 'size'
|
1171
1178
|
i_classes << %(icon-flip-#{(node.attr 'flip')[0]}) if node.attr? 'flip'
|
@@ -1626,10 +1633,10 @@ body > svg {
|
|
1626
1633
|
.to_ios
|
1627
1634
|
end
|
1628
1635
|
|
1629
|
-
def get_kindlegen_command
|
1630
|
-
unless kindlegen_path.nil?
|
1631
|
-
logger.debug %(Using ebook-kindlegen-path attribute: #{kindlegen_path})
|
1632
|
-
return [kindlegen_path]
|
1636
|
+
def get_kindlegen_command
|
1637
|
+
unless @kindlegen_path.nil?
|
1638
|
+
logger.debug %(Using ebook-kindlegen-path attribute: #{@kindlegen_path})
|
1639
|
+
return [@kindlegen_path]
|
1633
1640
|
end
|
1634
1641
|
|
1635
1642
|
unless (result = ENV['KINDLEGEN']).nil?
|
@@ -1637,22 +1644,15 @@ body > svg {
|
|
1637
1644
|
return [result]
|
1638
1645
|
end
|
1639
1646
|
|
1640
|
-
|
1641
|
-
|
1642
|
-
result = ::Kindlegen.command.to_s
|
1643
|
-
logger.debug %(Using KindleGen from gem: #{result})
|
1644
|
-
[result]
|
1645
|
-
rescue LoadError => e
|
1646
|
-
logger.debug %(#{e}; Using KindleGen from PATH)
|
1647
|
-
[%(kindlegen#{::Gem.win_platform? ? '.exe' : ''})]
|
1648
|
-
end
|
1647
|
+
logger.debug 'Using KindleGen from PATH'
|
1648
|
+
[%(kindlegen#{::Gem.win_platform? ? '.exe' : ''})]
|
1649
1649
|
end
|
1650
1650
|
|
1651
|
-
def distill_epub_to_mobi epub_file, target, compress
|
1651
|
+
def distill_epub_to_mobi epub_file, target, compress
|
1652
1652
|
mobi_file = ::File.basename target.sub(EpubExtensionRx, '.mobi')
|
1653
1653
|
compress_flag = KindlegenCompression[compress ? (compress.empty? ? '1' : compress.to_s) : '0']
|
1654
1654
|
|
1655
|
-
argv = get_kindlegen_command
|
1655
|
+
argv = get_kindlegen_command + ['-dont_append_source', compress_flag, '-o', mobi_file, epub_file].compact
|
1656
1656
|
begin
|
1657
1657
|
# This duplicates Kindlegen.run, but we want to override executable
|
1658
1658
|
out, err, res = Open3.capture3(*argv) do |r|
|
@@ -1677,10 +1677,10 @@ body > svg {
|
|
1677
1677
|
end
|
1678
1678
|
end
|
1679
1679
|
|
1680
|
-
def get_epubcheck_command
|
1681
|
-
unless epubcheck_path.nil?
|
1682
|
-
logger.debug %(Using ebook-epubcheck-path attribute: #{epubcheck_path})
|
1683
|
-
return [epubcheck_path]
|
1680
|
+
def get_epubcheck_command
|
1681
|
+
unless @epubcheck_path.nil?
|
1682
|
+
logger.debug %(Using ebook-epubcheck-path attribute: #{@epubcheck_path})
|
1683
|
+
return [@epubcheck_path]
|
1684
1684
|
end
|
1685
1685
|
|
1686
1686
|
unless (result = ENV['EPUBCHECK']).nil?
|
@@ -1698,8 +1698,8 @@ body > svg {
|
|
1698
1698
|
end
|
1699
1699
|
end
|
1700
1700
|
|
1701
|
-
def validate_epub epub_file
|
1702
|
-
argv = get_epubcheck_command
|
1701
|
+
def validate_epub epub_file
|
1702
|
+
argv = get_epubcheck_command + ['-w', epub_file]
|
1703
1703
|
begin
|
1704
1704
|
out, err, res = Open3.capture3(*argv)
|
1705
1705
|
rescue Errno::ENOENT => e
|
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: 1.5.0.alpha.
|
4
|
+
version: 1.5.0.alpha.19
|
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: 2020-
|
12
|
+
date: 2020-10-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: asciidoctor-diagram
|
@@ -287,7 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
287
287
|
- !ruby/object:Gem::Version
|
288
288
|
version: 1.3.1
|
289
289
|
requirements: []
|
290
|
-
rubygems_version: 3.1.
|
290
|
+
rubygems_version: 3.1.4
|
291
291
|
signing_key:
|
292
292
|
specification_version: 4
|
293
293
|
summary: Converts AsciiDoc documents to EPUB3 and KF8/MOBI (Kindle) e-book formats
|