diff --git a/elements.gen.go b/elements.gen.go index 4736dc8..e9f9b53 100644 --- a/elements.gen.go +++ b/elements.gen.go @@ -6574,6 +6574,43 @@ func (e *RectElement) MarshalXML(encoder *xml.Encoder, _ xml.StartElement) error return encodeElement(encoder, "rect", e.attrs, e.children) } +// A StyleElement is a style element. +type StyleElement struct { + attrs map[string]AttrValue + children []Element +} + +// Style returns a new StyleElement. +func Style(children ...Element) *StyleElement { + return &StyleElement{ + attrs: map[string]AttrValue{}, + children: children, + } +} + +// AppendChildren appends the given children. +func (e *StyleElement) AppendChildren(children ...Element) *StyleElement { + e.children = append(e.children, children...) + return e +} + +// Children sets the children. +func (e *StyleElement) Children(children ...Element) *StyleElement { + e.children = children + return e +} + +// Type sets the type attribute. +func (e *StyleElement) Type(_type String) *StyleElement { + e.attrs["type"] = _type + return e +} + +// MarshallXML implements encoding/xml.Marshaller.MarshalXML. +func (e *StyleElement) MarshalXML(encoder *xml.Encoder, _ xml.StartElement) error { + return encodeElement(encoder, "style", e.attrs, e.children) +} + // A SwitchElement is a switch element. type SwitchElement struct { attrs map[string]AttrValue diff --git a/elements.yaml b/elements.yaml index 7d2e839..2f1c930 100644 --- a/elements.yaml +++ b/elements.yaml @@ -327,6 +327,13 @@ elements: - name: ry exportedGoName: RY +- name: style + container: true + attributes: + - name: type + goName: _type + exportedGoName: Type + - name: switch container: true attributeGroups: diff --git a/svg_test.go b/svg_test.go index 0627633..7387ed3 100644 --- a/svg_test.go +++ b/svg_test.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "slices" + "strings" "testing" "github.com/alecthomas/assert/v2" @@ -347,7 +348,7 @@ func normalizedXMLTokens(data []byte) ([]any, error) { var normalizedToken any switch token := token.(type) { case xml.CharData: - normalizedToken = string(token) + normalizedToken = string(bytes.TrimSpace(token)) case xml.StartElement: slices.SortFunc(token.Attr, func(a, b xml.Attr) int { return cmp.Or( diff --git a/testdata/cubic01.svg b/testdata/cubic01.svg new file mode 100644 index 0000000..de847d9 --- /dev/null +++ b/testdata/cubic01.svg @@ -0,0 +1,29 @@ + + + Example cubic01- cubic Bézier commands in path data + Picture showing a simple example of path data using both a "C" and an "S" command, along with annotations showing the control points and end points + + + + + + + + + + + + + + + M100,200 C100,100 250,100 250,200 + S400,300 400,200 + \ No newline at end of file