   '.rb':     {name: 'ruby',          symbol: '#'}
 }
 
-# The language object, containing the appropriate matchers and delimiters for
-# for the current sourcefile's language.
-language: null
-
-# Set the current language we're documenting, based on the extension.
-set_language: (source) ->
-  l: language: languages[path.extname(source)]
+# Build out the appropriate matchers and delimiters for each language.
+for ext, l of languages
 
   # Does the line begin with a comment?
   l.comment_matcher: new RegExp('^\\s*' + l.symbol + '\\s?')

  # The mirror of `divider_text` that we expect Pygments to return. We can split
  # on this to recover the original sections.
  l.divider_html: new RegExp('\\n*<span class="c1">' + l.symbol + 'DIVIDER<\\/span>\\n*')

# Compute the destination HTML path for an input source file path. If the source
# is `lib/example.coffee`, the HTML will be at `docs/example.html`

# marker comments between each section and then splitting the result string
# wherever our markers occur.
highlight: (source, sections, callback) ->
  language: get_language source
  pygments: process.createChildProcess 'pygmentize', ['-l', language.name, '-f', 'html']
  output: ''
  pygments.addListener 'error',  (error)  ->
