   else
     'xlink:href'
 
+maybeWrite = (filename, data) ->
+  ## Writes data to filename, unless the file is already identical to data.
+  ## Returns whether the write actually happened.
+  try
+    if data == fs.readFileSync filename, encoding: 'utf8'
+      return false
+  fs.writeFileSync filename, data
+  true
+
 class Drawing extends Input
   hrefAttr: -> hrefAttr @settings
   load: (data) ->

      if (outputDir = @getOutputDir '.svg')?
        filename.dir = outputDir
      filename = path.format filename
    console.log '->', filename
    fs.writeFileSync filename, @renderSVG mappings, styles
    filename
  renderSVGDOM: (mappings, styles) ->
    ###
    Main rendering engine, returning an xmldom object for the whole document.

          filenames = input.writeSVG mappings, styles
          input.writeTeX() if settings.texText
          ## Convert to any additional formats
          if filenames? and filenames.length
            convert filenames, formats, settings
        else if input instanceof SVGFile
          convert input.filename, formats, settings
  unless files
