Skip to content

Commit

Permalink
Merge pull request #7 from WindowsSov8forUs/master
Browse files Browse the repository at this point in the history
add: 添加扩展元素构造函数
  • Loading branch information
WindowsSov8forUs authored Jun 19, 2024
2 parents 63a4f1a + e541770 commit 1c41123
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/message/message_element_extend.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,17 @@ func (e *MessageElementExtend) Parse(n *html.Node) (MessageElement, error) {
return result, nil
}

func NewMessageElementExtend(tag string, attrs map[string]string, children ...MessageElement) MessageElement {
result := &MessageElementExtend{
tag: tag,
}
for key, value := range attrs {
result.ExtendAttributes = result.AddAttribute(key, value)
}
result.ChildrenMessageElement = &ChildrenMessageElement{
children: children,
}
return result
}

var ExtendParser = &MessageElementExtend{}

0 comments on commit 1c41123

Please sign in to comment.