As a feature, my final objective would be the ability to typeset the
snippets into a vector format, as the resolution's better and it takes up
In order for the goal to be eventually reached, cropping would have to be
native to lilypond. Right now, there is no cropping for SVGs. Each
generated SVG is the size of the page, through the height, width, and
0 119.5016 169.0094" attributes.
With individual snippets I've typeset into SVG, I've been taking the
bounding box and using that as the viewBox; modifying the snippets with
var svg = document.getElementsByTagName("svg");
var box = svg.getBBox();
var viewBox = [box.x, box.y, box.width, box.height].join(" ");
However, I don't think it's a very good solution; finding that such
functionality should be built-in to lilypond, and not require the use of
In the MediaWiki extension, I've been trying to find a way, and the feature
request is being tracked: https://phabricator.wikimedia.org/T49578. Making
the extension output SVG is no problem (just change the backend on the
lilypond command), but cropping is. I believe that the Lilypond project
would be more suited to handle and incorporate this proposed feature, and
could potentially be useful when outputting PNG too. A flag could be added
to the command if cropping is desired.
Thank you for considering my feature request. This would not only help me,
but make Lilypond more flexible for typesetting music.