File last modified on August 18, 2022

Notes

Footnotes, rearnotes or any kind of notes found in content must back link regardless if they exist in the same file or another file as this is a channel requirement, example:

html
1
<p class="text">
2
Bacon ipsum dolor amet capicola chicken rump porchetta, meatball short loin filet mignon hamburger
3
leberkas ham hock strip steak jowl pork alcatra ribeye.<a
4
id="backlink-footnote-1"
5
href="footnote-1"
6
><span class="superscript">1</span></a
7
>
8
</p>
9
<!-- More Content -->
10
<p class="footnote">
11
<a id="footnote-1" href="backlink-footnote-1">1.</a> Ribeye jowl meatball tongue cupim meatloaf
12
ball tip sausage brisket pastrami.
13
</p>

Location

Notes can be placed at the end of each chapter or in a XHTML named backmatter. If a XHTML is to be used the notes are to be the last XHTML file. This rule placement order doesn't apply to notes that are in referenced in the PDF. For example:

Below HTML assumes a page with a header and the last pagebreak is a blank white page.

html
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<!DOCTYPE html>
3
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
4
<head>
5
<title>Note Example</title>
6
<link href="../css/idGeneratedStyles.css" rel="stylesheet" type="text/css" />
7
<link href="../css/epub3.css" rel="stylesheet" type="text/css" />
8
</head>
9
<body epub:type="backmatter">
10
<section epub:type="rearnotes">
11
<a epub:type="pagebreak" id="page209" title="209"></a>
12
<p class="cht">Notes</p>
13
<p class="notes">
14
<a id="rearnote-ch02-1" href="SC02_chapter02.xhtml#rearnote-backlink-ch02-1">1</a>. Note
15
text here.
16
</p>
17
<p class="notes">
18
<a id="rearnote-ch07-2" href="SC02_chapter07.xhtml#rearnote-backlink-ch07-2">2</a>. Note
19
text here.
20
</p>
21
<a epub:type="pagebreak" id="page210" title="210"></a>
22
</section>
23
</body>
24
</html>

Multi Span

For some reason an InDesign's exported notes are within multiple spans, example:

html
1
<span class="superscrpt">
2
<span id="footnote-328-backlink">
3
<a class="_idFootnoteLink _idGenColorInherit" href="output.xhtml#footnote-328">2025</a>
4
</span>
5
</span>

This can be cleaned regex:

bash
1
## Find:
2
<span class="([A-Za-z_-]+)"><span id="footnote-(\d{1,5})-backlink"><a class="_idFootnoteLink _idGenColorInherit" href=".*\.xhtml#footnote-\2">(\d{1,5})</a></span></span>
3
4
## Replace:
5
<span id="footnote-\2-backlink" class="\1"><a href="03_backmatter\.xhtml#footnote-\2">\3</a></span>

which outputs:

html
1
<span id="footnote-328-backlink" class="superscrpt">
2
<a href="03_backmatter.xhtml#footnote-328">2025</a>
3
</span>

Chapter Removal

If there are a low number of notes and the note numerical count isn't reset/starts with 1 on each new chapter the chapter ref can be removed, example:

Before

Chapter file (links to back):

html
1
<a id="rearnote-backlink-ch02-1" href="SC03_backmatter01.xhtml#rearnote-ch02-1">
2
<span class="superscript">1</span>
3
</a>

Backmatter file (links to content):

html
1
<a id="rearnote-ch02-1" href="SC02_chapter02.xhtml#rearnote-backlink-ch02-1">1</a>

After

Chapter file (links to back):

html
1
<a id="rearnote-backlink-1" href="SC03_backmatter01.xhtml#rearnote-1">
2
<span class="superscript">1</span>
3
</a>

Backmatter file (links to content):

html
1
<a id="rearnote-1" href="SC02_chapter02.xhtml#rearnote-backlink-1">1</a>

Regex

Following regex will trim chapter.xhtml and backmatter.xhtml files:

bash
1
## Find:
2
(?<=rearnote|backlink)-ch\d+-(?=\d)
3
4
## Replace:
5
-
Last build: Thursday, 08/18/2022, 01:01:08 AM