Skip to content

The Incrementor

We use many open source tools in our day-to-day operations here at eBook Architects; tools like Gimp, Inkscape, Perl, and Python form integral parts of our process and allow us to keep our costs down. To say thanks, eBook Architects has been looking for ways to give back to the open source community, such as assisting in the launch of the #ePrdctn Wiki and by maintaining and spreading great tools like epub-applescripts and kindlegen-drop-app. We hope that these tools and resources are as useful in your eBook development as they are in ours.

The foundation of any good coding operation is the code editor you use. We recently switched to a code editor called Sublime Text 2, a cross-platform program with a dedicated developer, a consistent upgrade schedule, a large community of other users, and an impressively flexible and adjustable interface and feature set. There are a few things that our old editor allowed us to do that Sublime does not  have built-in, but we were able to code replacement functions in Sublime, keeping the developer learning curve during our switch-over down to a bare minimum.

Today we are releasing one of those new features, a  Sublime Text 2 plugin called The Incrementor, into the open source world! This little tool allows you to do common tasks like re-numbering the PlayOrder values in an NCX file quickly and easily. To download or learn more about The Incrementor visit our Github page.

Major kudos go to the coding team here at eBook Architects (TobyChris, and AJ) for their hard work on this Sublime switch over and the Incrementor plugin.

KindleGen 2.5 update

Sorry for the long hiatus… Things are really busy here at eBA!

Just wanted to give my thoughts on the updates released in KindleGen 2.5 today. The release notes include more items, but these are the ones that are most important to me:

Improved transparent PNG conversion: Transparent PNG images (now converted to JPEG) will use white background. This originally used black background during conversion causing degraded reading experience.
While not an update to support transparent PNG, this is definitely an improvement from a development standpoint. Now at least we don’t have to create separate JPGs or flatten our PNGs when building Kindle files.

Resolved indentation issues in Mobi7 related to bullets and numbered lists. This was due to usage of “margin-left” CSS property with bullets and numbered lists. In Mobi7, the margin-left property is being ignored for bullets and numbered lists. The margin-left CSS property will continue to be preserved in KF8.
This has been a big issue for us when developing non-fiction Kindle files. Hopefully B&N follows suit and updates their system to allow lists with 10 or more elements…

CSS property “display: none” no longer induces an additional space in Mobi7 for inline tags.
Peter over at Extraordinary Commons should be even happy about this than I am.

Resolved conversion failure when dc:Language tag in OPF has attributes (ex: id attribute).
This has been annoying Toby for a while. We include IDs in all of our metadata attributes for ePub and Kindle OPF files.

Overall, this is a nice maintenance update. It is always great to see Amazon (and anyone else!) actively working on support for features and bugs that developers need. Keep on sending them suggestions!

Backwards Compatible Poetry for KF8/Mobi

One of the most enjoyable, and at times most frustrating, things about eBook development is learning new systems and formats when they are released. The new Kindle Format 8 (KF8) comes with some great changes to the design capabilities on the Kindle platform, but one of the main challenges in using it is creating Kindle files that will degrade gracefully to the older Kindle devices that do not have support for KF8.

A prime example of formatting that needs backwards compatibility is poetry. In 2008 I developed the now-standard approach of using Mobipocket’s width attribute combined with specific values and non-breaking spaces to make poetry work well in Kindle devices. I covered that in detail in my book, Kindle Formatting: The Complete Guide.

In KF8, the old width attribute is no longer valid, so using this code for backwards compatibility is not possible. In the early beta versions of the KindleGen 2 tool for KF8, there was no way to make the hanging indents work properly in Mobi while still making a valid KF8 file, so I complained to Amazon about the need for a CSS-driven option using media queries. They came through with a small change to the final release version of KindleGen that allows the use of negative values in the text-indent CSS property.

So, here is a new way to create valid code in your KF8 files that will degrade gracefully for older Mobi-only devices.

The HTML is actually pretty simple. The class name designates a paragraph’s level of indentation. The non-breaking spaces are placed inside span tags that can be hidden in KF8.

1
2
3
4
5
6
<p class="poem1">Poem1. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="poem2"><span class="hide">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span>Poem2. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="poem3"><span class="hide">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span>Poem3. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="poem4"><span class="hide">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span>Poem4. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="poem5"><span class="hide">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span>Poem5. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p class="poem6"><span class="hide">&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;&#xa0;</span>Poem6. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>

The CSS starts off with the use of media queries. One section of the CSS is defining the styles for Mobipocket-only devices, and the other is defining the styles for other devices (those that support KF8 or another future format).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
@media amzn-mobi {
p.poem1 {
text-align: left;
text-indent: -30px;
}
p.poem2 {
text-align: left;
text-indent: -60px;
}
p.poem3 {
text-align: left;
text-indent: -90px;
}
p.poem4 {
text-align: left;
text-indent: -120px;
}
p.poem5 {
text-align: left;
text-indent: -150px;
}
p.poem6 {
text-align: left;
text-indent: -180px;
}
}

@media not amzn-mobi {
p {
margin-top: 0;
margin-bottom: 0;
}
.hide {display: none;}
p.poem1 {
text-align: left;
text-indent: -30px;
margin-left: 30px;
}
p.poem2 {
text-align: left;
text-indent: -30px;
margin-left: 60px;
}
p.poem3 {
text-align: left;
text-indent: -30px;
margin-left: 90px;
}
p.poem4 {
text-align: left;
text-indent: -30px;
margin-left: 120px;
}
p.poem5 {
text-align: left;
text-indent: -30px;
margin-left: 150px;
}
p.poem6 {
text-align: left;
text-indent: -30px;
margin-left: 180px;
}}

The Mobi-only CSS uses the negative text-indent to emulate the width attribute, and the KF8 CSS hides the non-breaking spaces and uses the standard CSS approach to hanging indents (negative text-indent, positive margin-left).

That’s it! Come back later for more posts on KF8 development and backwards compatibility.