fb2

package
v0.0.0-...-9f06ebb Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package fb2 represent .fb2 format parser

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorType

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

AuthorType embedded fb2 type, represents author info

type FB2

type FB2 struct {
	ID          string   `bson:"_id"`
	FictionBook xml.Name `xml:"FictionBook" bson:"FictionBook"`
	Stylesheet  []string `xml:"stylesheet" bson:"stylesheet"`
	Description struct {
		TitleInfo struct {
			Genre      []string     `xml:"genre" bson:"genre"`
			GenreType  []string     `xml:"genreType" bson:"genreType"`
			Author     []AuthorType `xml:"author" bson:"author"`
			BookTitle  string       `xml:"book-title" bson:"book-title"`
			Annotation string       `xml:"annotation" bson:"annotation"`
			Keywords   string       `xml:"keywords" bson:"keywords"`
			Date       string       `xml:"date" bson:"date"`
			Coverpage  struct {
				Image struct {
					Href string `xml:"xlink:href,attr" bson:"href"`
				} `xml:"image,allowempty" bson:"image"`
			} `xml:"coverpage" bson:"coverpage"`
			Lang       string     `xml:"lang" bson:"lang"`
			SrcLang    string     `xml:"src-lang" bson:"src-lang"`
			Translator AuthorType `xml:"translator" bson:"translator"`
			Sequence   string     `xml:"sequence" bson:"sequence"`
		} `xml:"title-info" bson:"title-info"`
		DocumentInfo struct {
			Author      []AuthorType `xml:"author" bson:"author"`
			ProgramUsed string       `xml:"program-used" bson:"program-used"`
			Date        string       `xml:"date" bson:"date"`
			SrcURL      []string     `xml:"src-url" bson:"src-url"`
			SrcOcr      string       `xml:"src-ocr" bson:"src-ocr"`
			ID          string       `xml:"id" bson:"id"`
			Version     float64      `xml:"version" bson:"version"`
			History     string       `xml:"history" bson:"history"`
		} `xml:"document-info" bson:"document-info"`
		PublishInfo struct {
			BookName  string `xml:"book-name" bson:"book-name"`
			Publisher string `xml:"publisher" bson:"publisher"`
			City      string `xml:"city" bson:"city"`
			Year      int    `xml:"year" bson:"year"`
			ISBN      string `xml:"isbn" bson:"isbn"`
			Sequence  string `xml:"sequence" bson:"sequence"`
		} `xml:"PublishInfo" bson:"PublishInfo"`
		CustomInfo []struct {
			InfoType string `xml:"info-type" bson:"info-type"`
		} `xml:"custom-info" bson:"custom-info"`
	} `xml:"description" bson:"description"`
	Body struct {
		Sections []struct {
			P []string `xml:"p" bson:"p"`
		} `xml:"section" bson:"section"`
	} `xml:"body" bson:"body"`
	Binary []struct {
		Value       string `xml:",chardata" bson:"value"`
		ContentType string `xml:"content-type,attr" bson:"content-type"`
		ID          string `xml:"id,attr" bson:"id"`
	} `xml:"binary" bson:"binary"`
}

FB2 represents FB2 structure

func (*FB2) UnmarshalCoverpage

func (f *FB2) UnmarshalCoverpage(data []byte)

UnmarshalCoverpage func

type PType

type PType struct {
}

PType embedded fb2 type, represents paragraph

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser struct

func New

func New(data []byte) *Parser

New creates new Parser

func NewReader

func NewReader(data io.Reader) *Parser

NewReader creates new Parser from reader

func (*Parser) CharsetReader

func (p *Parser) CharsetReader(c string, i io.Reader) (r io.Reader, e error)

CharsetReader required for change encodings

func (*Parser) Unmarshal

func (p *Parser) Unmarshal() (result FB2, err error)

Unmarshal parse data to FB2 type

type TextFieldType

type TextFieldType struct {
}

TextFieldType embedded fb2 type, represents text field

type TitleType

type TitleType struct {
	P         []string `xml:"p"`
	EmptyLine []string `xml:"empty-line"`
}

TitleType embedded fb2 type, represents title type fields

Jump to

Keyboard shortcuts

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