Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Viewer does not support full SVG 1.1" added to image during optimization #1410

Closed
michaeljmcd opened this issue Mar 8, 2021 · 8 comments · Fixed by #1747
Closed

"Viewer does not support full SVG 1.1" added to image during optimization #1410

michaeljmcd opened this issue Mar 8, 2021 · 8 comments · Fixed by #1747
Labels

Comments

@michaeljmcd
Copy link

Describe the bug
When I run an SVG 1.1 document through svgo (version 2.2.1 installed via yarn global), I get the text "Viewer does not support full SVG 1.1" added to the bottom of the image. I don't see anything else wrong with the image. Checking the output SVG source shows that the text is added by svgo, not the viewer.

To Reproduce
Steps to reproduce the behavior:

  1. Use diagrams.net / draw.io to create a simple diagram.
  2. Export the image to SVG with default settings.
  3. Run svgo my.svg -o my2.svg
  4. View the resulting image.

Expected behavior

Assuming that the warning is legitimate, I would expect it to either appear on stdout or else to fail processing and be on stderr. Showing up silently on the output image was unexpected.

Screenshots

image

Desktop (please complete the following information):

  • SVGO Version - 2.2.1
  • NodeJs Version - 15.10.0
  • OS: MacOS Catalina 10.15.7
@michaeljmcd michaeljmcd added the bug label Mar 8, 2021
@TrySound
Copy link
Member

TrySound commented Mar 8, 2021

Hi, could you please submit svg file here?

@TrySound
Copy link
Member

TrySound commented Mar 9, 2021

Alright, I see the problem

@michaeljmcd
Copy link
Author

Good deal - do you still need that SVG file?

@TrySound
Copy link
Member

TrySound commented Mar 9, 2021

You can submit one in case service will be unavailable

@acalvo
Copy link

acalvo commented Sep 27, 2022

For anyone else hitting this problem:

draw.io graphs are generated with this piece of code:

<switch>
  <g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/>
  <a transform="translate(0,-5)" xlink:href="[https://www.diagrams.net/doc/faq/svg-export-text-problems](view-source:https://www.diagrams.net/doc/faq/svg-export-text-problems)" target="_blank">
    <text text-anchor="middle" font-size="10px" x="50%" y="100%">Viewer does not support full SVG 1.1</text>
  </a>
</switch>

And SVGO's removeEmptyContainers plugin strips out the g tag, making the message appear unconditionally.

The workaround, until that plugin deals with this case, is to disable it through config. I.e.:

module.exports = {
    plugins: [
      {
        name: 'preset-default',
        params: {
          overrides: {
            removeEmptyContainers: false,
          },
        },
      },
    ],
  };

@vincentbernat
Copy link
Contributor

This seems easy to fix: check if parentNode tag is switch and don't remove the container if it is.

@SethFalco
Copy link
Member

This seems easy to fix: check if parentNode tag is switch and don't remove the container if it is.

Thanks for investigating this and opening a PR. I'll review it soon and get it merged.
Just writing a note for how to approach this.

I was checking if we should really skip if the parent is a <switch>, or if instead we should only skip if any of the requiredFeatures, requiredExtensions, or systemLanguage attributes are present.

Indeed, I think the best solution is to check if the parent is a <switch> though, as it is valid for a <switch> to contain an empty <g/> with no attributes, which will render nothing. Removing that would affect the rendering of the SVG.

It could also be worth updating Remove Hidden Elements to delete the <switch> entirely if the first node doesn't contain a conditional attribute and is a non-rendering element. I'll look into this separately, though.

SethFalco pushed a commit to vincentbernat/svgo that referenced this issue Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants