~dricottone/epub2html

ref: 565f40feaf047541aac49915ddf89afac6d04362 epub2html/xml.go -rw-r--r-- 952 bytes
565f40feDominic Ricottone Initial commit 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Structs for parsing X(HT)?ML files in e-pub archives

package main

import (
	"encoding/xml"
)

type Head struct {
	Title string `xml:"title"`
}

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

type BlockQuote struct {
	Paragraphs  []Paragraph  `xml:"p"`
}

type Division struct {
	Divisions   []Division   `xml:"div"`
	Paragraphs  []Paragraph  `xml:"p"`
	BlockQuotes []BlockQuote `xml:"blockquote"`
}

type Body struct {
	Title    string   `xml:"h3"`
	Division Division `xml:"div"`
}

type Xhtml struct {
	XMLName xml.Name `xml:"html"`
	Head    Head     `xml:"head"`
	Body    Body     `xml:"body"`
}

type Content struct {
	Src string `xml:"src,attr"`
}

type NavPoint struct {
	Label   string  `xml:"navLabel>text"`
	Content Content `xml:"content"`
	Order   int     `xml:"playOrder,attr"`
}

type Ncx struct {
	XMLName   xml.Name   `xml:"ncx"`
	Title     string     `xml:"docTitle>text"`
	NavPoints []NavPoint `xml:"navMap>navPoint"`
}