~dricottone/epub2html

ref: ae806b4144a63817e5a1a9c3448540314e2e77ce epub2html/textnodes.go -rw-r--r-- 818 bytes
ae806b41Dominic Ricottone Fixing blockquotes and refactoring 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
// Structs for handling text nodes

package main

import (
	"encoding/xml"
)

// Text nodes are either a paragraph or a blockquote.
type TextNode interface {
	Order() int
}

// A paragraph contains character data and other text-oriented tags, such as
// b or strong. This data should be retained as raw XML.
type Paragraph struct {
	XMLName xml.Name `xml:"p"`
	Text    string   `xml:",innerxml"`
	order   int      `xml:"-"`
}

func (p Paragraph) Order() int {
	return p.order
}

// A blockquote contains paragraphs. Unlike divisions, the blockquote structure
// must be maintained in order to format the paragraphs correctly.
type BlockQuote struct {
	XMLName    xml.Name    `xml:"blockquote"`
	Paragraphs []Paragraph `xml:"p"`
	order      int         `xml:"-"`
}

func (b BlockQuote) Order() int {
	return b.order
}