Skip to content

use href not resolved correctly #12

@Merovius

Description

@Merovius

If I take the example of use from MDN Network and try to parse it using giosvg, I get an error:

package main

import (
	"fmt"
	"strings"

	"github.com/inkeliz/giosvg"
)

func main() {
	_, err := giosvg.NewVectorReader(strings.NewReader(svg))
	fmt.Println(err)
}

var svg = `<svg viewBox="0 0 30 10" xmlns="http://www.w3.org/2000/svg">
  <circle id="myCircle" cx="5" cy="5" r="4" stroke="blue" />
  <use href="#myCircle" x="10" fill="blue" />
  <use href="#myCircle" x="20" fill="white" stroke="red" />
</svg>`

This prints href ID in use statement was not found in saved defs.

From what I understand, the issue is that giosvg assumes that only those elements appearing in a <def> element can be referenced by use, which the example disagrees with. I ran into this with a real SVG.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions