public static function format_code($code, $language, $hl = NULL)
 {
     // Ensure the language is defined
     if ($language != NULL && $hl->is_highlighted()) {
         $code = self::clean_code($code, FALSE, FALSE, FALSE, TRUE);
         /* Perform the replace on the code using the regex, pass the captured matches for
         		 formatting before they are replaced */
         try {
             CrayonParser::parse($language->id());
             // Match language regex
             $elements = $language->elements();
             $regex = $language->regex();
             if (!empty($regex) && !empty($elements)) {
                 // Get array of CrayonElements
                 self::$elements = array_values($elements);
                 $code = preg_replace_callback($regex, 'CrayonFormatter::format_match', $code);
             }
         } catch (Exception $e) {
             $error = 'An error occured when formatting: ' . $e->message();
             $hl ? $hl->log($error) : CrayonLog::syslog($error);
         }
         return $code;
     } else {
         return self::clean_code($code, TRUE, TRUE, TRUE, TRUE);
     }
 }