  'Wallapatta.File'
  'Wallapatta.Paginate'
  'Wallapatta.Toc'
+ 'Wallapatta.Parser'
  'Weya'
- (jsdom, fs, YAML, path, FileRender, Paginate, Toc, 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
+   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
+   if FS.existsSync css
     commands.push "rm -r #{css}"
-   if fs.existsSync lib
+   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}"
+    "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) ->

     book.chapters

   for toc in book.toc
    tocTemplate = path.resolve __dirname,
                               path.resolve cwd, toc.template

    opt =
     chapters: book.chapters

   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

#Render file
  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

#Render book
  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
