Skip to content

Conversation

martinthomson
Copy link
Contributor

This warning annoys a lot of people unnecessarily.

The argument that this means that the diagram doesn't stretch is true (it won't stretch), but misleading, because stretching is not a good goal to seek. Diagrams in RFCs often have text, which either becomes too large or too small when stretched. Consequently, the right choice is to set width and height in many cases.

Indeed, the example in RFC 7992 includes width and height (and no viewbox, but that's a separate issue). RFC 7996 does nothing about this. This warning is therefore overreach.

This warning annoys a lot of people unnecessarily.

The argument that this means that the diagram doesn't stretch is true
(it won't stretch), but misleading, because stretching is not a good
goal to seek.  Diagrams in RFCs often have text, which either becomes too large
or too small when stretched.  Consequently, the right choice is to set
width and height in many cases.

Indeed, the example in RFC 7992 includes width and height (and no
viewbox, but that's a separate issue).  RFC 7996 does nothing about
this.  This warning is therefore overreach.
@kesara kesara changed the title Remove warning about SVG width and height feat: Remove warning about SVG width and height Feb 14, 2025
@cabo
Copy link
Contributor

cabo commented Feb 14, 2025

Yes, one of the warnings I regularly silence via:

v3xml2rfc:
  silence:
  - Found SVG with width or height specified

@ajeanmahoney
Copy link
Collaborator

The RPC has struggled with this warning. Removing height and width attributes requires twiddling with the viewbox attribute to get the image to look sorta right, and this is very much a trial-and-error activity. Even if height and width are set, a reader can still make the image smaller or larger by using the zoom tools in the browser, so it's not like these attributes actually prevent scaling.

@martinthomson
Copy link
Contributor Author

That only highlights to me that getting SVG right is tricky (and perhaps in need of clearer guidance). Removing width and height is not going to work in many cases. For instance, I'm not aware of any cases with aasvg where you would want to do that rather than do something else entirely. As Jean notes, zoom tools are probably a better fit from a usability perspective.

@kesara kesara requested a review from rjsparks February 18, 2025 06:03
@@ -926,12 +924,11 @@ def render_artwork(self, h, x):
if not (svgw and svgh):
svgw = float(w)-float(xo)
svgh = float(h)-float(yo)
elif svgw and svgh:
svg.set('viewBox', '0 0 %s %s' % (svgw, svgh))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this is a pre-existing concern, but is overwriting any viewBox that might have been specified in the source the right thing to do?

Getting a good understanding of reasonable ways to use viewport and viewbox in the series I think needs some discussion.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The accessibility experts recommend the following for understanding viewport and viewBox: https://www.sarasoueidan.com/blog/svg-coordinate-systems/
There's also https://stackoverflow.com/questions/15335926/how-to-use-the-svg-viewbox-attribute

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding here is that this is fine. What this does is to ensure that there is a viewBox attribute always and that it follows a fixed syntax.

That is, if it is present, then any commas are removed. (That's arm 1.)

If it is not present, but there is a width and height, then one is added based on that width and height. (That's arm 2.)

Otherwise, it's an error (as it likely would be anyway). (That's arm 3).

There is one problem that I see with this code, which is that width and height are not required to be specified in the default unit of pixels. They can be "auto", any length (e.g., "44pt" or "23em"), or a percentage. Use of those will generate ValueError, which will be caught below. That's a fine choice if it were deliberate. However, it means that specifying width="44px" will be treated as invalid, which isn't ideal.

@kesara kesara merged commit 5810699 into ietf-tools:main Feb 25, 2025
18 of 19 checks passed
@martinthomson martinthomson deleted the svg-warning branch February 26, 2025 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants