Apply a direct scale to the provided SVG markup by inserting a <g transform="scale(...)">
around the SVG contents and multiplying simple numeric width/height attributes when present.
It also adjusts a viewBox attributeβs width/height so that SVGs that rely on viewBox
sizing are not cropped after applying the transform.
Given an SVG and a candidate scale, determine the final scale so that the
rendered image does not exceed the specified maximum ratio of the provided page width/height. The
function returns a scale that is at most candidate_scale.