File last modified on August 18, 2022

OPF Spine

While the Manifest lists all the contents of the ePub the Spine renders the order of XHTML files and it's very important to note what is declared in the Spine and one reason the implemented naming convention is required during development is to assist the Spine creation. If the XHTML naming convention was followed then in BBEdit open a new file (shortcut N), copy and paste what's in the manifest for XHTML:

html
1
<item
2
id="DS01_frontmatter01"
3
href="text/DS01_frontmatter01.xhtml"
4
media-type="application/xhtml+xml"
5
/>
6
<item
7
id="DS01_frontmatter02"
8
href="text/DS01_frontmatter02.xhtml"
9
media-type="application/xhtml+xml"
10
/>
11
<item id="DS02_chapter01" href="text/DS02_chapter01.xhtml" media-type="application/xhtml+xml" />
12
<item id="DS02_chapter02" href="text/DS02_chapter02.xhtml" media-type="application/xhtml+xml" />
13
<item id="DS02_chapter03" href="text/DS02_chapter03.xhtml" media-type="application/xhtml+xml" />
14
<item id="DS02_chapter04" href="text/DS02_chapter04.xhtml" media-type="application/xhtml+xml" />
15
<item
16
id="DS03_backmatter01"
17
href="text/DS03_backmatter01.xhtml"
18
media-type="application/xhtml+xml"
19
/>

run the BBEdit regex command:

bash
1
## Find:
2
<item id="(.*)" href.*?$
3
4
## Replace:
5
<itemref idref="\1" />

which should render:

html
1
<itemref idref="DS01_frontmatter01" />
2
<itemref idref="DS01_frontmatter02" />
3
<itemref idref="DS02_chapter01" />
4
<itemref idref="DS02_chapter02" />
5
<itemref idref="DS02_chapter03" />
6
<itemref idref="DS02_chapter04" />
7
<itemref idref="DS03_backmatter01" />

copy and paste the newly converted text and paste it in between the <spine> tags after the toc, example:

html
1
<spine toc="ncx">
2
<itemref idref="toc" />
3
<itemref idref="DS01_frontmatter01" />
4
<itemref idref="DS01_frontmatter02" />
5
<itemref idref="DS02_chapter01" />
6
<itemref idref="DS02_chapter02" />
7
<itemref idref="DS02_chapter03" />
8
<itemref idref="DS02_chapter04" />
9
<itemref idref="DS03_backmatter01" />
10
</spine>

by default we assume the first entry to be referenced will always be the toc. While this is our default standard sometimes this can be changed and that usually comes from an editorial request.

Linear No

There is the ability to apply a linear=no option to itemrefs to exclude an XHTML file from the reading order, example:

html
1
<spine toc="ncx">
2
<itemref idref="toc" />
3
<itemref idref="DS01_frontmatter01" />
4
<itemref idref="DS01_frontmatter02" />
5
<itemref idref="DS02_chapter01" />
6
<itemref idref="DS02_chapter02" />
7
<itemref idref="DS02_chapter03" />
8
<itemref idref="DS02_chapter04" linear="no" />
9
<itemref idref="DS03_backmatter01" />
10
</spine>

However, this option isn't widely supported on devices since it was implemented around ePub 2 and most apps do not support this like Adobe Digital Editions.

ON THIS PAGE
Last build: Thursday, 08/18/2022, 01:01:08 AM