asciidoctor-epub3 1.5.0.alpha.17 → 1.5.0.alpha.18

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: 22c90a180a710ca315f1ef423cd70f5420a9e37ae045e4c0897e737161f1577d
4
- data.tar.gz: f7c2398e711e506b3b3c5acecc46bf07e7a2ffc91feec0a72428988f0888350d
3
+ metadata.gz: 352b650ba19d840c6f0eb7cdcc1f6abe941d05316b4d92d220faf2e21b63ba87
4
+ data.tar.gz: fd2a164d0c20c9ee6415e47d9d77db71f6ba09500219778508794e6210b93130
5
5
  SHA512:
6
- metadata.gz: fa4efe81a7a55f9fa7e186d86109b44853ecf9a97c1261ae5cfc5f0edced42911a4bfadabcc236cc39c49ac1d3fc24faba33b48578db66de40afbe36e89ff2cf
7
- data.tar.gz: 300b3859bb41288dbcc06b87d810bb4a547b708a20f42fa555ddf3f44cace89a44d37b4a9532c948ebaea50b693e47a46876b2e92c49e3fb4031593469c87c6b
6
+ metadata.gz: be30f10eaa7309066230c86e3f124cda27a9668a0b1eac7ac2d68f70eddacb2ab9886dadcd96ac292845d4da28c52ffefa63ded60282cbf0d55c39fa8efbf0df
7
+ data.tar.gz: 3e1ec0eef64136a609d402a5cae8b4bb03007ea462a362f2e33df55ed0b84bdc624c61b9813cafca1a35d81401c31859fef28f487505aaaaa036944134f7ad77
@@ -5,6 +5,18 @@
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.18 (2020-07-27) - @slonopotamus
9
+
10
+ * remove <b> from chapter subtitle (#123)
11
+ * improve tables support: cell content alignment, column width (#350)
12
+ * fix chapter titles to actually be chapter titles instead of document title (#343)
13
+ * store syntax highlighter CSS in a separate file (#339)
14
+ * initial landmarks support: appendix, bibliography, bodymatter, cover, frontmatter, glossary, index, preface, toc (#174)
15
+ * add support for in-document table of contents via `:toc:` document attribute (#174)
16
+ * add support for MathML (#10)
17
+ * rescale color palette to use darker shades of gray (#338)
18
+ * gracefully handle invalid `:front-cover-image:` value (#353)
19
+
8
20
  == 1.5.0.alpha.17 (2020-05-25) - @slonopotamus
9
21
 
10
22
  * support remote URLs for audio/video/image (#333, #334)
data/Gemfile CHANGED
@@ -13,7 +13,7 @@ end
13
13
 
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
- gem 'epubcheck-ruby', '~> 4.2.2.0'
16
+ gem 'epubcheck-ruby', '~> 4.2.4.0'
17
17
  # We would like to make kindlegen a runtime dependency, but can't because of the way asciidoctorj-epub3 packaging works
18
18
  # See https://github.com/asciidoctor/asciidoctor-epub3/issues/288
19
19
  gem 'kindlegen', '~> 3.0.3'
@@ -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.17, 2020-05-25
3
+ v1.5.0.alpha.18, 2020-07-27
4
4
  // Settings:
5
5
  :experimental:
6
6
  :idprefix:
@@ -27,30 +27,30 @@ endif::[]
27
27
  :project-handle: asciidoctor-epub3
28
28
  // URIs:
29
29
  :uri-project: https://github.com/asciidoctor/{project-handle}
30
- :uri-gem: http://rubygems.org/gems/asciidoctor-epub3
30
+ :uri-gem: https://rubygems.org/gems/asciidoctor-epub3
31
31
  :uri-repo: {uri-project}
32
32
  :uri-issues: {uri-repo}/issues
33
- :uri-ci: {uri-repo}/actions?query=workflow%3ACI
34
- :uri-discuss: http://discuss.asciidoctor.org
33
+ :uri-ci: {uri-repo}/actions?query=branch%3Amaster
34
+ :uri-discuss: https://discuss.asciidoctor.org/
35
35
  :uri-rvm: https://rvm.io
36
- :uri-asciidoctor: http://asciidoctor.org
36
+ :uri-asciidoctor: https://asciidoctor.org/
37
37
  :uri-idpf: http://www.idpf.org/
38
38
  :uri-epub: http://www.idpf.org/epub/31/spec/epub-spec.html
39
- :uri-epubcheck: https://github.com/idpf/epubcheck
40
- :uri-kindlegen: http://www.amazon.com/gp/feature.html?docId=1000765211
39
+ :uri-epubcheck: https://github.com/w3c/epubcheck
40
+ :uri-kindlegen: https://www.amazon.com/gp/feature.html?docId=1000765211
41
41
  :uri-kf8: http://www.amazon.com/gp/feature.html?docId=1000729511
42
42
  :uri-send-to-kindle: https://www.amazon.com/gp/sendtokindle/
43
43
  :uri-metadata-elem: http://www.idpf.org/epub/30/spec/epub30-publications.html#sec-metadata-elem
44
- :uri-dc: http://dublincore.org/documents/2004/12/20/dces
44
+ :uri-dc: https://www.dublincore.org/specifications/dublin-core/dces/2004-12-20/
45
45
  :uri-github-guides: https://guides.github.com
46
46
  :uri-github-guides-fork: https://github.com/opendevise/github-guides-asciidoc
47
- :uri-asciidoctor-i18n: http://asciidoctor.org/docs/user-manual/#builtin-attributes-i18n
47
+ :uri-asciidoctor-i18n: https://asciidoctor.org/docs/user-manual/#builtin-attributes-i18n
48
48
  :uri-epubreadingsystem: http://www.idpf.org/epub/301/spec/epub-contentdocs.html#app-epubReadingSystem
49
- :uri-android-sdk: http://developer.android.com/sdk/index.html
49
+ :uri-android-sdk: https://developer.android.com/sdk/index.html
50
50
 
51
51
  ifdef::status[]
52
52
  image:https://img.shields.io/gem/v/asciidoctor-epub3.svg[Latest Release,link={uri-gem}]
53
- image:{uri-repo}/workflows/CI/badge.svg[GitHub Actions,link={uri-ci}]
53
+ image:{uri-repo}/workflows/CI/badge.svg?branch=master[GitHub Actions,link={uri-ci}]
54
54
  endif::[]
55
55
 
56
56
  {project-name} is a set of Asciidoctor extensions for converting AsciiDoc documents directly to the EPUB3 and KF8/MOBI e-book formats.
@@ -108,6 +108,7 @@ Of course, there's always room for improvement, so we'll continue to work with y
108
108
  * Orphan section titles avoided (so much as it's supported by the e-reader)
109
109
  * Table border settings honored
110
110
  * Support for SVG images in the content
111
+ * Stem blocks via AsciiMath
111
112
 
112
113
  === Project Status
113
114
 
@@ -121,7 +122,7 @@ We may explore the use of fixed layout documents in the future if the need arise
121
122
  ifdef::env-github[]
122
123
  === Planned Features and Work In Progress
123
124
 
124
- See <<WORKLOG#,WORKLOG.adoc>>.
125
+ See link:WORKLOG.adoc[].
125
126
  endif::[]
126
127
 
127
128
  == Converter Workflow
@@ -321,6 +322,12 @@ Volume is a number, ID probably a UUID that is constant for all volumes in the s
321
322
  |Used to control the inclusion of special content in the generated HTML.
322
323
  If set to a value other than book, the byline information (author and avatar) is included below the chapter header and a typographic end mark is added at the end of the last paragraph.
323
324
  Suggested values include: book (default), article.
325
+
326
+ |toc
327
+ |Adds table of contents at the beginning of the book. Depth is controlled by `:toclevels:` attribute.
328
+
329
+ |outlinelevels
330
+ |Sets the depth of table of contents metadata. If not set, defaults to `:toclevels:`
324
331
  |===
325
332
 
326
333
  When using the EPUB3 converter, the `ebook-format` attribute resolves to the name of the e-book format being generated (epub3 or kf8) and the corresponding attribute `ebook-format-<name>` is defined, where `<name>` is `epub3` or `kf8`.
@@ -602,7 +609,7 @@ The theme's fonts are located in the [path]_data/fonts_ directory.
602
609
  The M+ Outline fonts are used for titles, headings, literal (monospace) text, and annotation numbers.
603
610
  The body text uses Noto Serif.
604
611
  Admonition icons and the end-of-chapter mark are from the Font Awesome icon font.
605
- Refer to the <<NOTICE#,NOTICE>> file for further information about the fonts.
612
+ Refer to the link:NOTICE.adoc[] file for further information about the fonts.
606
613
 
607
614
  // TODO document command to generate the M+ 1p latin fonts
608
615
 
@@ -898,7 +905,7 @@ Copyright (C) 2014-2019 OpenDevise Inc. and the Asciidoctor Project.
898
905
  Free use of this software is granted under the terms of the MIT License.
899
906
 
900
907
  For the full text of the license, see the link:LICENSE[] file.
901
- Refer to the <<NOTICE#,NOTICE>> file for information about third-party Open Source software in use.
908
+ Refer to the link:NOTICE.adoc[] file for information about third-party Open Source software in use.
902
909
 
903
910
  ////
904
911
  == Additional Points of Note
@@ -31,6 +31,7 @@ An extension for Asciidoctor that converts AsciiDoc documents to EPUB3 and KF8/M
31
31
  s.require_paths = ['lib']
32
32
 
33
33
  s.add_development_dependency 'asciidoctor-diagram', '>= 1.5.0', '< 3.0.0'
34
+ s.add_development_dependency 'asciimath', '~> 2.0'
34
35
  s.add_development_dependency 'coderay', '~> 1.1.0'
35
36
  s.add_development_dependency 'pygments.rb', '~> 1.2.0'
36
37
  s.add_development_dependency 'rake', '~> 13.0.0'
@@ -1,14 +1,11 @@
1
1
  .palette-grayscale {
2
- color: #191918; /* black :: literal, blockquote text */
3
- color: #333332; /* off-black :: body text, heading default, chapter header background */
4
- color: #4F4F4C; /* deep gray :: h4 */
5
- /* what about 40403E or 4C4C4B? for h4 */
6
- color: #666665; /* dark gray :: h5, visited link, list bullets, abstract, caption, open quote */
7
- color: #80807F; /* medium gray :: table borders */
8
- color: #B3B3B1; /* gray :: chapter title, footer subtitle, sidebar border */
9
- color: #DCDCDE; /* lighter gray :: footer lines, byline text, pre border, masthead bottom line */
10
- /* what about DEDEDC instead of DCDCDE? */
11
- color: #F2F2F2; /* off white :: pre background, sidebar background */
2
+ color: #000000; /* black :: body text, heading default */
3
+ color: #101010; /* off-black :: code, literal, blockquote text */
4
+ color: #202020; /* deep gray :: h4 */
5
+ color: #333332; /* dark gray :: h5, visited link, list bullets, abstract, caption, open quote */
6
+ color: #707070; /* medium gray :: table borders */
7
+ color: #C8C8C8; /* gray :: footer subtitle, sidebar border */
8
+ color: #E0E0E0; /* off white :: pre background, sidebar background */
12
9
  color: #FFFFFF; /* white :: chapter subtitle */
13
10
  }
14
11
 
@@ -75,23 +75,6 @@ body code, body kbd, body pre, pre :not(code) {
75
75
  th, td, figcaption, caption {
76
76
  text-rendering: optimizeLegibility;
77
77
  }*/
78
- /* hack line height of subtitle using floats on Kindle */
79
- h1.chapter-title .subtitle {
80
- margin-top: -0.2em;
81
- margin-bottom: 0.3em; /* compensate for reduced line height */
82
- }
83
-
84
- /* NOTE using b instead of span since Firefox ePubReader applies immutable styles to span */
85
- h1.chapter-title .subtitle > b {
86
- float: left;
87
- display: inline-block;
88
- margin-bottom: -0.3em; /* reduce the line height */
89
- padding-right: 0.2em; /* spacing between words */
90
- }
91
-
92
- h1.chapter-title .subtitle > b:last-child {
93
- padding-right: 0;
94
- }
95
78
 
96
79
  h1.chapter-title .subtitle::after {
97
80
  display: table;
@@ -100,39 +83,6 @@ body code, body kbd, body pre, pre :not(code) {
100
83
  }
101
84
  }
102
85
 
103
- /* Use darker font colors on Kindle Paperwhite */
104
- @media amzn-kf8 and (device-height: 1024px) and (device-width: 758px), amzn-kf8 and (device-height: 758px) and (device-width: 1024px) {
105
- body p,
106
- div.abstract > p,
107
- ul, ol, li, dl, dt, dd, footer,
108
- div.verse .attribution, table.table th, table.table td,
109
- figcaption, caption,
110
- h1, h2, h3, h4, h5 {
111
- color: #000000;
112
- }
113
-
114
- body a:link,
115
- div.abstract > p a:link {
116
- color: #000000;
117
- -webkit-text-fill-color: #000000;
118
- }
119
-
120
- body a:visited {
121
- color: #333332;
122
- -webkit-text-fill-color: #333332;
123
- }
124
-
125
- .chapter-header {
126
- color: #191918;
127
- border-bottom-color: #191918;
128
- }
129
-
130
- h1.chapter-title .subtitle,
131
- .chapter-header p.byline {
132
- color: #000000;
133
- }
134
- }
135
-
136
86
  .chapter-header p.byline {
137
87
  height: auto; /* Aldiko requires this value to be 0; reset it for all others */
138
88
  }
@@ -81,8 +81,8 @@ b, strong {
81
81
 
82
82
  b.button {
83
83
  font-weight: normal;
84
- text-shadow: 1px 0 0 #666665;
85
- color: #191918;
84
+ text-shadow: 1px 0 0 #333332;
85
+ color: #101010;
86
86
  white-space: nowrap;
87
87
  }
88
88
 
@@ -143,7 +143,7 @@ img {
143
143
 
144
144
  mark {
145
145
  background-color: #FFC14F;
146
- color: #191918;
146
+ color: #101010;
147
147
  }
148
148
 
149
149
  small {
@@ -198,14 +198,36 @@ td, th {
198
198
  padding: 0;
199
199
  }
200
200
 
201
+ /* We need to apply text-align to <p> too in order to override global text-align:justify */
202
+ th.halign-left, td.halign-left, th.halign-left > p, td.halign-left > p {
203
+ text-align: left
204
+ }
205
+
206
+ th.halign-right, td.halign-right, th.halign-right > p, td.halign-right > p {
207
+ text-align: right
208
+ }
209
+
210
+ th.halign-center, td.halign-center, th.halign-center > p, td.halign-center > p {
211
+ text-align: center
212
+ }
213
+
214
+ th.valign-top, td.valign-top, th.valign-top > p, td.valign-top > p {
215
+ vertical-align: top
216
+ }
217
+
218
+ th.valign-bottom, td.valign-bottom, th.valign-bottom > p, td.valign-bottom > p {
219
+ vertical-align: bottom
220
+ }
221
+
222
+ th.valign-middle, td.valign-middle, th.valign-middle > p, td.valign-middle > p {
223
+ vertical-align: middle
224
+ }
225
+
201
226
  body a:link {
202
- color: #333332;
203
- /* hack for font color in iBooks and Gitden (though Gitden would accept color !important too) */
204
- -webkit-text-fill-color: #333332;
205
227
  /* Kindle requires the !important on text-decoration */
206
228
  /* In night mode, the only indicator of a link is the underline, so we need it or a background image */
207
229
  text-decoration: none !important;
208
- border-bottom: 1px dashed #666665;
230
+ border-bottom: 1px dashed #333332;
209
231
  /* allow URLs to break anywhere if they don't fit on a line; but how do we know it's a URL? */
210
232
  /*
211
233
  word-break: break-all;
@@ -222,9 +244,9 @@ body:first-of-type a:link {
222
244
  }
223
245
 
224
246
  body a:visited {
225
- color: #666665;
247
+ color: #333332;
226
248
  /* hack for font color in iBooks */
227
- -webkit-text-fill-color: #666665;
249
+ -webkit-text-fill-color: #333332;
228
250
  }
229
251
 
230
252
  code.literal {
@@ -270,7 +292,6 @@ body p,
270
292
  ul, ol, li, dl, dt, dd, footer,
271
293
  div.verse .attribution, table.table th, table.table td,
272
294
  figcaption, caption {
273
- color: #333332;
274
295
  /* NOTE iBooks will forcefully override font-family of text inside div, p and span elements when font other than Original is selected */
275
296
  /* NOTE iBooks honors Original font for prose text if declared in display-options.xml */
276
297
  font-family: "Noto Serif", serif;
@@ -281,7 +302,7 @@ body p, li, dt, dd, footer {
281
302
  }
282
303
 
283
304
  code, kbd, pre {
284
- color: #191918;
305
+ color: #101010;
285
306
  font-family: "M+ 1mn", monospace;
286
307
  -webkit-hyphens: none; /* disable hyphenation where supported (e.g., iBooks) */
287
308
  }
@@ -462,7 +483,7 @@ ul > li::before {
462
483
 
463
484
  ul > li::before {
464
485
  content: "\25AA"; /* small black square */
465
- color: #666665;
486
+ color: #333332;
466
487
  }
467
488
 
468
489
  ul ul > li::before {
@@ -472,7 +493,7 @@ ul ul > li::before {
472
493
 
473
494
  ul ul ul > li::before {
474
495
  content: "\2022"; /* small black circle */
475
- color: #666665;
496
+ color: #333332;
476
497
  }
477
498
 
478
499
  ul ul ul ul > li::before {
@@ -534,7 +555,6 @@ ul.references > li > span.principal {
534
555
 
535
556
  /* sized based on the major third modular scale (4:5, 16px, 24px) */
536
557
  h1, h2 {
537
- color: #333332;
538
558
  font-size: 1.5em;
539
559
  word-spacing: -0.075em;
540
560
  margin-top: 1em; /* 1.5rem */
@@ -542,14 +562,13 @@ h1, h2 {
542
562
  }
543
563
 
544
564
  h3 {
545
- color: #333332;
546
565
  font-size: 1.25em;
547
566
  margin-top: 0.84em; /* 1.05rem */
548
567
  margin-bottom: -0.5em; /* -0.625rem, 0.375rem to content */
549
568
  }
550
569
 
551
570
  h4 {
552
- color: #4F4F4C;
571
+ color: #202020;
553
572
  font-weight: 200;
554
573
 
555
574
  font-size: 1.1em;
@@ -564,7 +583,7 @@ h4 {
564
583
  }
565
584
 
566
585
  h5 {
567
- color: #666665;
586
+ color: #333332;
568
587
  /*
569
588
  font-size: 1em;
570
589
  text-transform: uppercase;
@@ -594,7 +613,7 @@ h5 code {
594
613
  /*padding: 0.75em 1.5em 0.25em 1.5em;*/
595
614
  padding: 0.25em 0;
596
615
  margin-bottom: 2.5em;
597
- border-bottom: 1px solid #666665;
616
+ border-bottom: 1px solid #333332;
598
617
  /* TODO maybe what we need to get articles to start in left column
599
618
  -webkit-column-break-before: left;
600
619
  page-break-before: left;
@@ -607,7 +626,7 @@ h1.chapter-title {
607
626
  margin-top: 3.5em; /* 4.2rem - would like to use 9vh */
608
627
  margin-bottom: 0;
609
628
  padding-bottom: 0.8333em; /* 1.2rem */
610
- color: #666665;
629
+ color: #333332;
611
630
  text-transform: uppercase; /* not supported in Adobe Digital Editions */
612
631
  word-spacing: -0.075em;
613
632
  letter-spacing: -0.01em;
@@ -615,7 +634,6 @@ h1.chapter-title {
615
634
 
616
635
  h1.chapter-title .subtitle {
617
636
  font-weight: 400;
618
- color: #333332;
619
637
  display: block;
620
638
  font-size: 1.5em;
621
639
  margin: 0 0 0 0.75em; /* would like to use 2vw */
@@ -632,7 +650,6 @@ h1.chapter-title b {
632
650
  }
633
651
 
634
652
  .chapter-header p.byline {
635
- color: #333332;
636
653
  /* float left and height 0 takes this line out of the flow */
637
654
  float: left;
638
655
  height: 0;
@@ -663,15 +680,15 @@ div.abstract {
663
680
  }
664
681
 
665
682
  div.abstract > p {
666
- color: #666665;
683
+ color: #333332;
667
684
  font-size: 1.05em; /* or 1.1em? */
668
685
  line-height: 1.75;
669
686
  }
670
687
 
671
688
  div.abstract > p a:link {
672
- color: #666665;
689
+ color: #333332;
673
690
  /* hack for font color in iBooks */
674
- -webkit-text-fill-color: #666665;
691
+ -webkit-text-fill-color: #333332;
675
692
  }
676
693
 
677
694
  div.abstract > p:first-child::first-line {
@@ -748,7 +765,7 @@ figcaption,
748
765
  caption {
749
766
  font-size: 0.9em;
750
767
  font-style: italic;
751
- color: #666665;
768
+ color: #333332;
752
769
  letter-spacing: -0.01em;
753
770
  line-height: 1.4;
754
771
  text-align: left;
@@ -780,10 +797,10 @@ figure.listing > figcaption + pre {
780
797
  }
781
798
 
782
799
  aside.sidebar {
783
- border: 1px solid #B3B3B1;
800
+ border: 1px solid #C8C8C8;
784
801
  padding: 0 1.5em;
785
802
  font-size: 0.9em;
786
- background-color: #F2F2F2;
803
+ background-color: #E0E0E0;
787
804
  text-align: right; /* aligns heading to right */
788
805
  /*
789
806
  -webkit-box-shadow: 0px 1px 1px rgba(102, 102, 101, 0.15);
@@ -811,7 +828,7 @@ aside.sidebar > h2 {
811
828
  letter-spacing: 0;
812
829
  display: inline-block;
813
830
  white-space: nowrap; /* for some reason it's wrapping prematurely */
814
- border: 1px solid #B3B3B1;
831
+ border: 1px solid #C8C8C8;
815
832
  padding: 1.5em .75em .5em .75em;
816
833
  margin: -1em 0.5em -0.25em 0.5em;
817
834
  background-color: #FFFFFF;
@@ -848,7 +865,7 @@ div[class~="blockquote"] {
848
865
  }
849
866
 
850
867
  blockquote > p {
851
- color: #191918;
868
+ color: #101010;
852
869
  font-style: italic;
853
870
 
854
871
  /*
@@ -865,7 +882,7 @@ blockquote > p {
865
882
 
866
883
  blockquote > p:first-of-type::before {
867
884
  display: inline-block;
868
- color: #666665;
885
+ color: #333332;
869
886
  text-shadow: 0 1px 2px rgba(102, 102, 101, 0.3);
870
887
 
871
888
  /* using serif quote from entypo */
@@ -898,7 +915,7 @@ blockquote footer {
898
915
  blockquote footer .context {
899
916
  font-size: 0.9em;
900
917
  letter-spacing: -0.05em;
901
- color: #666665;
918
+ color: #333332;
902
919
  }
903
920
 
904
921
  pre {
@@ -909,14 +926,10 @@ pre {
909
926
  overflow-wrap: break-word; /* break in middle of long word if no other break opportunities are available */
910
927
  font-size: 0.85em;
911
928
  line-height: 1.4; /* matches what Kindle uses and can't go less */
912
- background-color: #F2F2F2;
929
+ background-color: #E0E0E0;
913
930
  padding: 0.6em 0.9em; /* this is supposed to be '0.5rem 0.75rem' but Sony Readers crash when see that (at least, PRS-350, PRS-505, PRS-T1) */
914
- /*
915
- border-top: 3px solid #DCDCDE;
916
- */
917
- /* QUESTION #B3B3B1? */
918
- border-top: 1px solid #DCDCDE;
919
- border-right: 1px solid #DCDCDE;
931
+ border-top: 1px solid #C8C8C8;
932
+ border-right: 1px solid #C8C8C8;
920
933
  }
921
934
 
922
935
  body:first-of-type pre {
@@ -1109,8 +1122,6 @@ table.table th,
1109
1122
  table.table td {
1110
1123
  line-height: 1.4;
1111
1124
  padding: 0.5em 0.5em 1em 0.1em;
1112
- vertical-align: top;
1113
- text-align: left;
1114
1125
  -webkit-column-break-inside: avoid;
1115
1126
  page-break-inside: avoid;
1116
1127
  }
@@ -1120,7 +1131,7 @@ table.table th {
1120
1131
  }
1121
1132
 
1122
1133
  table.table thead th {
1123
- border-bottom: 1px solid #80807F;
1134
+ border-bottom: 1px solid #707070;
1124
1135
  }
1125
1136
 
1126
1137
  table.table td > p,
@@ -1128,47 +1139,43 @@ table.table div.embed > * {
1128
1139
  margin-top: 0;
1129
1140
  }
1130
1141
 
1131
- table.table td > p {
1132
- text-align: left;
1133
- }
1134
-
1135
1142
  /* REVIEW */
1136
1143
  table.table td > p + p,
1137
1144
  table.table div.embed > * + * {
1138
1145
  margin-top: 1em;
1139
1146
  }
1140
1147
 
1141
- table.table-framed {
1148
+ table.table-framed-all {
1142
1149
  border-width: 1px;
1143
1150
  border-style: solid;
1144
- border-color: #80807F;
1151
+ border-color: #707070;
1145
1152
  }
1146
1153
 
1147
1154
  table.table-framed-topbot {
1148
1155
  border-width: 1px 0;
1149
1156
  border-style: solid;
1150
- border-color: #80807F;
1157
+ border-color: #707070;
1151
1158
  }
1152
1159
 
1153
1160
  table.table-framed-sides {
1154
1161
  border-width: 0 1px;
1155
1162
  border-style: solid;
1156
- border-color: #80807F;
1163
+ border-color: #707070;
1157
1164
  }
1158
1165
 
1159
- table.table-grid th,
1160
- table.table-grid td {
1161
- border-width: 0 1px 1px 0;
1166
+ table.table-grid-all th,
1167
+ table.table-grid-all td {
1168
+ border-width: 1px 1px 1px 1px;
1162
1169
  border-style: solid;
1163
- border-color: #80807F;
1170
+ border-color: #707070;
1164
1171
  }
1165
1172
 
1166
- table.table-grid thead tr > *:last-child {
1173
+ table.table-grid-all thead tr > *:last-child {
1167
1174
  border-right-width: 0;
1168
1175
  }
1169
1176
 
1170
- table.table-grid tbody tr:last-child > th,
1171
- table.table-grid tbody tr:last-child > td {
1177
+ table.table-grid-all tbody tr:last-child > th,
1178
+ table.table-grid-all tbody tr:last-child > td {
1172
1179
  border-bottom-width: 0;
1173
1180
  }
1174
1181
 
@@ -1176,14 +1183,14 @@ table.table-grid-rows tbody th,
1176
1183
  table.table-grid-rows tbody td {
1177
1184
  border-width: 1px 0 0 0;
1178
1185
  border-style: solid;
1179
- border-color: #80807F;
1186
+ border-color: #707070;
1180
1187
  }
1181
1188
 
1182
1189
  table.table-grid-cols th,
1183
1190
  table.table-grid-cols td {
1184
1191
  border-width: 0 1px 0 0;
1185
1192
  border-style: solid;
1186
- border-color: #80807F;
1193
+ border-color: #707070;
1187
1194
  }
1188
1195
 
1189
1196
  table.table-grid-cols thead th:last-child {
@@ -1214,7 +1221,7 @@ hr.pagebreak + * {
1214
1221
 
1215
1222
  img.headshot {
1216
1223
  float: left;
1217
- border: 1px solid #80807F;
1224
+ border: 1px solid #707070;
1218
1225
  padding: 1px;
1219
1226
  margin: 0.35em 1em 0.15em 0;
1220
1227
  height: 5em !important;
@@ -1252,6 +1259,11 @@ nav#toc ol {
1252
1259
  list-style-type: none;
1253
1260
  }
1254
1261
 
1262
+ /* Calibre doesn't hide <nav hidden="hidden"> for some reason */
1263
+ nav[hidden~="hidden"] {
1264
+ display: none;
1265
+ }
1266
+
1255
1267
  .icon {
1256
1268
  display: none;
1257
1269
  }
@@ -220,8 +220,27 @@ module Asciidoctor
220
220
  series_meta.refine 'collection-type', 'series'
221
221
  end
222
222
 
223
- add_cover_image node
224
- add_front_matter_page node
223
+ # For list of supported landmark types see
224
+ # https://idpf.github.io/epub-vocabs/structure/
225
+ landmarks = []
226
+
227
+ cover_page = add_cover_page node
228
+ landmarks << { type: 'cover', href: cover_page.href, title: 'Cover' } unless cover_page.nil?
229
+
230
+ front_matter_page = add_front_matter_page node
231
+ landmarks << { type: 'frontmatter', href: front_matter_page.href, title: 'Front Matter' } unless front_matter_page.nil?
232
+
233
+ nav_item = @book.add_item('nav.xhtml', id: 'nav').nav
234
+
235
+ toclevels = [(node.attr 'toclevels', 1).to_i, 0].max
236
+ outlinelevels = [(node.attr 'outlinelevels', toclevels).to_i, 0].max
237
+
238
+ if node.attr? 'toc'
239
+ toc_item = @book.add_ordered_item 'toc.xhtml', id: 'toc'
240
+ landmarks << { type: 'toc', href: toc_item.href, title: node.attr('toc-title') }
241
+ else
242
+ toc_item = nil
243
+ end
225
244
 
226
245
  if node.doctype == 'book'
227
246
  toc_items = node.sections
@@ -231,11 +250,18 @@ module Asciidoctor
231
250
  add_chapter node
232
251
  end
233
252
 
234
- nav_xhtml = @book.add_item 'nav.xhtml', content: postprocess_xhtml(nav_doc(node, toc_items)), id: 'nav'
235
- nav_xhtml.nav
253
+ landmarks << { type: 'bodymatter', href: %(#{get_chapter_name toc_items[0]}.xhtml), title: 'Start of Content' } unless toc_items.empty?
254
+
255
+ toc_items.each do |item|
256
+ landmarks << { type: item.style, href: %(#{get_chapter_name item}.xhtml), title: item.title } if %w(appendix bibliography glossary index preface).include? item.style
257
+ end
258
+
259
+ nav_item.add_content postprocess_xhtml(nav_doc(node, toc_items, landmarks, outlinelevels))
260
+ # User is not supposed to see landmarks, so pass empty array here
261
+ toc_item&.add_content postprocess_xhtml(nav_doc(node, toc_items, [], toclevels))
236
262
 
237
263
  # NOTE gepub doesn't support building a ncx TOC with depth > 1, so do it ourselves
238
- toc_ncx = ncx_doc node, toc_items
264
+ toc_ncx = ncx_doc node, toc_items, outlinelevels
239
265
  @book.add_item 'toc.ncx', content: toc_ncx.to_ios, id: 'ncx'
240
266
 
241
267
  docimagesdir = (node.attr 'imagesdir', '.').chomp '/'
@@ -301,25 +327,22 @@ module Asciidoctor
301
327
 
302
328
  chapter_item = @book.add_ordered_item %(#{docid}.xhtml)
303
329
 
304
- if node.context == :document && (doctitle = node.doctitle partition: true, use_fallback: true).subtitle?
330
+ doctitle = node.document.doctitle partition: true, use_fallback: true
331
+ doctitle_sanitized = sanitize_xml doctitle.combined, :cdata
332
+
333
+ if node.context == :document && doctitle.subtitle?
305
334
  title = %(#{doctitle.main} )
306
335
  subtitle = doctitle.subtitle
307
336
  elsif node.title
308
337
  # HACK: until we get proper handling of title-only in CSS
309
338
  title = ''
310
339
  subtitle = get_numbered_title node
340
+ doctitle_sanitized = sanitize_xml subtitle, :cdata
311
341
  else
312
342
  title = nil
313
343
  subtitle = nil
314
344
  end
315
345
 
316
- doctitle_sanitized = (node.document.doctitle sanitize: true, use_fallback: true).to_s
317
-
318
- # By default, Kindle does not allow the line height to be adjusted.
319
- # But if you float the elements, then the line height disappears and can be restored manually using margins.
320
- # See https://github.com/asciidoctor/asciidoctor-epub3/issues/123
321
- subtitle_formatted = subtitle ? subtitle.split.map {|w| %(<b>#{w}</b>) } * ' ' : nil
322
-
323
346
  if node.document.doctype == 'book'
324
347
  byline = ''
325
348
  else
@@ -351,16 +374,17 @@ module Asciidoctor
351
374
 
352
375
  header = (title || subtitle) ? %(<header>
353
376
  <div class="chapter-header">
354
- #{byline}<h1 class="chapter-title">#{title}#{subtitle ? %(<small class="subtitle">#{subtitle_formatted}</small>) : ''}</h1>
377
+ #{byline}<h1 class="chapter-title">#{title}#{subtitle ? %(<small class="subtitle">#{subtitle}</small>) : ''}</h1>
355
378
  </div>
356
379
  </header>) : ''
357
380
 
358
- # TODO : support writing code highlighter CSS to a separate file
359
- linkcss = false
381
+ # We want highlighter CSS to be stored in a separate file
382
+ # in order to avoid style duplication across chapter files
383
+ linkcss = true
360
384
 
361
385
  # NOTE kindlegen seems to mangle the <header> element, so we wrap its content in a div
362
386
  lines = [%(<!DOCTYPE html>
363
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="#{lang = node.document.attr 'lang', 'en'}" lang="#{lang}">
387
+ <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}">
364
388
  <head>
365
389
  <meta charset="UTF-8"/>
366
390
  <title>#{doctitle_sanitized}</title>
@@ -376,13 +400,12 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
376
400
  });
377
401
  ]]></script>)]
378
402
 
379
- if self.class.supports_highlighter_docinfo? && (syntax_hl = node.document.syntax_highlighter) && (syntax_hl.docinfo? :head)
380
- lines << (syntax_hl.docinfo :head, node, linkcss: linkcss, self_closing_tag_slash: '/')
381
- end
403
+ syntax_hl = node.document.syntax_highlighter
404
+ lines << (syntax_hl.docinfo :head, node, linkcss: linkcss, self_closing_tag_slash: '/') if syntax_hl&.docinfo? :head
382
405
 
383
406
  lines << %(</head>
384
407
  <body>
385
- <section class="chapter" title="#{doctitle_sanitized.gsub '"', '&quot;'}" epub:type="chapter" id="#{docid}">
408
+ <section class="chapter" title="#{doctitle_sanitized}" epub:type="chapter" id="#{docid}">
386
409
  #{header}
387
410
  #{content})
388
411
 
@@ -405,7 +428,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
405
428
 
406
429
  lines << '</section>'
407
430
 
408
- lines << (syntax_hl.docinfo :footer, node.document, linkcss: linkcss, self_closing_tag_slash: '/') if syntax_hl && (syntax_hl.docinfo? :footer)
431
+ lines << (syntax_hl.docinfo :footer, node.document, linkcss: linkcss, self_closing_tag_slash: '/') if syntax_hl&.docinfo? :footer
409
432
 
410
433
  lines << '</body>
411
434
  </html>'
@@ -547,7 +570,8 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
547
570
  nowrap = (node.option? 'nowrap') || !(node.document.attr? 'prewrap')
548
571
  if node.style == 'source'
549
572
  lang = node.attr 'language'
550
- if self.class.supports_highlighter_docinfo? && (syntax_hl = node.document.syntax_highlighter)
573
+ syntax_hl = node.document.syntax_highlighter
574
+ if syntax_hl
551
575
  opts = syntax_hl.highlight? ? {
552
576
  css_mode: ((doc_attrs = node.document.attributes)[%(#{syntax_hl.name}-css)] || :class).to_sym,
553
577
  style: doc_attrs[%(#{syntax_hl.name}-style)],
@@ -570,8 +594,28 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
570
594
  </figure>)
571
595
  end
572
596
 
573
- # TODO: implement proper stem support. See https://github.com/asciidoctor/asciidoctor-epub3/issues/10
574
- alias convert_stem convert_listing
597
+ def convert_stem node
598
+ return convert_listing node if node.style != 'asciimath' || !asciimath_available?
599
+
600
+ id_attr = node.id ? %( id="#{node.id}") : ''
601
+ title_element = node.title? ? %(<figcaption>#{node.captioned_title}</figcaption>) : ''
602
+ equation_data = AsciiMath.parse(node.content).to_mathml 'mml:'
603
+
604
+ %(<figure#{id_attr} class="#{prepend_space node.role}">
605
+ #{title_element}
606
+ <div class="content">
607
+ #{equation_data}
608
+ </div>
609
+ </figure>)
610
+ end
611
+
612
+ def asciimath_available?
613
+ (@asciimath_status ||= load_asciimath) == :loaded
614
+ end
615
+
616
+ def load_asciimath
617
+ Helpers.require_library('asciimath', true, :warn).nil? ? :unavailable : :loaded
618
+ end
575
619
 
576
620
  # QUESTION should we wrap the <pre> in either <div> or <figure>?
577
621
  def convert_literal node
@@ -657,41 +701,36 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
657
701
  lines = [%(<div class="table">)]
658
702
  lines << %(<div class="content">)
659
703
  table_id_attr = node.id ? %( id="#{node.id}") : ''
660
- frame_class = {
661
- 'all' => 'table-framed',
662
- 'topbot' => 'table-framed-topbot',
663
- 'sides' => 'table-framed-sides',
664
- 'none' => '',
665
- }
666
- grid_class = {
667
- 'all' => 'table-grid',
668
- 'rows' => 'table-grid-rows',
669
- 'cols' => 'table-grid-cols',
670
- 'none' => '',
671
- }
672
- table_classes = %W[table #{frame_class[node.attr 'frame'] || frame_class['topbot']} #{grid_class[node.attr 'grid'] || grid_class['rows']}]
704
+ table_classes = [
705
+ 'table',
706
+ %(table-framed-#{node.attr 'frame', 'rows', 'table-frame'}),
707
+ %(table-grid-#{node.attr 'grid', 'rows', 'table-grid'}),
708
+ ]
673
709
  if (role = node.role)
674
710
  table_classes << role
675
711
  end
676
- table_class_attr = %( class="#{table_classes * ' '}")
677
712
  table_styles = []
678
- table_styles << %(width: #{node.attr 'tablepcwidth'}%) unless (node.option? 'autowidth') && !(node.attr? 'width', nil, false)
713
+ if (autowidth = node.option? 'autowidth') && !(node.attr? 'width')
714
+ table_classes << 'fit-content'
715
+ elsif (tablewidth = node.attr 'tablepcwidth') == 100
716
+ table_classes << 'stretch'
717
+ else
718
+ table_styles << %(width: #{tablewidth}%;)
719
+ end
720
+ table_class_attr = %( class="#{table_classes * ' '}")
679
721
  table_style_attr = !table_styles.empty? ? %( style="#{table_styles * '; '}") : ''
680
722
 
681
723
  lines << %(<table#{table_id_attr}#{table_class_attr}#{table_style_attr}>)
682
724
  lines << %(<caption>#{node.captioned_title}</caption>) if node.title?
683
725
  if (node.attr 'rowcount') > 0
684
726
  lines << '<colgroup>'
685
- #if node.option? 'autowidth'
686
- tag = %(<col/>)
687
- node.columns.size.times do
688
- lines << tag
727
+ if autowidth
728
+ lines += (Array.new node.columns.size, %(<col/>))
729
+ else
730
+ node.columns.each do |col|
731
+ lines << ((col.option? 'autowidth') ? %(<col/>) : %(<col style="width: #{col.attr 'colpcwidth'}%;" />))
732
+ end
689
733
  end
690
- #else
691
- # node.columns.each do |col|
692
- # lines << %(<col style="width: #{col.attr 'colpcwidth'}%"/>)
693
- # end
694
- #end
695
734
  lines << '</colgroup>'
696
735
  [:head, :body, :foot].reject {|tsec| node.rows[tsec].empty? }.each do |tsec|
697
736
  lines << %(<t#{tsec}>)
@@ -711,19 +750,16 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
711
750
  else
712
751
  cell_content = ''
713
752
  cell.content.each do |text|
714
- cell_content = %(#{cell_content}<p>#{text}</p>)
753
+ cell_content = %(#{cell_content}<p class="tableblock">#{text}</p>)
715
754
  end
716
755
  end
717
756
  end
718
757
 
719
758
  cell_tag_name = tsec == :head || cell.style == :header ? 'th' : 'td'
720
- cell_classes = []
721
- if (halign = cell.attr 'halign') && halign != 'left'
722
- cell_classes << 'halign-left'
723
- end
724
- if (halign = cell.attr 'valign') && halign != 'top'
725
- cell_classes << 'valign-top'
726
- end
759
+ cell_classes = [
760
+ "halign-#{cell.attr 'halign'}",
761
+ "valign-#{cell.attr 'valign'}",
762
+ ]
727
763
  cell_class_attr = !cell_classes.empty? ? %( class="#{cell_classes * ' '}") : ''
728
764
  cell_colspan_attr = cell.colspan ? %( colspan="#{cell.colspan}") : ''
729
765
  cell_rowspan_attr = cell.rowspan ? %( rowspan="#{cell.rowspan}") : ''
@@ -931,7 +967,7 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
931
967
  end
932
968
 
933
969
  if Asciidoctor::Helpers.uriish? target
934
- # We need to add both local and remote media files to manifect
970
+ # We need to add both local and remote media files to manifest
935
971
  fs_path = nil
936
972
  else
937
973
  out_dir = node.attr('outdir', nil, true) || doc_option(node.document, :to_dir)
@@ -1176,25 +1212,30 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
1176
1212
  def convert_inline_quoted node
1177
1213
  open, close, tag = QUOTE_TAGS[node.type]
1178
1214
 
1179
- # TODO: implement proper stem support. See https://github.com/asciidoctor/asciidoctor-epub3/issues/10
1215
+ if node.type == :asciimath && asciimath_available?
1216
+ content = AsciiMath.parse(node.text).to_mathml 'mml:'
1217
+ else
1218
+ content = node.text
1219
+ end
1220
+
1180
1221
  node.add_role 'literal' if [:monospaced, :asciimath, :latexmath].include? node.type
1181
1222
 
1182
1223
  if node.id
1183
1224
  class_attr = class_string node
1184
1225
  if tag
1185
- %(#{open.chop} id="#{node.id}"#{class_attr}>#{node.text}#{close})
1226
+ %(#{open.chop} id="#{node.id}"#{class_attr}>#{content}#{close})
1186
1227
  else
1187
- %(<span id="#{node.id}"#{class_attr}>#{open}#{node.text}#{close}</span>)
1228
+ %(<span id="#{node.id}"#{class_attr}>#{open}#{content}#{close}</span>)
1188
1229
  end
1189
1230
  elsif role_valid_class? node.role
1190
1231
  class_attr = class_string node
1191
1232
  if tag
1192
- %(#{open.chop}#{class_attr}>#{node.text}#{close})
1233
+ %(#{open.chop}#{class_attr}>#{content}#{close})
1193
1234
  else
1194
- %(<span#{class_attr}>#{open}#{node.text}#{close}</span>)
1235
+ %(<span#{class_attr}>#{open}#{content}#{close}</span>)
1195
1236
  end
1196
1237
  else
1197
- %(#{open}#{node.text}#{close})
1238
+ %(#{open}#{content}#{close})
1198
1239
  end
1199
1240
  end
1200
1241
 
@@ -1258,6 +1299,19 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
1258
1299
  @book.add_item 'styles/epub3-css3-only.css', content: (postprocess_css_file ::File.join(workdir, 'epub3-css3-only.css'), format)
1259
1300
  end
1260
1301
 
1302
+ syntax_hl = doc.syntax_highlighter
1303
+ if syntax_hl&.write_stylesheet? doc
1304
+ Dir.mktmpdir do |dir|
1305
+ syntax_hl.write_stylesheet doc, dir
1306
+ Pathname.glob(dir + '/**/*').map do |filename|
1307
+ # Workaround for https://github.com/skoji/gepub/pull/117
1308
+ filename.open do |f|
1309
+ @book.add_item filename.basename.to_s, content: f
1310
+ end if filename.file?
1311
+ end
1312
+ end
1313
+ end
1314
+
1261
1315
  font_files, font_css = select_fonts ::File.join(DATA_DIR, 'styles/epub3-fonts.css'), (doc.attr 'scripts', 'latin')
1262
1316
  @book.add_item 'styles/epub3-fonts.css', content: font_css
1263
1317
  unless font_files.empty?
@@ -1277,8 +1331,8 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
1277
1331
  nil
1278
1332
  end
1279
1333
 
1280
- def add_cover_image doc
1281
- return if (image_path = doc.attr 'front-cover-image').nil?
1334
+ def add_cover_page doc
1335
+ return nil if (image_path = doc.attr 'front-cover-image').nil?
1282
1336
 
1283
1337
  imagesdir = (doc.attr 'imagesdir', '.').chomp '/'
1284
1338
  imagesdir = (imagesdir == '.' ? '' : %(#{imagesdir}/))
@@ -1295,20 +1349,21 @@ document.addEventListener('DOMContentLoaded', function(event, reader) {
1295
1349
  workdir = doc.attr 'docdir'
1296
1350
  workdir = '.' if workdir.nil_or_empty?
1297
1351
 
1298
- unless ::File.readable? ::File.join(workdir, image_path)
1299
- logger.error %(#{::File.basename doc.attr('docfile')}: front cover image not found or readable: #{::File.expand_path image_path, workdir})
1300
- return
1352
+ begin
1353
+ @book.add_item(image_href, content: File.join(workdir, image_path)).cover_image
1354
+ rescue => e
1355
+ logger.error %(#{::File.basename doc.attr('docfile')}: error adding front cover image. Make sure that :front-cover-image: attribute points to a valid image file. #{e})
1356
+ return nil
1301
1357
  end
1302
1358
 
1359
+ return nil if @format == :kf8
1360
+
1303
1361
  unless !image_attrs.empty? && (width = image_attrs['width']) && (height = image_attrs['height'])
1304
1362
  width, height = 1050, 1600
1305
1363
  end
1306
1364
 
1307
- @book.add_item(image_href, content: File.join(workdir, image_path)).cover_image
1308
-
1309
- unless @format == :kf8
1310
- # NOTE SVG wrapper maintains aspect ratio and confines image to view box
1311
- content = %(<!DOCTYPE html>
1365
+ # NOTE SVG wrapper maintains aspect ratio and confines image to view box
1366
+ content = %(<!DOCTYPE html>
1312
1367
  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
1313
1368
  <head>
1314
1369
  <meta charset="UTF-8"/>
@@ -1338,10 +1393,7 @@ body > svg {
1338
1393
  </svg></body>
1339
1394
  </html>).to_ios
1340
1395
 
1341
- # Gitden expects a cover.xhtml, so add it to the spine
1342
- @book.add_ordered_item 'cover.xhtml', content: content, id: 'cover'
1343
- end
1344
- nil
1396
+ @book.add_ordered_item 'cover.xhtml', content: content, id: 'cover'
1345
1397
  end
1346
1398
 
1347
1399
  def get_frontmatter_files doc, workdir
@@ -1371,19 +1423,22 @@ body > svg {
1371
1423
  workdir = doc.attr 'docdir'
1372
1424
  workdir = '.' if workdir.nil_or_empty?
1373
1425
 
1426
+ result = nil
1374
1427
  get_frontmatter_files(doc, workdir).each do |front_matter|
1375
1428
  front_matter_content = ::File.read front_matter
1376
1429
 
1377
1430
  front_matter_file = File.basename front_matter, '.html'
1378
1431
  item = @book.add_ordered_item "#{front_matter_file}.xhtml", content: (postprocess_xhtml front_matter_content)
1379
1432
  item.add_property 'svg' if SvgImgSniffRx =~ front_matter_content
1433
+ # Store link to first frontmatter page
1434
+ result = item if result.nil?
1380
1435
 
1381
1436
  front_matter_content.scan ImgSrcScanRx do
1382
1437
  @book.add_item $1, content: File.join(File.dirname(front_matter), $1)
1383
1438
  end
1384
1439
  end
1385
1440
 
1386
- nil
1441
+ result
1387
1442
  end
1388
1443
 
1389
1444
  def add_profile_images doc, usernames
@@ -1415,8 +1470,7 @@ body > svg {
1415
1470
  nil
1416
1471
  end
1417
1472
 
1418
- # TODO: aggregate authors of chapters into authors attribute(s) on main document
1419
- def nav_doc doc, items
1473
+ def nav_doc doc, items, landmarks, depth
1420
1474
  lines = [%(<!DOCTYPE html>
1421
1475
  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="#{lang = doc.attr 'lang', 'en'}" lang="#{lang}">
1422
1476
  <head>
@@ -1426,13 +1480,29 @@ body > svg {
1426
1480
  <link rel="stylesheet" type="text/css" href="styles/epub3-css3-only.css" media="(min-device-width: 0px)"/>
1427
1481
  </head>
1428
1482
  <body>
1429
- <h1>#{sanitize_doctitle_xml doc, :pcdata}</h1>
1430
- <nav epub:type="toc" id="toc">
1431
- <h2>#{doc.attr 'toc-title'}</h2>)]
1432
- lines << (nav_level items, [(doc.attr 'toclevels', 1).to_i, 0].max)
1433
- lines << %(</nav>
1483
+ <section class="chapter">
1484
+ <header>
1485
+ <div class="chapter-header"><h1 class="chapter-title"><small class="subtitle">#{doc.attr 'toc-title'}</small></h1></div>
1486
+ </header>
1487
+ <nav epub:type="toc" id="toc">)]
1488
+ lines << (nav_level items, [depth, 0].max)
1489
+ lines << '</nav>'
1490
+
1491
+ unless landmarks.empty?
1492
+ lines << '
1493
+ <nav epub:type="landmarks" id="landmarks" hidden="hidden">
1494
+ <ol>'
1495
+ landmarks.each do |landmark|
1496
+ lines << %(<li><a epub:type="#{landmark[:type]}" href="#{landmark[:href]}">#{landmark[:title]}</a></li>)
1497
+ end
1498
+ lines << '
1499
+ </ol>
1500
+ </nav>'
1501
+ end
1502
+ lines << '
1503
+ </section>
1434
1504
  </body>
1435
- </html>)
1505
+ </html>'
1436
1506
  lines * LF
1437
1507
  end
1438
1508
 
@@ -1466,7 +1536,7 @@ body > svg {
1466
1536
  lines * LF
1467
1537
  end
1468
1538
 
1469
- def ncx_doc doc, items
1539
+ def ncx_doc doc, items, depth
1470
1540
  # TODO: populate docAuthor element based on unique authors in work
1471
1541
  lines = [%(<?xml version="1.0" encoding="utf-8"?>
1472
1542
  <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="#{doc.attr 'lang', 'en'}">
@@ -1478,7 +1548,7 @@ body > svg {
1478
1548
  </head>
1479
1549
  <docTitle><text>#{sanitize_doctitle_xml doc, :cdata}</text></docTitle>
1480
1550
  <navMap>)]
1481
- lines << (ncx_level items, [(doc.attr 'toclevels', 1).to_i, 0].max, state = {})
1551
+ lines << (ncx_level items, depth, state = {})
1482
1552
  lines[0] = lines[0].sub '%{depth}', %(<meta name="dtb:depth" content="#{state[:max_depth]}"/>)
1483
1553
  lines << %(</navMap>
1484
1554
  </ncx>)
@@ -1674,14 +1744,6 @@ body > svg {
1674
1744
  def role_valid_class? role
1675
1745
  role.is_a? String
1676
1746
  end
1677
-
1678
- class << self
1679
- def supports_highlighter_docinfo?
1680
- # Asciidoctor only got pluggable syntax highlighters since 2.0:
1681
- # https://github.com/asciidoctor/asciidoctor/commit/23ddbaed6818025cbe74365fec7e8101f34eadca
1682
- Asciidoctor::Document.method_defined? :syntax_highlighter
1683
- end
1684
- end
1685
1747
  end
1686
1748
 
1687
1749
  class DocumentIdGenerator
@@ -1694,6 +1756,7 @@ body > svg {
1694
1756
  InvalidIdCharsRx = /[^[:word:]]+/
1695
1757
  LeadingDigitRx = /^[[:digit:]]/
1696
1758
  end
1759
+
1697
1760
  class << self
1698
1761
  def generate_id doc, pre = nil, sep = nil
1699
1762
  synthetic = false
@@ -1749,7 +1812,10 @@ body > svg {
1749
1812
  # TODO: bw theme for CodeRay
1750
1813
  document.set_attribute 'pygments-style', 'bw' unless document.attr? 'pygments-style'
1751
1814
  document.set_attribute 'rouge-style', 'bw' unless document.attr? 'rouge-style'
1752
- unless Converter.supports_highlighter_docinfo?
1815
+
1816
+ # Old asciidoctor versions do not have public API for writing highlighter CSS file
1817
+ # So just use inline CSS there.
1818
+ unless Document.supports_syntax_highlighter?
1753
1819
  document.set_attribute 'coderay-css', 'style'
1754
1820
  document.set_attribute 'pygments-css', 'style'
1755
1821
  document.set_attribute 'rouge-css', 'style'
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'asciidoctor/document'
3
4
  require_relative 'asciidoctor/logging_shim' unless defined? Asciidoctor::Logging
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Asciidoctor::Document
4
+ class << self
5
+ def supports_syntax_highlighter?
6
+ if @supports_syntax_highlighter.nil?
7
+ # Asciidoctor only got pluggable syntax highlighters since 2.0:
8
+ # https://github.com/asciidoctor/asciidoctor/commit/23ddbaed6818025cbe74365fec7e8101f34eadca
9
+ @supports_syntax_highlighter = method_defined? :syntax_highlighter
10
+ end
11
+
12
+ @supports_syntax_highlighter
13
+ end
14
+ end
15
+
16
+ def syntax_highlighter
17
+ nil
18
+ end unless supports_syntax_highlighter?
19
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module Epub3
5
- VERSION = '1.5.0.alpha.17'
5
+ VERSION = '1.5.0.alpha.18'
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: 1.5.0.alpha.17
4
+ version: 1.5.0.alpha.18
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-05-25 00:00:00.000000000 Z
12
+ date: 2020-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: asciidoctor-diagram
@@ -31,6 +31,20 @@ dependencies:
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 3.0.0
34
+ - !ruby/object:Gem::Dependency
35
+ name: asciimath
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ type: :development
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
34
48
  - !ruby/object:Gem::Dependency
35
49
  name: coderay
36
50
  requirement: !ruby/object:Gem::Requirement
@@ -248,6 +262,7 @@ files:
248
262
  - lib/asciidoctor-epub3/converter.rb
249
263
  - lib/asciidoctor-epub3/ext.rb
250
264
  - lib/asciidoctor-epub3/ext/asciidoctor.rb
265
+ - lib/asciidoctor-epub3/ext/asciidoctor/document.rb
251
266
  - lib/asciidoctor-epub3/ext/asciidoctor/logging_shim.rb
252
267
  - lib/asciidoctor-epub3/ext/core.rb
253
268
  - lib/asciidoctor-epub3/ext/core/string.rb