9 Improvements to SVG Export
The 3 Features:
1) For each <path> and <polyline> element: an attribute indicating the element type. The value is an Element::Type cast as an integer. For example:
The "data-" prefix is a recommended practice for custom SVG attributes. I achieved this functionality by adding a function SvgGenerator::setElement(const Element* e). This sets a variable that the code can use when writing the SVG file.
2) Remove the group element wrappers (<g>) around everything. Each path and polyline element is separated by a newline and that's it. With the "data-type" as the first attribute specified you can see the element types sorted in Element::Type enumeration order. The purpose of this is mainly to improve the readability of the .svg file by removing unnecessary elements.
3) If an attribute value is the same as the SVG default value, omit that attribute from the element in the file. This reduces the file size for any score where the notation is black, for example, because the default for the SVG "fill" attribute is black. This also improves file readability, IMO.
I've attached two sample files, one is exported from MuseScore 2.0.2 (current release version), the other includes these 3 "improvements". You'll notice that the "improved" file has approximately 1/10th the number of lines as the 2.0.2 version.
Note that the code distinguishes between System and Measure bar lines. This causes the appearance of data-type="74" mixed in with data-type="6" in the exported file. 74 is Element::Type::SYSTEM, 6 is Element::Type::BAR_LINE