gopub

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 6 Imported by: 0

README

gopub

Go library to work with EPUB files.

[!WARNING] Not ready for usage in the production environment yet.

Supported EPUB standards:

  • EPUB 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Book

type Book struct {
	FilePath     string
	Title        string
	Author       string
	Authors      []string
	Description  string
	CoverImage   []byte
	ReadingOrder []LocalTextContentFile
	Navigation   []Navigation
	Content      Content
}

func ReadBook

func ReadBook(filePath string) (Book, error)

type Collection

type Collection struct {
	ID          string       `xml:"id,attr"`
	Role        string       `xml:"role,attr"`
	Language    string       `xml:"language,attr"`
	Metadata    Metadata     `xml:"metadata"`
	Collections []Collection `xml:"collections"`
	Links       []Link       `xml:"link"`
}

type Container

type Container struct {
	RootFile RootFile `xml:"rootfiles>rootfile"`
}

type Content

type Content struct {
	Cover              LocalByteContentFile
	NavigationHtmlFile LocalTextContentFile
	Html               []LocalTextContentFile
	Css                []LocalTextContentFile
	Images             []LocalByteContentFile
	Fonts              []LocalByteContentFile
	Audios             []LocalByteContentFile
	AllFiles           []LocalContentFile
}

type ContentFile

type ContentFile struct {
	Key             string
	ContentType     ContentType
	ContentMimeType string
	ContentLocation ContentLocation
	ContentFileType ContentFileType
}

type ContentFileType

type ContentFileType int
const (
	ContentFileTypeText ContentFileType = iota + 1
	ContentFileTypeByteArray
)

type ContentLocation

type ContentLocation int
const (
	ContentLocationLocal ContentLocation = iota + 1
	ContentLocationRemote
)

type ContentType

type ContentType int
const (
	ContentTypeImageGif ContentType = iota + 1
	ContentTypeImageJpeg
	ContentTypeImagePng
	ContentTypeImageSvg
	ContentTypeImageWebp

	ContentTypeAudioMp3
	ContentTypeAudioMp4
	ContentTypeAudioOgg

	ContentTypeCss

	ContentTypeFontTruetype
	ContentTypeFontSfnt
	ContentTypeFontOpentype
	ContentTypeFontWoff
	ContentTypeFontWoff2

	ContentTypeXhtml
	ContentTypeXml
	ContentTypeScript
	ContentTypeDtb
	ContentTypeDtbNcx
	ContentTypeSmil

	ContentTypeOeb1Document
	ContentTypeOeb1Css

	ContentTypeOther
)

type Creator

type Creator struct {
	ID    string `xml:"id,attr"`
	Value string `xml:",chardata"`
}

type Guide

type Guide struct {
	References []Reference `xml:"reference"`
}

type Identifier

type Identifier struct {
	ID    string `xml:"id,attr"`
	Value string `xml:",chardata"`
}

type ItemRef

type ItemRef struct {
	ID         string `xml:"id,attr"`
	IdRef      string `xml:"idref,attr"`
	Linear     string `xml:"linear,attr"`
	Properties string `xml:"properties"`
}
type Link struct {
	ID        string `xml:"id"`
	Href      string `xml:"href"`
	MediaType string `xml:"media-type"`
}

type LocalByteContentFile

type LocalByteContentFile struct {
	Content []byte
	ContentFile
}

type LocalContentFile

type LocalContentFile struct {
	FilePath string
	ContentFile
}

type LocalTextContentFile

type LocalTextContentFile struct {
	Content string
	ContentFile
}

type Manifest

type Manifest struct {
	Items []ManifestItem `xml:"item"`
}

type ManifestItem

type ManifestItem struct {
	ID                string `xml:"id,attr"`
	Href              string `xml:"href,attr"`
	MediaType         string `xml:"media-type,attr"`
	MediaOverlay      string `xml:"media-overlay,attr"`
	RequiredNamespace string `xml:"required-namespace,attr"`
	RequiredModules   string `xml:"required-modules,attr"`
	Fallback          string `xml:"fallback,attr"`
	FallbackStyle     string `xml:"fallback-style,attr"`
	Properties        string `xml:"properties,attr"`
}

type Metadata

type Metadata struct {
	Identifiers  []Identifier `xml:"identifier"`
	Titles       []Title      `xml:"title"`
	Languages    []string     `xml:"language"`
	Contributers []string     `xml:contributor`
	Coverages    []string     `xml:coverage`
	Creators     []Creator    `xml:"creator"`
	Dates        []string     `xml:"date"`
	Descriptions []string     `xml:"description"`
	Formats      []string     `xml:"format"`
	Publishers   []string     `xml:"publisher"`
	Relations    []string     `xml:"relation"`
	Rights       []string     `xml:"right"`
	Sources      []string     `xml:"source"`
	Subjects     []string     `xml:"subject"`
	Types        []string     `xml:"types"`
}
type NavAnchor struct {
	Href  string `xml:"href,attr"`
	Text  string `xml:",chardata"`
	Title string `xml:"title,attr"`
	Alt   string `xml:"alt,attr"`
	Type  string `xml:"type,attr"`
}
type NavLi struct {
	Anchor  NavAnchor `xml:"a"`
	Span    NavSpan   `xml:"span"`
	ChildOl NavOl     `xml:"ol"`
}
type NavOl struct {
	IsHidden *string `xml:"hidden,attr"`
	Lis      []NavLi `xml:"li"`
}
type NavSpan struct {
	Text  string `xml:"text"`
	Title string `xml:"title"`
	Alt   string `xml:"alt"`
}
type Navigation struct {
	Type     string  `xml:"type,attr"`
	IsHidden *string `xml:"hidden,attr"`
	H1       string  `xml:"h1"`
	H2       string  `xml:"h2"`
	H3       string  `xml:"h3"`
	H4       string  `xml:"h4"`
	H5       string  `xml:"h5"`
	H6       string  `xml:"h6"`
	Ol       NavOl   `xml:"ol"`
}
type NavigationDocument struct {
	FilePath    string
	Title       string
	Navigations []Navigation
}

type Package

type Package struct {
	XMLName          xml.Name     `xml:"package"`
	UniqueIdentifier string       `xml:"unique-identifier,attr"`
	Version          string       `xml:"version,attr"`
	Metadata         Metadata     `xml:"metadata"`
	Manifest         Manifest     `xml:"manifest"`
	Spine            Spine        `xml:"spine"`
	Guide            Guide        `xml:"guide"`
	Collections      []Collection `xml:"collection"`
}

func ReadPackage

func ReadPackage(r *zip.ReadCloser, rootfilePath string) (Package, error)

type Reference

type Reference struct {
	Type  string `xml:"type,attr"`
	Title string `xml:"title,attr"`
	Href  string `xml:"href,attr"`
}

type RootFile

type RootFile struct {
	FullPath string `xml:"full-path,attr"`
}

type Spine

type Spine struct {
	ItemRefs []ItemRef `xml:"itemref"`
}

type StructuralSemanticsProperty

type StructuralSemanticsProperty int
const (
	SspCover StructuralSemanticsProperty = iota + 1
	SspFrontMatter
	SspBodyMatter
	SspBackMatter
	SspVolume
	SspPart
	SspChapter
	SspSubChapter
	SspDivision
	SspAbstract
	SspForeword
	SspPreface
	SspPrologue
	SspIntroduction
	SspPreamble
	SspConclusion
	SspEpilogue
	SspAfterword
	SspEpigram
	SspToc
	SspTocBrief
	SspLandmarks
	SspLoa
	SspLoi
	SspLot
	SspLov
	SspAppendix
	SspColophon
	SspCredits
	SspKeywords
	SspIndex
	SspIndexHeadnotes
	SspIndexLegend
	SspIndexGroup
	SspIndexEntryList
	SspIndexEntry
	SspIndexTerm
	SspIndexEditorNote
	SspIndexLocator
	SspIndexLocatorList
	SspIndexLocatorName
	SspIndexXrefPreferred
	SspIndexXrefRelated
	SspIndexTermCategory
	SspIndexTermCategories
	SspGlossary
	SspGlossTerm
	SspGlossDef
	SspBibliography
	SspBibloEntry
	SspTitlePage
	SspHalfTitlePage
	SspCopyrightPage
	SspSeriesPage
	SspAcknowledgements
	SspImprint
	SspImprimatur
	SspContributors
	SspOtherCredits
	SspErrata
	SspDedication
	SspRevisionHistory
	SspCaseStudy
	SspHelp
	SspMarginalia
	SspNotice
	SspPullQuote
	SspSidebar
	SspTip
	SspWarning
	SspHalfTitle
	SspFullTitle
	SspCoverTitle
	SspTitle
	SspSubtitle
	SspLabel
	SspOrdinal
	SspBridgehead
	SspLearningObjective
	SspLearningObjectives
	SspLearningOutcome
	SspLearningOutcomes
	SspLearningResource
	SspLearningResources
	SspLearningStandard
	SspLearningStandards
	SspAnswer
	SspAnswers
	SspAssessment
	SspAssessments
	SspFeedback
	SspFillInTheBlankProblem
	SspGeneralProblem
	SspQna
	SspMatchProblem
	SspMultipleChoiceProblem
	SspPractice
	SspQuestion
	SspPractices
	SspTrueFalseProblem
	SspPanel
	SspPanelGroup
	SspBalloon
	SspTextArea
	SspSoundArea
	SspAnnotation
	SspNote
	SspFootnote
	SspEndnote
	SspRearnote
	SspFootnotes
	SspEndnotes
	SspRearnotes
	SspAnnoRef
	SspBiblioRef
	SspGlossRef
	SspNoteRef
	SspBacklink
	SspCredit
	SspKeyword
	SspTopicSentence
	SspConcludingSentence
	SspPagebreak
	SspPageList
	SspTable
	SspTableRow
	SspTableCell
	SspList
	SspListItem
	SspFigure
	SspAside
	SspUnknown
)

type Title

type Title struct {
	ID    string `xml:"id,attr"`
	Value string `xml:",chardata"`
}

Jump to

Keyboard shortcuts

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