Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Tài liệu EPUB 3 Best Practices ppt
Nội dung xem thử
Mô tả chi tiết
www.it-ebooks.info
www.it-ebooks.info
Matt Garrish and Markus Gylling
EPUB 3 Best Practices
www.it-ebooks.info
ISBN: 978-1-449-32914-3
[LSI]
EPUB 3 Best Practices
by Matt Garrish and Markus Gylling
Copyright © 2013 Matt Garrish and Markus Gylling. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are
also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/
institutional sales department: 800-998-9938 or [email protected].
Editor: Brian Sawyer
Production Editor: Kristen Borg
Proofreader: Kiel Van Horn
Indexer: Jill Edwards
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrator: Robert Romano
February 2013: First Edition
Revision History for the First Edition:
2013-01-23 First release
See http://oreilly.com/catalog/errata.csp?isbn=9781449329143 for release details.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly
Media, Inc. EPUB 3 Best Practices, the image of a common goat, and related trade dress are trademarks of
O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade‐
mark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information contained
herein.
www.it-ebooks.info
Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
1. Package Document and Metadata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Vocabularies 2
The Default Vocabulary 3
The Reserved Vocabularies 3
Using Other Vocabularies 4
The All-Powerful meta Element 5
Publication Metadata 7
The Package Document Structure 8
The metadata Element 9
Identifiers 11
Types of Titles 14
The Manifest and Spine 15
The manifest and Fallbacks 16
The spine 17
Document Metadata 19
Links and Bindings 20
Metadata for Fixed Layout Publications 22
The Container 22
2. Navigation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
The EPUB Navigation Document 26
Building a Navigation Document 29
Repeated Patterns 31
Table of Contents 35
Landmarks 41
Page List 44
Extensibility 45
iii
www.it-ebooks.info
Adding the Navigation Document 46
Embedding as Content 47
Hiding Lists 48
Styling Lists 49
The NCX 50
3. Content Documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Terminology Refresher 53
XHTML 55
New in HTML5 56
EPUB Support Gotchas 62
DTDs Are Dead 63
Linking and Referencing 64
Content Chunking 67
epub:type and Structural Semantics 68
Adding Semantics 70
Multiple Semantics 72
MathML 72
SVG 78
Fixed Layouts 80
Covers 85
Styling 87
EPUB CSS Profile 88
CSS 2.1 88
CSS3 91
Ruby 96
Headers and Footers 97
Alt Style Tags 99
CSS Resets 102
Fallback Content 102
Manifest Fallbacks 103
Content Fallbacks 105
The epub:switch element 107
Bindings 112
4. Font Embedding and Licensing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Why Embed Fonts? 118
Maybe You Shouldn’t 118
Maybe You Should 122
Font Embedding in EPUB 3 130
How to Embed Fonts 131
Add the Font to Your EPUB Package 132
iv | Table of Contents
www.it-ebooks.info
Include the File in the EPUB Manifest 132
Reference the Font in the EPUB CSS 133
Obfuscating Fonts 134
Subsetting a Font 137
Licensing Fonts for Embedding in EPUB 138
Use an Open Font 139
Contact the Foundry Directly 139
5. Multimedia. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
The Codec Issue 142
The Media Elements 144
Sources 145
Control 153
Posters 155
Dimensions 156
The Rest 157
Timed Tracks 157
Fallbacks 162
Alternate Content 163
Triggers 165
6. Media Overlays. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
The EPUB Spectrum 174
Overlays in a Nutshell 176
Synchronization Granularity 177
Constructing an Overlay 178
Sequences 180
Parallel Playback 181
Adding to the Container 184
Styling the Active Element 185
Structural Considerations 186
Advanced Synchronization 187
Audio Considerations 188
7. Interactivity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
First Principles: Interaction Scope and Design 192
Progressive Enhancement 192
Procedural Interaction: JavaScript 193
JavaScript in EPUB 2 193
The EPUB 3 epubReadingSystem Object 193
Inclusion Models 197
Ebook State and Storage 199
Table of Contents | v
www.it-ebooks.info
Identifying Scripted Content Documents 199
Animation and Graphics: Canvas 200
Best Practices in Canvas Usage 201
Canvas in a Nonscripted Reading System 202
Object 203
Other Graphical Interaction Models 204
Accessibility and Scripting Summary 204
8. Global Language Support. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Characters and Encodings 206
Unicode 206
Declaring Encodings 207
Private Characters 208
Names 209
Specifying the Natural Language 211
Vertical Writing 212
Writing Modes 213
Page Progression Direction 215
Global Direction 220
Content Direction 221
Ruby and Emphasis Dots 222
Ruby 222
Emphasis Dots 224
Line Breaks, Word Breaks, and Hyphenation 226
Itemized Lists 227
9. Accessibility. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Accessibility and Usability 230
Fundamentals of Accessibility 232
Structure and Semantics 233
Data Integrity 235
Separation of Style 237
Semantic Inflection 238
Language 239
Logical Reading Order 239
Sections and Headings 241
Context Changes 244
Lists 245
Tables 246
Figures 249
Images 250
SVG 253
vi | Table of Contents
www.it-ebooks.info
MathML 254
Footnotes 255
Page Numbering 256
Styling 258
Avoiding Conflicts 258
Color 258
Hiding Content 260
Emphasis 260
Fixed Layouts 261
Image Layouts 262
Mixed Layouts 265
Text Layouts 266
Interactive Layouts 266
Scripted Interactivity 267
Progressive Enhancement 267
WAI-ARIA 269
Canvas 280
Metadata 281
10. Text-to-Speech (TTS). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
PLS Lexicons 287
SSML 292
CSS3 Speech 297
11. Validation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
epubcheck 304
Installing 304
Running 305
Options 308
Reading Errors 313
Beyond the Command Line 314
Web Validation 314
Graphical Interface 316
Commercial Options 316
Understanding Errors 317
Common XML Errors 318
Container Errors 321
Package Validation 323
Content Validation 326
Style 329
Scripting 329
Table of Contents | vii
www.it-ebooks.info
Accessibility 330
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
viii | Table of Contents
www.it-ebooks.info
Preface
When I first wrote What Is EPUB 3? in the summer of 2011, it was envisioned as both
a brief standalone piece that would orient people to the new EPUB 3.0 revision the
International Digital Publishing Forum (IDPF) was about to release and also as an in‐
troduction to what we hoped would evolve into a larger best practices guide—the one
you’re reading now.
You’ll find that book distilled down to its bare essentials in this book’s introduction, but
if you are new to EPUB, there is much information put into that original guide that is
helpful to know before tackling this one, so if I can recommend some advance reading,
it would be to grab a copy of that ebook and give it a skim. If you’re not familiar with
EPUBs generally, or what’s changed from 2 to 3, it’ll help give you a general view of the
big picture before launching into the details that we’ll be covering here. It’s only a smallchapter-length in size, too (and free!), so it won’t take you long to get through, and it
will give you a condensed perspective on what an EPUB is.
This guide instead delves right into the EPUB container and walks you through best
practices as they relate to production of your publications; you’ll find a bit of a mixture
of practices and guidance on how to use EPUB technologies. You don’t necessarily have
to know the technology of publishing EPUBs inside and out to find value here, nor do
you have to be a programmer or tech geek, but this book is for the ebook practitioner.
In planning out this guide, one of the challenges was trying to keep straight where the
boundaries are between EPUB 3 and the technologies it combines under its format
umbrella. Can a single book about EPUB 3 best practices try to detail every nuance of
HTML5, CSS3, JavaScript, MathML and SVG, just to pick out some of the prime content
document technologies? The answer should be obvious, considering the volume of ma‐
terial that’s already been written on those subjects.
ix
www.it-ebooks.info
What we’ve tried to do in this guide is find the key areas of overlap between those
technologies as they relate to publishing. You’re going to find a lot of discussion about
all of the features just listed, and more, but if you’re just getting started with the tech‐
nologies used in EPUBs this book will be more of a starting point on your journey. You
will learn about potential issues when scripting in the reading system environment, for
example, but you won’t find a tutorial on the JavaScript language.
Each of the chapters in this book deals with a unique aspect of the creation and distri‐
bution process. There is no assumption that you’re familiar with the entire format, be‐
cause the production of EPUBs often involves expertise from a number of different
functional areas. The people responsible for ensuring the technology of your ebooks
probably aren’t going to be the same people who are responsible for the metadata. The
authors and editors creating the content are likewise not going to be the people bundling
and distributing the ebook. So although the book will move over EPUB 3 in a linear
fashion, and can be read from cover to cover to learn about production as a whole, each
chapter is also intended to be readable in isolation, with pointers forward and back as
necessary.
And although we hope you’ll implement all the best practices you can, the book is not
designed to be a checklist to content conformity, and is not written as such. Everyone
produces using different methods, and everyone has to work within the constraints of
their production workflows, so we’ve tried hard not to target specific processes or read‐
ing systems but stick to the ultimate outcome. If you can’t implement every accessibility
practice, for example, the hope is that at least you’ll understand where, and how, you
can improve later on down the road.
This guide also isn’t intended to be the final word on EPUB, as EPUB is always evolving.
It’s about preparing you for producing EPUB 3 content using all the features it makes
available, helping you avoid known pitfalls, and giving you a heads up on the issues
you’ll face. If successful, it will also hopefully enlighten you to why the specification is
defined the way that it is. A specification is just an artifact of agreement on how to
implement a technology, after all. It tells you what the creators decided you must and
should and may do—and not do—but specifications don’t spend time retelling you the
story of why.
It doesn’t mean you’ll agree with all the decisions that were made, but specifications by
nature portray a myth of homogeneity. It’s the discussions and debate that continue
around EPUB that keep it at the forefront of ebook technologies.
If we’ve done our job writing this book, you should not have new ideas for your own
production, but be well equipped to join in the discussions on the future.
x | Preface
www.it-ebooks.info
The Future
By the time this book comes out, the EPUB 3 specification will be more than a year old.
It’s hard to believe how fast time flies, but it’s not surprising that technology is only just
catching up to the standard. That was a goal of the revision after all: to position the
specification so that features and best practices could be defined ahead of the pack
instead of trying to constantly play the catch-up game.
The modular nature of the specification has also proven its worth. Since the specification
was published in October 2011, IDPF subgroups have published two new documents:
fixed layouts and advanced adaptive layouts. Work on grammars for marking up indexes
and dictionaries has been ongoing since the beginning of 2012, and a new group dealing
with hybrid layouts is also in the process of being chartered. The IDPF is continuing to
work with its members to evolve the standard to meet their needs; it’s not sitting on its
laurels or creating a format by fiat.
Another major revision of the standard is not on the horizon at this point, but minor
revisions are anticipated to add new CSS functionality, fix bugs, and see if consensus
can be found on open issues like codecs and metadata. A new minor revision is expected
to begin as this book gets readied for print, which will effect the information in this
guide, but it’s anticipated only for the positive.
You may have RDFa and microdata for content documents by the time you read this,
for example, or at least a firm promise of them. Fixed layout support could be stronger
if the information document it’s currently defined in gets rolled into the main specifi‐
cation. The HTML5 landscape should be clearer, too, as the W3C pushes to finalize the
standard by 2014. EPUB 3 itself also is hoped to become an ISO Technical Specification
during the process.
But don’t worry that this means you’re going to be fed lots of point-in-time ideas. The
areas of instability are not that numerous, and the practices that exist solely to deal with
them are clearly marked. The point of this book is to look at the core of the standard,
so the information should stand for as long as EPUB 3s are being produced.
And even as we began wrapping up this book, a new project to create a conformance
test suite for reading systems was announced, which will help standardize rendering
across reading systems, more and more of which are appearing that support EPUB 3
content. In natural step, publishers are also announcing their plans to start releasing
content (the Hachette Book Group, for example).
EPUB 3 is here, now, in other words.
But we’re not here for long-winded introductions. Let’s get on with the show!
Preface | xi
www.it-ebooks.info
How to Use This Book
Although you can read this book cover to cover, each chapter contains information
about a unique aspect of the EPUB 3 format allowing them to also be read in isolation.
To simplify jumping through the content, here’s a quick summary of the information in
each:
Introduction
The introduction provides a brief, high-level overview of the EPUB format and
specifications. If you’re coming to this book with no background in EPUB produc‐
tion, this chapter will get you grounded before you head into the details.
Chapter 1: Package Document and Metadata
The first chapter introduces the package document at the heart of every EPUB and
walks you through the process of adding publication metadata. The structure of the
package document is reviewed, as is the required publication metadata. The new,
flexible model for adding metadata to publications via meta elements is also
introduced.
Chapter 2: Navigation
This chapter details the new EPUB navigation document, including how to con‐
struct the required table of contents and optional landmarks and page list navigation
aids. It also shows how the document can now double as content in your publication,
removing the need to have two documents for the same basic function.
Chapter 3: Content Documents
This chapter is more wide-ranging in scope, as it provides a general overview of
content documents. It reviews the new features and requirements of XHTML5, from
the new additions to the core HTML grammar to the inclusion of MathML and
SVG. It also reviews the new epub:type attribute for semantic inflection. EPUB
style sheets, alt style tags and other styling issues are also covered. The chapter
concludes by looking at the various fallback mechanisms at your disposal when
using nonstandard content types.
Chapter 4: Font Embedding and Licensing
The ability to embed fonts allows rich typography in EPUBs. This chapter looks at
the technical details involved in embedding WOFF and OTF fonts, and it also re‐
views the licensing issues to be aware of when you do.
Chapter 5: Multimedia
This chapter looks at the new audio and video elements in HTML5 for embedding
multimedia content in your publications. It covers how to include resources, poster
images, and timed tracks, as well as the issues surrounding the lack of a universal
codec for video. The chapter concludes by looking at epub:trigger elements for
building scriptless user interfaces.
xii | Preface
www.it-ebooks.info
Chapter 6: Media Overlays
Media overlays is the new technology that enables synchronized text and audio
playback in reading systems, and this chapter reviews the process of creating these
documents. The issues involved in creating overlays for different levels of playback
granularity gets explored, as does the impact on production.
Chapter 7: Interactivity
The addition of scripting in EPUB 3 opens up a whole new dimension in ebooks.
This chapter explores the scripting capabilities supported by the format, the new
epubReadingSystem JavaScript property for querying reading system capabilities,
and also reviews the issues you’ll need to consider when choosing to make your
content dynamic. It also covers the new HTML5 canvas element.
Chapter 8: Global Language Support
To become a truly global standard for ebooks, EPUB 3 was augmented to enable
more than just left-to-right page progressions and horizontal writing styles. This
chapter looks at the mechanics and mechanisms for handling both right-to-left page
progressions and vertical writing styles. It also reviews the new CSS additions that
give greater control over such features as line and word breaking, as well as the use
of ruby annotations.
Chapter 9: Accessibility
Although this book tries to keep a focus on accessibility throughout each chapter,
this one delves into unique accessibility requirements for markup, styling, fixed
layouts, and scripting. WAI-ARIA roles, states and properties are introduced for
dynamic content, as numerous best practices for markup, many drawn from WCAG
2.0.
Chapter 10: Text-to-Speech (TTS)
One of the shortcomings of ebooks for aural readers has been the inability to control
the quality of text-to-speech playback. EPUB 3 introduces three new technologies
to fill this void: PLS lexicon files enable producers to create reusable phonetic pro‐
nunciation libraries, SSML markup allows specific pronunciation overrides to be
embedded in the markup of a document, and the CSS3 Speech properties provide
a variety of playback controls. This chapter reviews how to include all these tech‐
nologies to improve the rendering on compliant reading systems.
Chapter 11: Validation
Before distributing your finished EPUB files, you want to make sure that they con‐
form to the specifications, otherwise you run the risk of them not being usable by
readers. The final chapter looks at the epubcheck validation program, including
how to run it and how to understand the errors it emits.
Preface | xiii
www.it-ebooks.info