 
    copyStatic options, callback
 
+#Render
+
+  exports.render = (content, callback) ->
+   parser = new Parser text: content
+   JSDOWM.env '<div id="main"></div><div id="sidebar"></div>', (err, window) ->
+    Weya.setApi document: window.document
+    main = window.document.getElementById 'main'
+    sidebar = window.document.getElementById 'sidebar'
+    render = parser.getRender()
+    render.render main, sidebar
+    callback
+     main: main.innerHTML
+     sidebar: sidebar.innerHTML
+
+
 
 Mod.initialize()

   for article in list
    opt =
     template: options.template
     output: path.resolve options.output, "#{article.id}.html"
    opt[k] = v for k, v of article
    opt.file = path.resolve options.cwd, article.file
    FileRender opt

    renderChapters options, article.content

  exports.file = (options, callback) ->
   FileRender
    file: options.file
    template: path.resolve __dirname, options.template
    output: path.resolve options.output, "index.html"
    title: options.title

   copyStatic options, callback

  exports.book = (options, callback) ->
   book = YAML.parse "#{fs.readFileSync options.book}"
   cwd = path.dirname options.book
   if book.articleTemplate?
    articleTemplate =
     path.resolve __dirname,
                  path.resolve cwd, book.articleTemplate
    renderChapters
     cwd: cwd
     output: options.output

 'Wallapatta.File'
 'Wallapatta.Paginate'
 'Wallapatta.Toc'
 'Wallapatta.Parser'
 'Weya'
 (JSDOM, FS, YAML, PATH, FileRender, Paginate, Toc, Parser, Weya) ->

#Copy Static files
  exports.copyStatic = copyStatic = (options, callback) ->
   if not options.static?
    callback()
    return

   commands = []
   js = PATH.resolve options.output, 'js'
   css = PATH.resolve options.output, 'css'
   lib  = PATH.resolve options.output, 'lib'
   if FS.existsSync js
    commands.push "rm -r #{js}"
   if FS.existsSync css
    commands.push "rm -r #{css}"
   if FS.existsSync lib
    commands.push "rm -r #{lib}"

   commands = commands.concat [
    "mkdir #{js}"
    "mkdir #{css}"
    "mkdir #{lib}"
    "cp -r #{PATH.resolve __dirname, 'build/js/*'} #{js}"
    "cp -r #{PATH.resolve __dirname, 'build/css/*'} #{css}"
    "cp -r #{PATH.resolve __dirname, 'build/lib/*'} #{lib}"
   ]

   exec commands.join('&&'), (e, stderr, stdout) ->
