files

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// NL is the system-specific newline character (initialized in init()).
	NL = "\n"
)

Functions

func FormatXML

func FormatXML(xmlString string) string

FormatXML takes a raw XML string and returns a formatted, indented version. It collapses existing whitespace and applies a hierarchical indentation based on the tag nesting level.

Types

type ByteSeq

type ByteSeq interface{ ~string | ~[]byte }

ByteSeq is a generic constraint that allows for types that are underlyingly strings or byte slices.

type FileContent

type FileContent[T ByteSeq] struct {
	// Filepath is the relative path within the EPUB zip container.
	Filepath string
	// Bytes is the content of the file, either as a string or a byte slice.
	Bytes T
}

FileContent represents a file to be included in the EPUB archive, pairing its destination path with its raw data.

func Container

func Container() FileContent[[]byte]

Container returns the mandatory "META-INF/container.xml" file. This file tells the e-reader where the root metadata (OPF) file is located.

func DisplayOptions

func DisplayOptions() FileContent[[]byte]

DisplayOptions returns a configuration file specifically for Apple iBooks to ensure custom embedded fonts are enabled by default.

func Mimetype

func Mimetype() FileContent[[]byte]

Mimetype returns the mandatory "mimetype" file. According to EPUB specs, this must be the first file in the ZIP archive and must be uncompressed.

func NewFileContent

func NewFileContent[T ByteSeq](filepath string, bytes T) FileContent[T]

NewFileContent is a constructor that initializes a FileContent with the given path and data.

func (FileContent[string]) ToBytes

func (f FileContent[string]) ToBytes() FileContent[[]byte]

ToBytes converts a string-based FileContent into a byte-slice-based FileContent, which is often necessary for the final compression stage.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL