gofb2

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XMLNS_FICTIONBOOK = "http://www.gribuser.ru/xml/fictionbook/2.0"
	XMLNS_XLINK       = "http://www.w3.org/1999/xlink"
	XMLNS_GENRE       = "http://www.gribuser.ru/xml/fictionbook/2.0/genres"
	XMLNS_XS          = "http://www.w3.org/2001/XMLSchema"
)

Variables

View Source
var (
	ErrMissionOrIncorrectXMLNS      = errors.New("missing or incorrect xmlns")
	ErrMissionOrIncorrectXMLNSXLink = errors.New("missing or incorrect xmlns:xlink")
	ErrMissionOrIncorrectXMLNSGenre = errors.New("missing or incorrect xmlns:genre")
	ErrMissionOrIncorrectXMLNSXS    = errors.New("missing or incorrect xmlns:xs")
)

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	Paragraphs []Paragraph `xml:"p,omitempty"`
	Poem       *Poem       `xml:"poem,omitempty"`
	Cite       *Cite       `xml:"cite,omitempty"`
}

type AuthorType

type AuthorType struct {
	FirstName  string `xml:"first-name"`
	MiddleName string `xml:"middle-name,omitempty"`
	LastName   string `xml:"last-name"`
	Nickname   string `xml:"nickname,omitempty"`
	HomePage   string `xml:"home-page,omitempty"`
	Email      string `xml:"email,omitempty"`
}

type Binary

type Binary struct {
	ID          string `xml:"id,attr"`
	ContentType string `xml:"content-type,attr"`
	Value       string `xml:",chardata"`
}

type Body

type Body struct {
	Epigraph *Epigraph `xml:"epigraph,omitempty"`
	Sections []Section `xml:"section"`
	Name     string    `xml:"name,attr,omitempty"`
}

type Cite

type Cite struct {
	Paragraphs []Paragraph `xml:"p"`
	TextAuthor string      `xml:"text-author,omitempty"`
}

type Coverpage

type Coverpage struct {
	Image *Image `xml:"image"`
}

type CustomInfo

type CustomInfo struct {
	InfoType string `xml:"info-type,attr"`
	Value    string `xml:",chardata"`
}

type Date

type Date struct {
	Value string `xml:"value,attr,omitempty"`
	Text  string `xml:",chardata"`
}

type Description

type Description struct {
	TitleInfo    TitleInfo    `xml:"title-info"`
	DocumentInfo DocumentInfo `xml:"document-info"`
	PublishInfo  PublishInfo  `xml:"publish-info,omitempty"`
	CustomInfo   []CustomInfo `xml:"custom-info,omitempty"`
}

type DocumentInfo

type DocumentInfo struct {
	Author      []AuthorType `xml:"author"`
	ProgramUsed string       `xml:"program-used,omitempty"`
	Date        Date         `xml:"date"`
	SrcURL      []string     `xml:"src-url,omitempty"`
	SrcOcr      string       `xml:"src-ocr,omitempty"`
	ID          string       `xml:"id"`
	Version     float64      `xml:"version"`
	History     string       `xml:"history,omitempty"`
}

type Epigraph

type Epigraph struct {
	Paragraphs []Paragraph `xml:"p,omitempty"`
}

type FB2

type FB2 struct {
	XMLName     xml.Name    `xml:"FictionBook"`
	XMLNS       *string     `xml:"xmlns,attr"`
	XMLNSXLink  *string     `xml:"xmlns:l,attr"`
	XMLNSGenre  *string     `xml:"xmlns:genre,attr"`
	XMLNSXS     *string     `xml:"xmlns:xs,attr"`
	Stylesheet  []string    `xml:"stylesheet"`
	Description Description `xml:"description"`
	Bodies      []Body      `xml:"body"`
	Binary      []Binary    `xml:"binary"`
}

func (*FB2) BodySectionTitles

func (fb2 *FB2) BodySectionTitles() []string

func (*FB2) FixNamespaces

func (fb2 *FB2) FixNamespaces()

func (FB2) Sections

func (fb2 FB2) Sections() []*Section

func (*FB2) ValidateNamespaces

func (fb2 *FB2) ValidateNamespaces() error

type Image

type Image struct {
	XMLName xml.Name `xml:"image"`
	Href    string   `xml:"l:href,attr"`
}

type Paragraph

type Paragraph struct {
	Text string `xml:",chardata"`
}

type Parser

type Parser struct{}

func NewParser

func NewParser() *Parser

func (*Parser) Marshal

func (p *Parser) Marshal(fb2 *FB2, pretty bool) ([]byte, error)

func (*Parser) MarshalToFile

func (p *Parser) MarshalToFile(fb2 *FB2, filePath string, pretty bool) error

func (*Parser) Unmarshal

func (p *Parser) Unmarshal(reader io.Reader, isStrict bool) (*FB2, error)

func (*Parser) UnmarshalFromFile

func (p *Parser) UnmarshalFromFile(filePath string, isStrict bool) (*FB2, error)

type Poem

type Poem struct {
	Title    *Title    `xml:"title,omitempty"`
	Epigraph *Epigraph `xml:"epigraph,omitempty"`
	Stanzas  []Stanza  `xml:"stanza"`
}

type PublishInfo

type PublishInfo struct {
	BookName  string   `xml:"book-name"`
	Publisher string   `xml:"publisher"`
	City      string   `xml:"city"`
	Year      int      `xml:"year,omitempty"`
	ISBN      string   `xml:"isbn,omitempty"`
	Sequence  Sequence `xml:"sequence,omitempty"`
}

type Section

type Section struct {
	XMLName     xml.Name    `xml:"section"`
	Title       Title       `xml:"title,omitempty"`
	Paragraphs  []Paragraph `xml:"p"`
	Subsections []Section   `xml:"section,omitempty"`
}

type Sequence

type Sequence struct {
	Name   string `xml:"name,attr"`
	Number int    `xml:"number,attr,omitempty"`
}

type Stanza

type Stanza struct {
	Verses []Verse `xml:"v"`
}

type Subtitle

type Subtitle struct {
	ID   string `xml:"id,attr,omitempty"`
	Text string `xml:",chardata"`
}

type Title

type Title struct {
	Paragraphs []Paragraph `xml:"p,omitempty"`
}

type TitleInfo

type TitleInfo struct {
	Genre      []string     `xml:"genre"`
	Author     []AuthorType `xml:"author"`
	BookTitle  string       `xml:"book-title"`
	Annotation Annotation   `xml:"annotation,omitempty"`
	Coverpage  Coverpage    `xml:"coverpage"`
	Keywords   string       `xml:"keywords,omitempty"`
	Date       Date         `xml:"date"`
	Lang       string       `xml:"lang"`
	SrcLang    string       `xml:"src-lang,omitempty"`
	Translator []AuthorType `xml:"translator,omitempty"`
	Sequence   Sequence     `xml:"sequence,omitempty"`
}

type Verse

type Verse struct {
	Text string `xml:",chardata"`
}

Jump to

Keyboard shortcuts

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