go-epub icon indicating copy to clipboard operation
go-epub copied to clipboard

The property "svg" should be declared in the OPF file

Open neclepsio opened this issue 1 year ago • 2 comments

If I add an <svg> tag to a section, the validator returns this error:

ERROR(OPF-014): prova.epub/EPUB/xhtml/section0001.xhtml(-1,-1): The property "svg" should be declared in the OPF file.

That is, in package.opf there shoud be properties="svg" in the item tag:

    <item id="section0001.xhtml" href="xhtml/section0001.xhtml" media-type="application/xhtml+xml" properties="svg"></item>

I found no way to do it.

Thank you.

neclepsio avatar Aug 26 '24 20:08 neclepsio

Hi can you please send a html code example that this error happen in it. or even better exact go code so i can reproduce that. Thanks

Monirzadeh avatar Aug 27 '24 12:08 Monirzadeh

func main() {
	e, _ := epub.NewEpub("Prova")
	
	section1Body := `<h1>Section 1</h1>
<p><svg xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"
	id="p001" viewBox="0 0 400 400">

  <g>
    <rect x="0" y="0" width="20" height="20" />
  </g>
</svg></p>`

	_, _ = e.AddSection(section1Body, "Section 1", "", "")

	_ = e.Write("prova.epub")
}

neclepsio avatar Aug 27 '24 13:08 neclepsio