PDF→EPUB: Add epub:type to examples.

This commit is contained in:
tastytea 2021-03-21 22:21:52 +01:00
parent a8b9c51b7d
commit b26895aa88
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 25 additions and 13 deletions

View File

@ -20,6 +20,9 @@ toc: true
:url-calibre-convert: https://manual.calibre-ebook.com/conversion.html#pdfconversion
:url-emacs: https://www.gnu.org/software/emacs/
:url-emacs-key-notation: https://www.emacswiki.org/emacs/EmacsKeyNotation
:url-helicon-type: https://www.heliconbooks.com/?id=blog&postid=EPUB3Footnotes
:url-epub-spec: https://www.w3.org/publishing/epub/epub-contentdocs.html
:url-ap-semantics: https://www.accessiblepublishing.ca/epub-semantic-aria-roles/
:wp-pdf: https://en.wikipedia.org/wiki/PDF
:wp-epub: https://en.wikipedia.org/wiki/EPUB
:wp-xhtml: https://en.wikipedia.org/wiki/XHTML
@ -68,7 +71,7 @@ Your files should look similar to this:
[source,html]
--------------------------------------------------------------------------------
<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
<head>
<title>Meine zwei Jahre in Russland</title>
@ -175,20 +178,21 @@ elisp function:
Once you are done, copy the result into Calibre.
== Add footnotes
[#_add_footnotes]
== Add endnotes
Use the method from above to copy the footnotes into the now empty Emacs buffer
and clean them up until you have 1 paragraph per line. Footnotes need to be
Use the method from above to copy the endnotes into the now empty Emacs buffer
and clean them up until you have 1 paragraph per line. Endnotes need to be
hyperlink-able, so we can't just wrap them in plain `<p>` tags, they need IDs. I
like to use `<span>1</span><p id="fn1">[…]</p>` if there is only one
footnote-section or `<span>1</span><p id="fn1_1">[…]</p>` for
chapter-footnotes. We are going to use a macro with a counter to generate
consecutively numbered IDs. First, set the counter to 1 with kbd:[C-x]
kbd:[C-k] kbd:[C-c] `1`. Then, record this macro:
like to use `<span>1</span><aside epub:type="endnote" id="fn1">[…]</aside>` if there
is only one footnote-section or `<span>1</span><aside epub:type="endnote"
id="fn1_1">[…]</aside>` for chapter-endnotes. We are going to use a macro with a
counter to generate consecutively numbered IDs. First, set the counter to 1 with
kbd:[C-x] kbd:[C-k] kbd:[C-c] `1`. Then, record this macro:
`<span>` kbd:[C-x] kbd:[C-k] kbd:[<tab>] kbd:[C-u] `-1` kbd:[C-x] kbd:[C-k]
kbd:[C-a] `</span><p id="fn` kbd:[C-x] kbd:[C-k] kbd:[<tab>] `">` kbd:[<end>]
`</p>` kbd:[<down>] kbd:[<down>] kbd:[<home>]
kbd:[C-a] `</span><aside epub:type="endnote" id="fn` kbd:[C-x] kbd:[C-k]
kbd:[<tab>] `">` kbd:[<end>] `</aside>` kbd:[<down>] kbd:[<down>] kbd:[<home>]
[NOTE]
kbd:[C-u] `-1` kbd:[C-x] kbd:[C-k] kbd:[C-a] “adds” -1 to the counter, so that
@ -200,7 +204,8 @@ out what a key combination does.
Call the macro until every footnote is wrapped and copy them to Calibre.
=== Add references to footnotes
[#_add_references_to_footnotes]
=== Add references to endnotes
The footnotes are probably superscript numbers in the PDF but normal numbers in
the EPUB right now. I found that the footnote-numbers are usually preceded by a
@ -208,7 +213,7 @@ space and followed by a space or `<`. I use the find & replace function in
Calibre in Regex-mode to convert them to hyperlinks.
Find: ``&nbsp;([0-9]{1,3})([ <])`` (note the leading space) +
Replace: `<sup><a href="#fn\1">\1</a></sup>\2`
Replace: `<sup><a epub:type="noteref" href="#fn\1">\1</a></sup>\2`
Press kbd:[<f3>] to search through the text and kbd:[C-r] to replace.
@ -225,5 +230,12 @@ Select menu:Tools[Check book] and fix the errors.
You're done! Enjoy your cleanly formatted book. 😊
== Updates
* [2021-02-21] Added ``epub:type``s to examples. See
link:{url-helicon-type}[Helicon Books: Footnotes in EPUB3],
link:{url-epub-spec}#sec-epub-type-attribute[the EPUB specification] and
link:{url-ap-semantics}[AccessiblePublishing: EPUB Semantics, ARIA Roles, &
Metadata] for more information.
// LocalWords: Calibre