EPubHacks

From MobileRead
Jump to: navigation, search

Note: Please try if you can to specify the version of the software you are testing against. In some cases, a hack may be no longer needed after the reading software has been updated. These hacks are specific to ePub version 2.X unless specified otherwise.

[edit] Adobe Digital Editions

Problem

Ignores CSS "font-variant:small-caps;"

Hack

First, the text must be all caps. Then you must tag the first letter of the word as well as the rest of the word like this:

<span class="small-caps-first">S</span><span class="small-caps-rest">UBJECT</span>

Then use the CSS of your choice to make the class "small-caps-rest" in smaller text.

One very unfortunate down side to this hack is that the Nook will treat your word as two words separated by the spans. So, in this example, if your word gets too close to the edge it will leave the "S" at the end of the line and wrap "UBJECT" down to the beginning of the next line. Ugh-ly! Some EPrdctn folks have gotten around this CSS small caps bad line wrap with one of these hacks:

  • wrap the whole word or phrase in another span:
    <span class=small_caps_text>C<span class="small-caps">APTER</span> O<span class="small-caps">NE</span></span>
  • create a css class "span.nowrap {white-space:nowrap;} " and apply to text, note: best for short bits of text, lines that are too long may disappear by extending past margins
    <span class="nowrap">C<span class="small-caps">APTER</span> O<span class="small-caps">NE</span></span>
  • add "adobeTextLayout: OptimizeSpeed;" to your CSS, it forces the Nook Color to use an older RMSDK (?) and also eliminates hyphens.

Thanks to @cdcasey @bendu @rcgordon


If you're using Sigil to edit your ePub, you can automate the creation of "manual" small caps using Sigil's regular expression engine (regex).

First, ensure all instances of small-caps are wrapped with `<span class="SC"></span>`, remove the `font-variant: small-caps;` property from the CSS, and create an `span.FSC` style (for Fake Small Caps):

span.SC {
	/*font-variant: small-caps;*/
}
span.FSC {
	font-size: 0.75em;
}

Using the Find/Replace strings below and set to search on all HTML files, use "Replace All" only once.

  • Find:
(<span class="SC">(?:(?!<\/span>)(?:[^a-z&]|&[^;]+;))*|(?!^)\G(?:(?!<\/span>)(?:[^a-z&]|&[^;]+;))*)([a-z]+)
  • Replace:
\1<span class="FSC">\U\2\E</span>

This method brought to you by user "ka рха" at StackOverflow.

An explanation of this regex string can be found here.

Problem

In some ereaders and ereader software based on Adobe Digital Editions, margins can show up VERY large all the way around the text.

Solution

Some older versions of Adobe InDesign create *.xpgt files that serve no purpose in epub. Delete any *.xpgt files in your epub and any reference to them in the heads of your html files and your opf file. See this discussion.

Problem

Unordered lists will break the last list item across a page breaks for no apparent reason. There is no known solution to this issue.

[edit] iBooks

Problem

Alignment instructions applied to a class on a span tag are ignored.

Hack

Insert empty span tags within the span with the class. For example:

<span class="float-right"><span>Pull Quote</span></span>
Personal tools
Namespaces

Variants
Actions
Navigation
MobileRead Networks
Toolbox