diff --git a/inlineTextContent.go b/inlineTextContent.go index 8365292..73dd477 100644 --- a/inlineTextContent.go +++ b/inlineTextContent.go @@ -8,8 +8,8 @@ import ( type InlineTextContent struct { *CommonAttributes - Type string `xml:"type,attr,omitempty"` // Must be text or html - Texts []string `xml:",chardata"` + Type string `xml:"type,attr,omitempty"` // Must be text or html + Text string `xml:",chardata"` } // newInlineTextContent creates a new InlineTextContent. It returns a @@ -19,23 +19,11 @@ func newInlineTextContent(mediaType string, content any) (*InlineTextContent, er return nil, fmt.Errorf("media type %v incompatible with inline text content", mediaType) } - texts := make([]string, 0) - - t := reflect.TypeOf(content) - switch t.Kind() { - case reflect.Slice: - if t.Elem().Kind() == reflect.String { - for _, t := range content.([]string) { - texts = append(texts, t) - } - } - case reflect.String: - texts = append(texts, content.(string)) - default: + if reflect.TypeOf(content).Kind() != reflect.String { return nil, fmt.Errorf("content type %T incompatible with inline text content", content) } - return &InlineTextContent{Type: mediaType, Texts: texts}, nil + return &InlineTextContent{Type: mediaType, Text: content.(string)}, nil } // isContent checks whether the InlineTextContent is a Content. It returns a