 
       # If we reached the end of a multiline comment,
       # set inMulti to false and reset multiAccum
-      if line.match(language.multi_end_matcher)
+      if lang.checkType(line) is 'multiend'
         inMulti = no
         docs = multiAccum
         multiAccum = ''
 
     # Single line comment
-    else if line.match(language.comment_matcher) and not line.match(language.comment_filter)
+    else if lang.checkType(line) is 'single'
       if hasCode
-        save docs, code
-        hasCode = docs = code = ''
-      docs += line.replace(language.comment_matcher, '') + '\n'
+        hasCode = no
+        sections.push { docs: marked(docs), code }
+        docs = code = ''
+      docs += lang.filter(line) + '\n'
 
     # Code
     else

_      = require 'underscore'
walk   = require 'walk'

marked.setOptions sanitize: false

# Generate the documentation for a source file by reading it in, splitting it
# up into comment/code sections, and merging them into an HTML template.
generateDocumentation = (sourceFile, context, cb) ->
  fs.readFile sourceFile, "utf-8", (err, code) ->
    throw err if err
    sections = makeSections get_language(sourceFile), code
    generate_source_html sourceFile, context, sections
    cb()

# Given a string of source code, find each comment and the code that
# follows it, and create an individual **section** for the code/doc pair.
makeSections = (language, data) ->
  
  lines = data.split '\n'
  

  inMulti = no
  hasCode = no

  for line in lines

    # Multi line comment
    if lang.checkType(line) is 'multistart' or inMulti

      ## Start of a new section, save the old section
      if hasCode
        sections.push { docs: marked(docs), code }
        docs = code = ''
        hasCode = no

