   compile: (input,cb) ->
     async.waterfall [
       @renderhbs.bind(@,input)
-      @renderMarkedDown.bind(@)
+      (input,cb) =>
+        sync (=>
+          @renderMarkedDown(input)
+        ), cb
       @applyTransforms.bind(@)
     ], cb
 

    pipe = async.compose.apply(@,TRANSFORMERS)
    pipe(this,input,cb)

  renderMarkedDown: (input,cb) ->
    renderer = new marked.Renderer()
    idfy = (str) -> _s.dasherize(str.toLowerCase())
    renderer.header = (text,level) ->
      "<h#{level} id='#{idfy(text)}'>#{text}</h#{level}>"
    renderer.blockcode = (code,lang) =>
      console.log "doing highlight"
      result = highlight(code,lang,@hbs)
      "<pre><code>#{result}</pre></code>"
    marked input, {
      renderer: renderer
      }, cb

module.exports = TemplateCompiler

marked = require 'marked'

# highlight = require "./highlight"
async = require 'async'
sync = require 'sync'
hbs = require("handlebars")
_s = require "underscore.string"

SourceFormatter = require "./source-formatter"

# Add the root parameter to helper options when it is invoked.
# @param root (Path) the root path for template compilation
