mozman / svgwrite

Python Package to write SVG files (UNMAINTAINED)
Other
543 stars 97 forks source link

save method of Drawing is producing svg without newline at file end #103

Open linuxrider opened 2 years ago

linuxrider commented 2 years ago

The save method of Drawing is producing svg file without newline at the end of the file which can be problematic on linux. It generates a file with newline at the end when pretty is set to true, however. Is this intended behavior?

dwg = svgwrite.Drawing('no_newline.svg', profile='tiny')
dwg.save()

no_newline.svg

<?xml version="1.0" encoding="utf-8" ?>
<svg baseProfile="tiny" height="100%" version="1.2" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink"><defs /></svg>
dwg2 = svgwrite.Drawing('newline.svg', profile='tiny')
dwg2.save(pretty=True)

newline.svg

<?xml version="1.0" encoding="utf-8" ?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink" baseProfile="tiny" height="100%" version="1.2" width="100%">
  <defs/>
</svg>