asciidoctor-epub3 1.5.0.alpha.5 → 1.5.0.alpha.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,4 +18,4 @@ include::sample-content.adoc[]
18
18
 
19
19
  include::asciidoctor-js-introduction.adoc[]
20
20
 
21
- include::asciidoctor-js-extension.adoc[]
21
+ include::asciidoctor-js-browser-extension.adoc[]
@@ -7,7 +7,7 @@ Sarah White <https://github.com/graphitefriction[@graphitefriction]>
7
7
  :language: asciidoc
8
8
 
9
9
  [abstract]
10
- This sample guide describes the some Asciidoctor attributes, values, and layout options available for producing a customized and polished document.
10
+ This sample guide describes several Asciidoctor attributes, values, and layout options available for producing a customized and polished document.
11
11
 
12
12
  == Block titles
13
13
 
@@ -16,7 +16,7 @@ In most cases, the title is displayed immediately above the content.
16
16
  If the content is a figure or image, the title is displayed below the content.
17
17
 
18
18
  A block title is defined on a line above the element.
19
- The line must begin with a dot (+.+) and be followed immediately by the title text with no spaces inbetween.
19
+ The line must begin with a dot (`.`) and be followed immediately by the title text with no spaces inbetween.
20
20
 
21
21
  Here's an example of a list with a title:
22
22
 
@@ -107,7 +107,7 @@ Warning:: Used to inform the reader of potential risks.
107
107
  Caution:: Also used to inform the reader of potential risks, take your pick.
108
108
 
109
109
  When you want to call attention to a single paragraph, start the first line of the paragraph with the label you want to use.
110
- The label must be uppercase and followed by a colon (+:+).
110
+ The label must be uppercase and followed by a colon (`:`).
111
111
 
112
112
  WARNING: Wolpertingers are known to nest in server racks.
113
113
  Enter at your own risk.
@@ -131,9 +131,9 @@ While werewolves are hardy community members, keep in mind the following dietary
131
131
 
132
132
  Quotes, prose excerpts and verses share the same syntax structure, including:
133
133
 
134
- * style attribute, either +quote+ or +verse+
134
+ * style attribute, either `quote` or `verse`
135
135
  * name of who the content is attributed to
136
- * biblographical information of the book, speech, play, etc., where the content was drawn from
136
+ * bibliographical information of the book, speech, play, etc., where the content was drawn from
137
137
  * excerpt text
138
138
 
139
139
  .Anatomy of a basic quote
@@ -28,14 +28,26 @@ only screen and (max-device-width: 1280px) and (max-device-height: 768px) {
28
28
 
29
29
  /*body.namo-epub-library > section.chapter {
30
30
  margin: 0 5pt;
31
- } */
31
+ }*/
32
+ }
33
+
34
+ body h1, body h2, body h3:not(.list-heading), body h4, body h5, body h6,
35
+ h1 :not(code), h2 :not(code), h3:not(.list-heading) :not(code), h4 :not(code), h5 :not(code), h6 :not(code) {
36
+ /* !important required to override custom font setting in Kindle / Gitden / Namo */
37
+ /* Gitden requires the extra weight of a parent selector; it also makes headings bold when custom font is specified */
38
+ /* Kindle and Gitden require the override on heading child elements */
39
+ font-family: "M+ 1p", sans-serif !important;
32
40
  }
33
41
 
34
- body.gitden-reader a:link {
35
- color: #333332 !important;
42
+ /* QUESTION what about nested elements inside code? */
43
+ body code, body kbd, body pre, pre :not(code) {
44
+ /* !important required to override custom font setting in Kindle / Gitden / Namo */
45
+ /* Gitden requires the extra weight of a parent selector */
46
+ /* Kindle and Gitden require the override on pre child elements */
47
+ font-family: "M+ 1mn", monospace !important;
36
48
  }
37
49
 
38
- @media amzn-kf8, amzn-mobi {
50
+ @media amzn-kf8 {
39
51
  /* Kindle does its own margin management, so don't use an explicit margin */
40
52
  /*body {
41
53
  margin: 0 !important;
@@ -43,11 +55,12 @@ body.gitden-reader a:link {
43
55
 
44
56
  /* text-rendering is the only way to enable kerning in Kindle (and Calibre, though it seems to kern automatically) */
45
57
  /* personally, I think Kindle overdoes kerning, but we're running with it for now */
46
- h1, h2, h3, h4, h5, h6,
58
+ /* text-rendering: optimizeLegibility kills certain Kindle eInk devices */
59
+ /*h1, h2, h3, h4, h5, h6,
47
60
  body p, li, dd, blockquote > footer,
48
61
  th, td, figcaption, caption {
49
62
  text-rendering: optimizeLegibility;
50
- }
63
+ }*/
51
64
 
52
65
  /* hack line height of subtitle using floats on Kindle */
53
66
  h1.chapter-title .subtitle {
@@ -81,7 +94,8 @@ body.gitden-reader a:link {
81
94
  /* Font-based icons */
82
95
  .icon {
83
96
  display: inline-block;
84
- font-family: "FontAwesome";
97
+ /* !important required to override custom font setting in Kindle (since .icon can appear inside a span) */
98
+ font-family: "FontAwesome" !important;
85
99
  font-style: normal !important;
86
100
  font-weight: normal !important;
87
101
  line-height: 1;
@@ -1,4 +1,3 @@
1
- @charset "UTF-8";
2
1
  @import url("epub3-fonts.css");
3
2
 
4
3
  *, *:before, *:after {
@@ -29,7 +28,7 @@ body {
29
28
  /* don't use !important on margin as it breaks calibre */
30
29
  margin: 0;
31
30
  font-size: 100%;
32
- /* NOTE putting optimizeLegibility on the body slow down rendering considerably */
31
+ /* NOTE putting optimizeLegibility on the body slows down rendering considerably */
33
32
  text-rendering: optimizeSpeed;
34
33
  /* -webkit-font-smoothing has no noticable effect and is controversial, so leaving it off */
35
34
  }
@@ -84,6 +83,7 @@ b.button {
84
83
  font-weight: normal;
85
84
  text-shadow: 1px 0 0 #B3B3B1;
86
85
  color: #191918;
86
+ white-space: nowrap;
87
87
  }
88
88
 
89
89
  b.button .label {
@@ -199,7 +199,7 @@ td, th {
199
199
 
200
200
  body a:link {
201
201
  color: #333332;
202
- /* hack for font color in iBooks */
202
+ /* hack for font color in iBooks and Gitden (though Gitden would accept color !important too) */
203
203
  -webkit-text-fill-color: #333332;
204
204
  /* Kindle requires the !important on text-decoration */
205
205
  /* In night mode, the only indicator of a link is the underline, so we need it or a background image */
@@ -239,19 +239,13 @@ code.literal {
239
239
  h1, h2, h3, h4, h5, h6 {
240
240
  font-family: "M+ 1p", sans-serif;
241
241
  font-weight: 400;
242
- text-align: left;
243
- color: #333332;
244
242
  letter-spacing: -0.01em;
245
- /* disable hyphenation, such as in iBooks */
246
- -webkit-hyphens: none;
247
- /* force super-long words to break */
248
- word-break: break-word;
249
-
250
- /* NOTE: Kindle doesn't allow the line-height to be less than the font size (refer to heading font sizes) */
243
+ /* NOTE Kindle doesn't allow the line-height to be less than the font size (refer to heading font sizes) */
251
244
  line-height: 1.4; /* or 1.2125 */
245
+ text-align: left;
252
246
 
253
- margin: 0;
254
- padding: 0;
247
+ -webkit-hyphens: none; /* disable hyphenation where supported (e.g., iBooks) */
248
+ word-wrap: break-word; /* break in middle of long word if no other break opportunities are available */
255
249
 
256
250
  /* avoiding page breaks does not seem to work in Kindle */
257
251
  -webkit-column-break-inside: avoid;
@@ -264,36 +258,31 @@ h1, h2, h3, h4, h5, h6 {
264
258
  /* We'll just use the stronger rule for all paragraph-related stuff to be sure */
265
259
  body p {
266
260
  margin: 1em 0 0 0;
267
- text-indent: 0;
268
-
269
- font-family: "Noto Serif", serif;
270
- color: #333332;
271
- line-height: 1.6;
272
261
  text-align: justify;
273
- /* Signal to iBooks that hypens are okay here */
274
- -webkit-hyphens: auto;
262
+ text-indent: 0;
275
263
 
276
264
  widows: 2;
277
265
  orphans: 2;
278
266
  }
279
267
 
268
+ body p,
280
269
  ul, ol, li, dl, dt, dd, footer,
281
- div.verse .attribution, table.table th, table.table td {
282
- font-family: "Noto Serif", serif;
270
+ div.verse .attribution, table.table th, table.table td,
271
+ figcaption, caption {
283
272
  color: #333332;
273
+ /* NOTE iBooks will forcefully override font-family of text inside div, p and span elements when font other than Original is selected */
274
+ /* NOTE iBooks honors Original font for prose text if declared in display-options.xml */
275
+ font-family: "Noto Serif", serif;
284
276
  }
285
277
 
286
- li, dt, dd, footer {
278
+ body p, li, dt, dd, footer {
287
279
  line-height: 1.6;
288
280
  }
289
281
 
290
- figcaption, caption {
291
- font-family: "Noto Serif", serif;
292
- }
293
-
294
282
  code, kbd, pre {
295
- font-family: "M+ 1mn", monospace;
296
283
  color: #191918;
284
+ font-family: "M+ 1mn", monospace;
285
+ -webkit-hyphens: none; /* disable hyphenation where supported (e.g., iBooks) */
297
286
  }
298
287
 
299
288
  /* QUESTION should we kern preformatted text blocks? */
@@ -301,12 +290,11 @@ h1, h2, h3, h4, h5, h6,
301
290
  body p, li, dd, blockquote > footer,
302
291
  th, td, figcaption, caption {
303
292
  /* forward-compatible CSS to enable kerning (if we want ligatures, add "liga" and "dlig") */
304
- /* WebKits that doesn't recognize these properties don't kern well, hence why we don't just enable kerning via text-rendering */
305
- /*text-rendering: optimizeLegibility;*/
293
+ /* WebKits that don't recognize these properties don't kern well, hence why we don't simply enable kerning via text-rendering */
306
294
  -webkit-font-feature-settings: "kern";
307
295
  font-feature-settings: "kern";
308
296
  font-kerning: normal;
309
- /* NOTE: see Kindle hack in epub3-css3-only.css for additional kerning settings */
297
+ /* NOTE see Kindle hack in epub3-css3-only.css for additional kerning settings (disabled) */
310
298
  }
311
299
 
312
300
  p.last::after {
@@ -314,7 +302,7 @@ p.last::after {
314
302
  display: inline-block;
315
303
  font-family: "FontAwesome";
316
304
  font-size: 1em;
317
- content: "\f121"; /* </> */
305
+ content: "\f121"; /* i.e., </> */
318
306
  margin-left: 0.25em;
319
307
  }
320
308
 
@@ -383,16 +371,15 @@ div.callout-list ol li {
383
371
  }
384
372
 
385
373
  i.conum {
386
- font-family: "M+ 1mn", monospace;
387
- /*text-rendering: geometricPrecision;*/
388
374
  color: #468C54;
375
+ font-family: "M+ 1mn", monospace;
389
376
  font-style: normal;
390
377
  }
391
378
 
392
- pre i.conum {
393
- /* don't let it affect line spacing; REVIEW may not need this! */
394
- /*line-height: 1;*/
395
- }
379
+ /* don't let conum affect line spacing; REVIEW may not need this! */
380
+ /*pre i.conum {
381
+ line-height: 1;
382
+ }*/
396
383
 
397
384
  div.callout-list li > i.conum {
398
385
  float: left;
@@ -416,23 +403,19 @@ div.ordered-list div.description-list {
416
403
  margin-top: 0;
417
404
  }
418
405
 
419
- /*
420
- div.description-list div.itemized-list,
406
+ /*div.description-list div.itemized-list,
421
407
  div.description-list div.ordered-list,
422
408
  div.description-list div.description-list {
423
- }
424
- */
409
+ }*/
425
410
 
426
- div.itemized-list > h3,
427
- div.ordered-list > h3,
428
- div.description-list > h3 {
411
+ h3.list-heading {
429
412
  font-size: 1em;
430
413
  font-family: "Noto Serif", serif;
431
414
  font-weight: bold;
432
415
  line-height: 1.6;
433
- color: #333332;
416
+ margin-top: 1em;
417
+ margin-bottom: -0.25em;
434
418
  letter-spacing: 0;
435
- word-spacing: 0;
436
419
  }
437
420
 
438
421
  div.stack li strong.subject,
@@ -462,9 +445,6 @@ body:first-of-type ul ul ul {
462
445
  }
463
446
 
464
447
  ul > li::before {
465
- /*
466
- text-rendering: geometricPrecision;
467
- */
468
448
  float: left;
469
449
  margin-left: -1em;
470
450
  margin-top: -0.05em;
@@ -546,35 +526,24 @@ ul.references > li > span.principal {
546
526
  text-align: left;
547
527
  }
548
528
 
549
- h1, h1 code,
550
- h2, h2 code {
551
- color: #333332;
552
- }
553
-
554
529
  /* sized based on the major third modular scale (4:5, 16px, 24px) */
555
530
  h1, h2 {
531
+ color: #333332;
556
532
  font-size: 1.5em;
557
533
  word-spacing: -0.075em;
558
534
  margin-top: 1em; /* 1.5rem */
559
535
  margin-bottom: -0.3333em; /* -0.5rem, 0.5rem to content */
560
536
  }
561
537
 
562
- h3, h3 code {
563
- color: #333332;
564
- }
565
-
566
538
  h3 {
539
+ color: #333332;
567
540
  font-size: 1.25em;
568
- word-spacing: 0;
569
541
  margin-top: 0.84em; /* 1.05rem */
570
542
  margin-bottom: -0.5em; /* -0.625rem, 0.375rem to content */
571
543
  }
572
544
 
573
- h4, h4 code {
574
- color: #4F4F4C;
575
- }
576
-
577
545
  h4 {
546
+ color: #4F4F4C;
578
547
  font-weight: 200;
579
548
 
580
549
  font-size: 1.1em;
@@ -588,11 +557,8 @@ h4 {
588
557
  margin-bottom: -0.625em; /* -0.75rem, 0.25rem to content */
589
558
  }
590
559
 
591
- h5, h5 code {
592
- color: #666665;
593
- }
594
-
595
560
  h5 {
561
+ color: #666665;
596
562
  /*
597
563
  font-size: 1em;
598
564
  text-transform: uppercase;
@@ -607,6 +573,10 @@ h5 {
607
573
  margin-bottom: -0.972em; /* -0.875rem */
608
574
  }
609
575
 
576
+ h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
577
+ color: inherit;
578
+ }
579
+
610
580
  h5 code {
611
581
  text-transform: none;
612
582
  }
@@ -942,10 +912,12 @@ figure.image img {
942
912
  }
943
913
 
944
914
  pre {
915
+ text-align: left; /* fix for Namo */
945
916
  margin-top: 1em; /* 0.85rem */
946
917
  /*margin-top: 1.176em;*/ /* 1rem */
947
918
  white-space: pre-wrap;
948
- word-wrap: break-word;
919
+ /*word-break: break-all;*/ /* break at the end of the line, no matter what */
920
+ word-wrap: break-word; /* break in middle of long word if no other break opportunities are available */
949
921
  font-size: 0.85em;
950
922
  line-height: 1.4; /* matches what Kindle uses and can't go less */
951
923
  background-color: #F2F2F2;
@@ -983,6 +955,7 @@ div.verse {
983
955
  page-break-inside: avoid;
984
956
  }
985
957
 
958
+ /* TODO we may want to reenable hyphens here, but not for kf8 */
986
959
  div.verse > pre {
987
960
  background-color: transparent;
988
961
  border: none;
@@ -1291,3 +1264,17 @@ nav#toc ol {
1291
1264
  .icon {
1292
1265
  display: none;
1293
1266
  }
1267
+
1268
+ @media amzn-mobi {
1269
+ /* NOTE mobi7 doesn't support custom fonts, so revert to generic ones */
1270
+ body p, ul, ol, li, dl, dt, dd, figcaption, caption, footer,
1271
+ table.table th, table.table td, div.verse .attribution {
1272
+ font-family: serif;
1273
+ }
1274
+ h1, h2, h3, h4, h5, h6 {
1275
+ font-family: sans-serif;
1276
+ }
1277
+ code, kbd, pre, i.conum {
1278
+ font-family: monospace;
1279
+ }
1280
+ }
@@ -149,14 +149,21 @@ class ContentConverter
149
149
  content = node.content
150
150
 
151
151
  # NOTE must run after content is resolved
152
- # NOTE pubtree requires icon CSS to be repeated inside <body> (or in a linked stylesheet); perhaps create dynamic CSS file?
153
- icon_css = unless @icon_names.empty?
152
+ # TODO perhaps create dynamic CSS file?
153
+ if @icon_names.empty?
154
+ icon_css_head = icon_css_scoped = nil
155
+ else
154
156
  icon_defs = @icon_names.map {|name|
155
157
  %(.i-#{name}::before { content: "#{FontIconMap[name.tr('-', '_').to_sym]}"; })
156
158
  } * EOL
157
- %(<style>
159
+ icon_css_head = %(<style>
158
160
  #{icon_defs}
159
161
  </style>
162
+ )
163
+ # NOTE Namo Pubtree requires icon CSS to be repeated inside <body> (or in a linked stylesheet); wrap in div to hide from Aldiko
164
+ icon_css_scoped = (node.attr? 'ebook-format', 'kf8') ? nil : %(<div style="display: none" aria-hidden="true"><style scoped="scoped">
165
+ #{icon_defs}
166
+ </style></div>
160
167
  )
161
168
  end
162
169
 
@@ -168,7 +175,7 @@ class ContentConverter
168
175
  <title>#{doctitle_sanitized}</title>
169
176
  <link rel="stylesheet" type="text/css" href="styles/epub3.css"/>
170
177
  <link rel="stylesheet" type="text/css" href="styles/epub3-css3-only.css" media="(min-device-width: 0px)"/>
171
- #{icon_css}<script type="text/javascript">
178
+ #{icon_css_head}<script type="text/javascript">
172
179
  document.addEventListener('DOMContentLoaded', function(event) {
173
180
  var epubReader = navigator.epubReadingSystem;
174
181
  if (!epubReader) {
@@ -182,7 +189,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
182
189
  </head>
183
190
  <body>
184
191
  <section class="chapter" title="#{doctitle_sanitized.gsub '"', '&quot;'}" epub:type="chapter" id="#{docid}">
185
- #{icon_css && (icon_css.sub '<style>', '<style scoped="scoped">')}<header>
192
+ #{icon_css_scoped}<header>
186
193
  <div class="chapter-header">
187
194
  <p class="byline"><img src="#{imagesdir}avatars/#{username}.jpg"/> <b class="author">#{author}</b></p>
188
195
  <h1 class="chapter-title">#{title_upper}#{subtitle ? %[ <small class="subtitle">#{subtitle_formatted_upper}</small>] : nil}</h1>
@@ -333,7 +340,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
333
340
  # patches conums to fix extra or missing leading space
334
341
  # TODO apply this patch upstream to Asciidoctor
335
342
  %(<figure class="#{figure_classes * ' '}">
336
- #{title_div}<pre class="#{pre_classes * ' '}"><code>#{node.content.gsub(/(?<! )<i class="conum"| +<i class="conum"/, ' <i class="conum"')}</code></pre>
343
+ #{title_div}<pre class="#{pre_classes * ' '}"><code>#{(node.content || '').gsub(/(?<! )<i class="conum"| +<i class="conum"/, ' <i class="conum"')}</code></pre>
337
344
  </figure>)
338
345
  end
339
346
 
@@ -562,7 +569,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
562
569
  lines << %(<span class="principal">#{dd.text}</span>) if dd.text?
563
570
  lines << dd.content
564
571
  else
565
- lines << dd.text
572
+ lines << %(<span class="principal">#{dd.text}</span>)
566
573
  end
567
574
  lines << '</dd>'
568
575
  end
@@ -581,7 +588,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
581
588
  ol_class_attr = ol_classes.empty? ? nil : %( class="#{ol_classes * ' '}")
582
589
  id_attribute = node.id ? %( id="#{node.id}") : nil
583
590
  lines = [%(<div#{id_attribute} class="#{div_classes * ' '}">)]
584
- lines << %(<h3>#{node.title}</h3>) if node.title?
591
+ lines << %(<h3 class="list-heading">#{node.title}</h3>) if node.title?
585
592
  lines << %(<ol#{ol_class_attr}#{(node.option? 'reversed') ? ' reversed="reversed"' : nil}>)
586
593
  node.items.each do |item|
587
594
  lines << %(<li>
@@ -609,7 +616,7 @@ document.addEventListener('DOMContentLoaded', function(event) {
609
616
  ul_class_attr = ul_classes.empty? ? nil : %( class="#{ul_classes * ' '}")
610
617
  id_attribute = node.id ? %( id="#{node.id}") : nil
611
618
  lines = [%(<div#{id_attribute} class="#{div_classes * ' '}">)]
612
- lines << %(<h3>#{node.title}</h3>) if node.title?
619
+ lines << %(<h3 class="list-heading">#{node.title}</h3>) if node.title?
613
620
  lines << %(<ul#{ul_class_attr}>)
614
621
  node.items.each do |item|
615
622
  lines << %(<li>