Added more error handling and necessary functions
This commit is contained in:
12
text.go
12
text.go
@@ -14,17 +14,11 @@ type Text interface {
|
||||
func NewText(textType, content string) (Text, error) {
|
||||
switch textType {
|
||||
case "text", "":
|
||||
return &PlainText{Type: textType, Text: content}, nil
|
||||
return newPlainText(textType, content)
|
||||
case "html":
|
||||
return &PlainText{Type: textType, Text: html.UnescapeString(content)}, nil
|
||||
return newPlainText(textType, html.UnescapeString(content))
|
||||
case "xhtml":
|
||||
return &XHTMLText{
|
||||
Type: textType,
|
||||
XHTMLDiv: &XHTMLDiv{
|
||||
XMLNS: "http://www.w3.org/1999/xhtml",
|
||||
Content: content,
|
||||
},
|
||||
}, nil
|
||||
return newXHTMLText(textType, content)
|
||||
default:
|
||||
return nil, fmt.Errorf("%v is not a valid text type", textType)
|
||||
}
|
||||
|
Reference in New Issue
Block a user