fb2

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2021 License: MIT Imports: 5 Imported by: 0

README

fb2

.fb2 parser for GoLang

Documentation

Overview

Package fb2 represent .fb2 format parser

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPFB2

func NewPFB2() prototype.PFB2

func ToPB

func ToPB(target FB2) prototype.PFB2

ToPB converts fb2 to protobuf fb2

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 Binary

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

type Body

type Body struct {
	Sections []Sections `xml:"section" bson:"section"`
	Title    string     `xml:"title"`
	Image    struct {
		Href string `xml:"href,attr" bson:"href"`
	} `xml:"image"`
	Subtitle string `xml:"subtitle"`
}

type Coverpage

type Coverpage struct {
	Image Image `xml:"image,allowempty" bson:"image"`
}

type CustomInfo

type CustomInfo struct {
	InfoType string `xml:"info-type" bson:"info-type"`
}

type Description

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

type DocumentInfo

type 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"`
}

type FB2

type FB2 struct {
	ID          string      `bson:"_id"`
	FictionBook xml.Name    `xml:"FictionBook" bson:"FictionBook"`
	Stylesheet  []string    `xml:"stylesheet" bson:"stylesheet"`
	Description Description `xml:"description" bson:"description"`
	Body        Body        `xml:"body" bson:"body"`
	Binary      []Binary    `xml:"binary" bson:"binary"`
}

FB2 represents FB2 structure

func (*FB2) UnmarshalCoverpage

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

UnmarshalCoverpage func

type Image

type Image struct {
	Href string `xml:"xlink:href,attr" bson:"href"`
}

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 ProtoFB2

type ProtoFB2 proto.PFB2

ProtoFB2 type

type PublishInfo

type 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"`
}

type Sections

type Sections struct {
	P     []string `xml:"p" bson:"p"`
	Title Title    `xml:"title"`
	Image struct {
		Href string `xml:"href,attr" bson:"href"`
	} `xml:"image"`
	Subtitle string `xml:"subtitle"`
}

type TextFieldType

type TextFieldType struct {
}

TextFieldType embedded fb2 type, represents text field

type Title

type Title struct {
	P []string `xml:"p"`
}

type TitleInfo

type 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  Coverpage    `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"`
}

type TitleType

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

TitleType embedded fb2 type, represents title type fields

Directories

Path Synopsis
Package fb2 is a generated protocol buffer package.
Package fb2 is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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