gen-epub-book.awk
- Generate an ePub book from a simple plaintext descriptor
gen-epub-book.awk -v temp
[ng]?awk -f gen-epub-book.awk -v temp
Generate an ePub book from a simple plaintext descriptor.
The script requires the user to pass a temporary directory via the temp
variable. The systems temporary directory can be found in the $TEMP
or
$TMP
environment variables.
Assuming the former, the full argument will be -v temp="$TEMP"
.
The descriptor consists of multiple lines in the format "Key: Value", unknown keys are ignored, lines that don't match the format are ignored.
Self
Required: yes
Type: file path
Value: path to file used as descriptor
Use: to extract base directory for relative content paths
Amount: 1
Order: before any content
Out
Required: yes
Type: file path
Value: path to the output file
Use: to extract temporary directory name for assembly
Amount: 1
Order: before any content
Name
Required: yes
Type: plaintext
Value: e-book's title
Amount: 1
Order: irrelevant
Content
Required: no
Type: file path
Value: relative path to (X)HTML chunk
Amount: any
Order: after Self
Remarks: see ADDITIONAL CONTENT PROCESSING
String-Content
Required: no
Type: (X)HTML
Value: (X)HTML string
Amount: any
Order: after Self and Out
Image-Content
Required: no
Type: file path
Value: relative path to image to include in e-book
Amount: any
Order: after Self and Out
Network-Image-Content
Required: no
Type: file URL
Value: URL of image to include in e-book
Amount: any
Order: after Self and Out
Cover
Required: no
Type: file path
Value: relative path to image to use as e-book cover
Amount: 0-1
Order: after Self and Out
Remarks: exclusive with Network-Cover
Network-Cover
Required: no
Type: file URL
Value: URL to image to use as e-book cover
Amount: 0-1
Order: after Self and Out
Remarks: exclusive with Cover
Include
Required: no
Type: file path
Value: auxilliary file to include in e-book
Amount: any
Network-Include
Required: no
Type: file URL
Value: URL of auxilliary file to include in e-book
Amount: any
Description
Required: no
Type: file URL
Value: relative path to book description
Amount: 0-1
Remarks: exclusive with String-Description and Network-Description
String-Description
Required: no
Type: (X)HTML
Value: book description
Amount: 0-1
Remarks: exclusive with Description and Network-Description
Network-Description
Required: no
Type: file URL
Value: URL of book description
Amount: 0-1
Remarks: exclusive with Description and String-Description
Author
Required: yes
Type: plaintext string
Value: e-book's author
Amount: 1
Order: irrelevant
Date
Required: yes
Type: ISO-8601-compliant date
Value: e-book's authoring/publishing date
Amount: 1
Order: irrelevant
Language
Required: yes
Type: BCP47-compliant language code
Value: language used in e-book
Amount: 1
Order: irrelevant
When adding content using the Content
entry, the file will additinally be
searched for a comment specifying the its name in the TOC in this format:
<!-- ePub title: "TOC_NAME" -->
Where TOC_NAME
is a string not containing the " character.
This will, on e-book readers, allow users to jump directly to the content represented by the document containing this entry.
Optional.
The script is continually tested against semi-recent GAWK and will work there.
The script doesn't support MAWK.
Need support/testing for some AWK version? Contact me via e-mail or pop into GitHub issues.
Written by nabijaczleweli <nabijaczleweli@gmail.com>
<https://github.com/nabijaczleweli/gen-epub-book/issues>
<https://github.com/nabijaczleweli/gen-epub-book>