Quote:
Originally Posted by xxyzz
I'd like to create a simple implementation of the preview cli. I want to find the KFX file format in your KFX Input plugin code, but don't know where to look at, could you please give some hints?
|
Here is a brief overview of the significant code in kfxlib, most of which is common to the KFX Input and KFX Output plugins.
- generate_kpf_common.py, generate_kpf_using_cli.py - Invoke Kindle Previewer CLI to convert EPUB to KPF.
- ion.py - Amazon Ion format, which is the underlying data format for KFX.
- ion_binary.py - The binary representation of Ion.
- ion_symbol_table.py - Ion symbol tables.
- ion_text.py - The text representation of Ion, useful for debugging.
- kfx_container.py - KFX file structure. Ion data fragments in a compact container.
- kpf_book.py - Book structure specific to KPF format.
- kpf_container.py - KPF file structure. Ion data fragments in an SQLite database.
- resources.py - Images, fonts, and mime types.
- yj_book.py - Handle the multiple files that make up a book in KFX format. Starting point for conversion.
- yj_container.py - Book content as a list of data fragments in Ion format.
- yj_metadata.py - Book metadata.
- yj_position_location.py - The methods by which book content is indexed.
- yj_structure.py - Consistency checks for various types of Ion data fragments.
- yj_symbol_catalog.py - Dummy Ion symbol catalog.
- yj_to_epub.py - Overall conversion of KFX to EPUB.
- yj_to_epub_content.py - Conversion of book content.
- yj_to_epub_illustrated_layout.py - Conversion of Kindle in Motion books. No longer being produced.
- yj_to_epub_metadata.py - Conversion of book metadata.
- yj_to_epub_misc.py - Miscellaneous data conversion.
- yj_to_epub_navigation.py - Navigation conversion: table of contents, guide, etc.
- yj_to_epub_notebook.py - Scribe notebooks.
- yj_to_epub_properties.py - Conversion of CSS properties.
- yj_to_epub_resources.py - Conversion of fonts and images.
- yj_to_pdf.py - Conversion of KFX book images to PDF.
- yj_versions.py - Known KFX metadata.
Notes:
KFX and KPF store data structures using
Amazon Ion format. That is the only documented aspect of KFX as far as I know. The data structures that make up a book are called fragments.
My code contains Ion symbols in their numeric form, such as $123. I did not include a copy of the YJ_symbols symbol table to avoid copying anything significant from Amazon. You can obtain the actual symbol table by decompiling EpubToKFXConverter-4.0.jar from Kindle Previewer and looking for the enumeration that begins with "kProperty_Invalid".
The KFX Output plugin converts KPF from Kindle Previewer to KFX. However this is mostly just a repackaging of Ion fragments. The hard work is done by the Kindle Previewer.
My code wasn't written to be especially readable. There are no comments.