Documentation ¶
Overview ¶
Package records contains facilities to create MOBI formatted books.
Index ¶
- Constants
- func ChunkIndexRecord(info []ChunkInfo) (IndexRecord, CNCXRecord)
- func NCXIndexRecord(info []ChapterInfo) (IndexRecord, CNCXRecord)
- func To32(i int) string
- type CNCXRecord
- type ChapterInfo
- type ChunkInfo
- type EXTHEntry
- type EXTHSection
- type FDSTRecord
- type ImageRecord
- type IndexRecord
- type NullRecord
- type SequenceData
- type StrandData
- type TextRecord
- type TrailProvider
- type TrailingData
Constants ¶
const NullPaddingLength = 8192 // 0x2000
const TextRecordMaxSize = 4096 // 0x1000
Variables ¶
This section is empty.
Functions ¶
func ChunkIndexRecord ¶
func ChunkIndexRecord(info []ChunkInfo) (IndexRecord, CNCXRecord)
func NCXIndexRecord ¶
func NCXIndexRecord(info []ChapterInfo) (IndexRecord, CNCXRecord)
Types ¶
type CNCXRecord ¶
type CNCXRecord struct {
// contains filtered or unexported fields
}
func (CNCXRecord) Length ¶
func (r CNCXRecord) Length() int
func (CNCXRecord) LengthNoPadding ¶
func (r CNCXRecord) LengthNoPadding() int
type ChapterInfo ¶
type EXTHEntry ¶
type EXTHEntry struct { EntryType t.EXTHEntryType Data []byte }
func NewEXTHEntry ¶
func NewEXTHEntry(tp t.EXTHEntryType, data []byte) EXTHEntry
type EXTHSection ¶
type EXTHSection struct {
// contains filtered or unexported fields
}
func NewEXTHSection ¶
func NewEXTHSection() EXTHSection
func (*EXTHSection) AddInt ¶
func (e *EXTHSection) AddInt(tp t.EXTHEntryType, is ...int)
func (*EXTHSection) AddString ¶
func (e *EXTHSection) AddString(tp t.EXTHEntryType, ss ...string)
func (EXTHSection) Length ¶
func (e EXTHSection) Length() int
func (EXTHSection) LengthWithoutPadding ¶
func (e EXTHSection) LengthWithoutPadding() int
type FDSTRecord ¶
type FDSTRecord struct {
// contains filtered or unexported fields
}
func NewFDSTRecord ¶
func NewFDSTRecord(flows ...string) FDSTRecord
type ImageRecord ¶
type IndexRecord ¶
type IndexRecord struct { Type uint32 HeaderType uint32 TAGXTable t.TAGXTagTable IDXTEntries [][]byte SubEntryCount uint32 CNCXCount uint32 }
func ChunkHeaderIndexRecord ¶
func ChunkHeaderIndexRecord(lastPos int, entryCount int) IndexRecord
func NCXHeaderIndexRecord ¶
func NCXHeaderIndexRecord(entryCount int) IndexRecord
func SkeletonHeaderIndexRecord ¶
func SkeletonHeaderIndexRecord(entryCount int) IndexRecord
func SkeletonIndexRecord ¶
func SkeletonIndexRecord(info []ChunkInfo) IndexRecord
func (IndexRecord) Length ¶
func (r IndexRecord) Length() int
func (IndexRecord) LengthNoPadding ¶
func (r IndexRecord) LengthNoPadding() int
type NullRecord ¶
type NullRecord struct { PalmDocHeader t.PalmDocHeader MOBIHeader t.KF8Header FullName string EXTHSection EXTHSection }
func NewNullRecord ¶
func NewNullRecord(name string) NullRecord
type SequenceData ¶
type SequenceData struct { Index int FlagFirstOfNotFirstStrand bool FlagTBSType int FlagNumSiblings byte FlagDoesSpan bool }
SequenceData is the indexing data that represents one chapter of an arbitrary level in the trailing byte sequence of a text record. If the chapter and its siblings do not have sub-chapters, its siblings are also combined into the sequence.
type StrandData ¶
type StrandData SequenceData
StrandData is the indexing data that represents one hierarchy of chapters and sub-chapters in the trailing byte sequence of a text record. This data would normally be separated into multiple strands and sequences but this implementation does not support sub-chapters meaning a strand must contain exactly one sequence and the indexing data must consist of either one or zero strands.
func (StrandData) Encode ¶
func (sd StrandData) Encode() []byte
type TextRecord ¶
type TextRecord struct {
// contains filtered or unexported fields
}
func NewTextRecord ¶
func NewTextRecord(s string, trail TrailingData) TextRecord
func (TextRecord) Length ¶
func (r TextRecord) Length() int
type TrailProvider ¶
type TrailProvider struct {
// contains filtered or unexported fields
}
func NewTrailProvider ¶
func NewTrailProvider(chapters []ChapterInfo) TrailProvider
type TrailingData ¶
type TrailingData struct { Multibyte byte Strands *StrandData }
TrailingData represents is the trailing entries that are appended to every text record as indicated by the extra data bitflags in the MOBI header. This implementation only supports flags 0b11 meaning entries for multibyte overlap and indexing data.
func Get ¶
func Get(end int, from, to int) TrailingData
func (s *TrailProvider) Get(from, to int) TrailingData { strands := TrailingData{Multibyte: 0} for i, chap := range s.chapters { end := chap.Start + chap.Length if chap.Start < from && end > to { strands.Strands = &StrandData{ Index: i, FlagTBSType: 8, FlagDoesSpan: true, } break } if chap.Start >= from && chap.Start <= to || end >= from && end <= to { if strands.Strands == nil { strands.Strands = &StrandData{ Index: i, FlagTBSType: 8, FlagDoesSpan: false, } } strands.Strands.FlagNumSiblings++ } } return strands }
func (TrailingData) Encode ¶
func (td TrailingData) Encode() []byte