 
 help = ->
   console.log """
-svgtiler #{metadata.version ? "(web)"}
+svgtiler #{metadata.version}
 Usage: #{process.argv[1]} (...options and filenames...)
 Documentation: https://github.com/edemaine/svgtiler
 

else
  DOMParser = window.DOMParser # escape CoffeeScript scope
  domImplementation = document.implementation
  path =
    extname: (x) -> /\.[^/]+$/.exec(x)[0]
    dirname: (x) -> /[^]*\/|/.exec(x)[0]

SVGNS = 'http://www.w3.org/2000/svg'
XLINKNS = 'http://www.w3.org/1999/xlink'

    for level in levelOrder
      for node in levels[level]
        svg.appendChild node
    svg.setAttribute 'viewBox', viewBox.join ' '
    svg.setAttribute 'width', @width = viewBox[2]
    svg.setAttribute 'height', @height = viewBox[3]
    svg.setAttribute 'preserveAspectRatio', 'xMinYMin meet'
    doc
  renderSVG: (mappings, styles) ->
    out = new XMLSerializer().serializeToString @renderSVGDOM mappings, styles
    ## Parsing xlink:href in user's SVG fragments, and then serializing,
    ## can lead to these null namespace definitions.  Remove.
    out = out.replace /\sxmlns:xlink=""/g, ''
    if prettyXML?
      out = prettyXML out,
        newline: '\n'  ## force consistent line endings, not require('os').EOL
    '''
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
