 
 	# render page
 	page = page.substr name.length
-	renderPage wiki, page, wrap, (err, html) ->
+	renderPage wiki, page, {wrap:wrap, wiki: wiki}, (err, html) ->
 		return cb err, null if err or not html
 		cb null, html

	langPrefix: 'hljs code '
	highlight: highlight

makePattern = (wiki, page) ->
	dir = wiki.dir.replace /\\/g, '/'
	page = '{index,readme}' if not page
	"#{dir}/#{page}.{md,mkd,markdown}"

# renders page template
renderTemplate = (content, cb) ->

		cb null, html

# renders given markdown file
renderFile = (file, opts, cb) ->
	fs.readFile file, {encoding: 'utf8'}, (err, md) ->
		return cb err, null if err
		dir = path.dirname file
		opts.prefix = dir.substr opts.wiki.dir.length + 1
		opts.prefix = '/' + opts.prefix if opts.prefix
		marked md, {renderer: new Renderer(opts)}, (err, html) ->
			return cb err, null if err
			return renderTemplate html, cb if opts.wrap
			# unwrapped markdown html
			cb null, html

# resolved and renders given wiki page
renderPage = (wiki, page, opts, cb) ->
	page.substr 1 if _.str.startsWith page, '/'
	pattern = makePattern wiki, page
	glob pattern, (err, files) ->
		return cb err, null if err
		renderFile files[0], opts, cb

# wiki page handler
module.exports = (page, wrap, cb) ->
