question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing <?xml - SVG files are XML files

See original GitHub issue

Please consider adding <?xml version="1.0" encoding="UTF-8" standalone="no"?> to downloaded files. The standard says: https://www.w3.org/TR/SVG11/struct.html#NewDocument

SVG-s copied to the clipboard could remain the way they are as people tend to paste them into HTML source code.

Thank you!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
TrySoundcommented, Aug 30, 2021

SVGO is an Optimizer. xml instruction is not necessary to use .svg files in many environments. If you need to add somethinng use svgo package directly and write custom plugin like this

const addXmlInstructionPlugin = {
  type: 'visitor',
  name: 'add-xml-instruction',
  fn: () => {
    let hasXmlInstruction = false;
    return {
      instruction: {
        enter: node => {
          if (node.name === 'xml') {
            hasXmlInstruction = true;
          }
        }
     },
      root: {
        exit: node => {
          if (hasXmlInstruction === false) {
            node.children.push({
              type: 'instruction',
              name: 'xml',
              value: 'version="1.0" encoding="utf-8"',
            })
          }
        }
      }
    }
  }
}
0reactions
szepeviktorcommented, Aug 30, 2021

Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SVG Export Missing XML Encoding Tag
In Illustrator: Use the "Export As" option. See screen cap for options selection. Once exported, open the SVG file in a text editor...
Read more >
Why does SVG upload in Media Library fail if the file ...
So if your SVG file is not being detected as image/svg+xml , then this is because PHP doesn't recognise it as an SVG...
Read more >
Why do some .svg files have file type “XML” (with no ...
svg files have file type “XML” (with no preview) instead of “Image”? Some .svg files have previews, and others don't. I'd like them...
Read more >
Missing XML header for .svg files · Issue #113
svg files, it needs the XML header to be able to render it. I have created two .svg diagram, one with plugin, one...
Read more >
SVG File Shows XML Code Instead Of Image
SVG File Shows XML Code Instead Of Image · How are you trying to display the image? · Its like this which works...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found