Grand Sorcerer
Posts: 7,013
Karma: 89771379
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
A KPF file is composed of Amazon's proprietary Ion data format contained in an SQLite database. There is no HTML code there. This Ion data is repackaged in a KFX container to make the KFX (enhanced typesetting) format of the book. As a fallback for older devices that do not support KFX, Amazon converts the Ion data to a MOBI equivalent that has a limited subset of the formatting of the original document.
So if you look at the MOBI file you will not see the actual coding used in the book. You can dump the contents of the KPF file into readable Ion-text format using my KFX Input plugin for calibre, but you will probably find that to be not very comprehensible.
As an example I created a book composed of a single paragraph with some simple formatting. The equivalent KPF Ion data is shown in the spoiler.
Spoiler :
Code:
$ion_1_0
format_capabilities:: [
{
key: "db.schema",
version: 1,
},
]
$ion_symbol_table:: {
max_id: 777,
imports: [
{
name: "YJ_symbols",
version: 10,
max_id: 744,
},
],
symbols: ["yj.semantics.page_number_begin", "yj.semantics.book_theme_metadata", "yj.semantics.modern_theme", "yj.semantics.book_theme_name", "yj.semantics.book_theme_styles", "yj.semantics.book_subtitle", "yj.semantics.author", "yj.semantics.part_title", "yj.semantics.part_subtitle", "yj.semantics.chapter_title", "yj.semantics.chapter_subtitle", "yj.semantics.first_para", "yj.semantics.block_quote", "yj.semantics.copyright", "yj.semantics.dedication", "yj.semantics.book_epigraph", "yj.semantics.book_epigraph_attribution", "yj.semantics.poem", "yj.semantics.separator", "yj.semantics.other_page_title", "yj.semantics.other_first_para", "yj.semantics.bodytext", "yj.semantics.book_title", "yj.semantics.book_theme_content_semantics"],
}
uAs_WcpQTsG26QhmxKKmkA1:: section:: {
section_name: uAs_WcpQTsG26QhmxKKmkA1,
page_templates: [
structure:: {
kfx_id: uAs_WcpQTsG26QhmxKKmkA4,
story_name: uAs_WcpQTsG26QhmxKKmkA5,
type: text,
},
],
}
content_features:: {
kfx_id: content_features,
features: [
{
namespace: "com.amazon.yjconversion",
key: "reflow-style",
version_info: {
version: {
major_version: 1,
minor_version: 0,
},
},
},
],
}
uAs_WcpQTsG26QhmxKKmkA5:: storyline:: {
story_name: uAs_WcpQTsG26QhmxKKmkA5,
content_list: [uAs_WcpQTsG26QhmxKKmkA6],
}
uAs_WcpQTsG26QhmxKKmkA8:: auxiliary_data:: {
kfx_id: uAs_WcpQTsG26QhmxKKmkA8,
metadata: [
{
key: "most-common-computed-style",
value: "ComputedStyle [{FONT_SIZE=decimal:1.0 em}{MARGIN_LEFT=decimal:0.0 percent}{MARGIN_RIGHT=decimal:0.0 percent}{hasBackgroundColor:false}{hasBackgroundImage:false}{hasBorder:false}]",
},
{
key: "filename.opf",
value: "misc/resource_0_1_82312ff879470c63_1_filename_opf",
},
{
key: "SourceIdContentInfo",
value: "..\\misc\\sourceIdInfo.json",
},
],
}
uAs_WcpQTsG26QhmxKKmkA6:: structure:: {
kfx_id: uAs_WcpQTsG26QhmxKKmkA6,
dropcap_lines: 3,
dropcap_chars: 1,
type: text,
style_events: [
{
offset: 123,
length: 108,
font_weight: bold,
},
{
offset: 334,
length: 111,
font_style: italic,
},
],
content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
}
'uAs_WcpQTsG26QhmxKKmkA1-spm':: section_position_id_map:: {
section_name: uAs_WcpQTsG26QhmxKKmkA1,
contains: [[1, uAs_WcpQTsG26QhmxKKmkA4], [2, uAs_WcpQTsG26QhmxKKmkA6]],
}
'yj.section_pid_count_map':: {
contains: [
{
section_name: uAs_WcpQTsG26QhmxKKmkA1,
length: 446,
},
],
}
eidbucket_29:: 'yj.eidhash_eid_section_map':: {
block: 29,
contains: [
{
eid: uAs_WcpQTsG26QhmxKKmkA1,
section_name: uAs_WcpQTsG26QhmxKKmkA1,
},
],
}
eidbucket_32:: 'yj.eidhash_eid_section_map':: {
block: 32,
contains: [
{
eid: uAs_WcpQTsG26QhmxKKmkA4,
section_name: uAs_WcpQTsG26QhmxKKmkA1,
},
],
}
eidbucket_34:: 'yj.eidhash_eid_section_map':: {
block: 34,
contains: [
{
eid: uAs_WcpQTsG26QhmxKKmkA6,
section_name: uAs_WcpQTsG26QhmxKKmkA1,
},
],
}
metadata:: {
reading_orders: [
{
reading_order_name: default,
sections: [uAs_WcpQTsG26QhmxKKmkA1],
},
],
}
book_metadata:: {
categorised_metadata: [
{
category: "kindle_title_metadata",
metadata: [
{
key: "book_id",
value: "KjzAroqdSrS7DV2Kt_ZwVQ1",
},
{
key: "publisher",
value: "",
},
{
key: "author",
value: "John Howell",
},
{
key: "language",
value: "en",
},
{
key: "title",
value: "Test Book",
},
],
},
{
category: "kindle_audit_metadata",
metadata: [
{
key: "creator_version",
value: "1.20.1.0",
},
{
key: "file_creator",
value: "KC",
},
],
},
{
category: "kindle_ebook_metadata",
metadata: [
{
key: "selection",
value: "enabled",
},
],
},
],
}
document_data:: {
column_count: auto,
direction: ltr,
writing_mode: horizontal_tb,
font_size: {
value: 1e0,
unit: em,
},
'yj.semantics.page_number_begin': uAs_WcpQTsG26QhmxKKmkA1,
selection: enabled,
auxiliary_data: {
'yj.conversion': uAs_WcpQTsG26QhmxKKmkA8,
},
line_height: {
value: 1.2e0,
unit: em,
},
'yj.semantics.book_theme_metadata': {
'yj.semantics.book_theme_name': 'yj.semantics.modern_theme',
'yj.semantics.book_theme_styles': {
'yj.semantics.book_subtitle': YxlATNbCQzCcg6wXkeYWmQ129,
'yj.semantics.author': YxlATNbCQzCcg6wXkeYWmQ130,
'yj.semantics.part_title': YxlATNbCQzCcg6wXkeYWmQ131,
'yj.semantics.part_subtitle': YxlATNbCQzCcg6wXkeYWmQ132,
'yj.semantics.chapter_title': YxlATNbCQzCcg6wXkeYWmQ133,
'yj.semantics.chapter_subtitle': YxlATNbCQzCcg6wXkeYWmQ134,
'yj.semantics.first_para': YxlATNbCQzCcg6wXkeYWmQ135,
'yj.semantics.block_quote': YxlATNbCQzCcg6wXkeYWmQ127,
'yj.semantics.copyright': YxlATNbCQzCcg6wXkeYWmQ136,
'yj.semantics.dedication': YxlATNbCQzCcg6wXkeYWmQ137,
'yj.semantics.book_epigraph': YxlATNbCQzCcg6wXkeYWmQ138,
'yj.semantics.book_epigraph_attribution': YxlATNbCQzCcg6wXkeYWmQ139,
'yj.semantics.poem': YxlATNbCQzCcg6wXkeYWmQ140,
'yj.semantics.separator': YxlATNbCQzCcg6wXkeYWmQ141,
'yj.semantics.other_page_title': YxlATNbCQzCcg6wXkeYWmQ142,
'yj.semantics.other_first_para': YxlATNbCQzCcg6wXkeYWmQ143,
'yj.semantics.bodytext': YxlATNbCQzCcg6wXkeYWmQ144,
'yj.semantics.book_title': YxlATNbCQzCcg6wXkeYWmQ128,
},
'yj.semantics.book_theme_content_semantics': {
'yj.semantics.separator': "\u25c6\u25c6\u25c6",
},
},
spacing_percent_base: width,
reading_orders: [
{
reading_order_name: default,
sections: [uAs_WcpQTsG26QhmxKKmkA1],
},
],
}
Last edited by jhowell; 01-15-2019 at 06:58 PM .