Documentation ¶
Overview ¶
Package mobi implements writing KF8-style formatted MOBI and AZW3 books.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SupportedLocales []language.Tag
SupportedLocales is a list of locales supported by MOBI, intended for use with Go language matching facilities.
BUG(leotaku): While the MOBI language format supports regions, this implementation does not and explicitly removes region information from the locale stored in the generated MOBI file.
Functions ¶
Types ¶
type Book ¶
type Book struct { Title string Authors []string Contributors []string Publisher string Subject string CreatedDate time.Time PublishedDate time.Time DocType string Language language.Tag FixedLayout bool RightToLeft bool Vertical bool Chapters []Chapter CSSFlows []string Images []r.ImageRecord CoverImage image.Image ThumbImage image.Image UniqueID uint32 Html string // contains filtered or unexported fields }
Book represents all the information necessary to generate a KF8-style formatted MOBI or AZW3 book.
You are expected to initialize the Book struct using the required variables and/or builder pattern, then convert the resulting structure into a PalmDB database. This database can then be written out to any io.Writer.
func (Book) GetThumbFilename ¶
GetThumbFilename returns the filename a JPEG image in the Kindle thumbnails folder would need to have in order to be correctly associated with the generated book.
Newer Kindle readers no longer respect the thumbnail embedded in the Palm database but instead try to download the cover art from Amazon's servers using the embedded ASIN identification string. However, we can still get covers for sideloaded books by embedding a fake ASIN identification string and manually copying an image to the corresponding location inside the Kindle thumbnails folder.
func (*Book) OverrideTemplate ¶
OverrideTemplate overrides the template used in order to generate the skeleton section of a KF8 HTML chunk.
During conversion to a PalmDB database, this template is passed the internal inventory type. If the template cannot successfully be applied, the conversion will panic.
The skeleton section generally consists of a complete HTML document including head and body, with the body tag expected to contain an 'aid' attribute that indicates the identifier of the corresponding chunk. As it is relatively easy to end up with an invalid KF8 document by generating invalid skeleton sections, this option is private and hidden behind a setter function.
type Chunk ¶
type Chunk struct {
Body string
}
Chunk represents a chunk of text in a MobiBook Chapter.
Chunks are mostly an implementation detail that is exposed for maximum control over the final book output. Generally, you should use one of the various "Chunks" functions in order to generate the correct amount of chunks for a chapter.
Notes ¶
Bugs ¶
While the MOBI language format supports regions, this implementation does not and explicitly removes region information from the locale stored in the generated MOBI file.
Directories ¶
Path | Synopsis |
---|---|
Package jfif implements writing JPEG images with fixed JFIF header.
|
Package jfif implements writing JPEG images with fixed JFIF header. |
Package pdb implements reading and writing PalmDB databases.
|
Package pdb implements reading and writing PalmDB databases. |
Package records contains facilities to create MOBI formatted books.
|
Package records contains facilities to create MOBI formatted books. |
Package types contains types and constants to create MOBI formatted books.
|
Package types contains types and constants to create MOBI formatted books. |