Skip to content

Commit 5810699

Browse files
feat: Remove warning about SVG width and height (#1225)
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.
1 parent 2639a00 commit 5810699

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Diff for: xml2rfc/writers/html.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,6 @@ def render_artwork(self, h, x):
916916
vbox = svg.get('viewBox')
917917
svgw = maybefloat(svg.get('width'))
918918
svgh = maybefloat(svg.get('height'))
919-
if svgw or svgh:
920-
self.warn(x, "Found SVG with width or height specified, which will make the artwork not scale. Specify a viewBox only to let the artwork scale.")
921919
try:
922920
if vbox:
923921
xo,yo,w,h = re.split(',? +', vbox.strip('()'))
@@ -926,12 +924,11 @@ def render_artwork(self, h, x):
926924
if not (svgw and svgh):
927925
svgw = float(w)-float(xo)
928926
svgh = float(h)-float(yo)
927+
elif svgw and svgh:
928+
svg.set('viewBox', '0 0 %s %s' % (svgw, svgh))
929929
else:
930-
if svgw and svgh:
931-
svg.set('viewBox', '0 0 %s %s' % (svgw, svgh))
932-
else:
933-
self.err(x, "Cannot place SVG properly when neither viewBox nor width and height is available")
934-
return None
930+
self.err(x, "Cannot place SVG properly when neither viewBox nor width and height is available")
931+
return None
935932
except ValueError as e:
936933
self.err(x, "Error when calculating SVG size: %s" % e)
937934
imgw = 660 if self.options.image_svg else 724

0 commit comments

Comments
 (0)