~chrisppy/go-barefeed

ref: 63fc114fd6c8a8779e44c7042a5c1a6f543a76fb go-barefeed/text.go -rw-r--r-- 842 bytes
63fc114fChris Palmer updates from schema 2 months 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
package barefeed

// TextType is an enumerated type for Text
type TextType uint

const (
	// TEXT denotes the text as plain text
	TEXT TextType = iota
	// HTML denotes the text as entity escaped html
	HTML
	// XHTML denotes the text as inline xhtml, wrapped in a div element
	XHTML
)

// Text contains info needed for any text
type Text struct {
	Value    string   `bare:"value"`
	TextType TextType `bare:"textType"`
}

// String converts the enumerated value to a string.  "TEXT" is default.
func (t TextType) String() string {
	switch t {
	case HTML:
		return "HTML"
	case XHTML:
		return "XHTML"
	default:
		return "TEXT"
	}
}

// ToTextType converts a string to the enumerated value.  TEXT is default.
func ToTextType(t string) TextType {
	switch t {
	case "HTML":
		return HTML
	case "XHTML":
		return XHTML
	default:
		return TEXT
	}
}