public function process() { $tmr = new CrayonTimer(); $this->runtime = NULL; if ($this->needs_load) { $tmr->start(); $this->load(); $this->runtime[CRAYON_LOAD_TIME] = $tmr->stop(); } if (!empty($this->error) || empty($this->code)) { // Disable highlighting for errors and empty code return; } if ($this->language === NULL) { $this->language_detect(); } if ($this->needs_format) { $tmr->start(); try { // Parse before hand to read modes $code = $this->code; // If inline, then combine lines into one if ($this->is_inline) { $code = preg_replace('#[\\r\\n]+#ms', '', $code); if ($this->setting_val(CrayonSettings::TRIM_WHITESPACE)) { $code = trim($code); } } // Decode html entities (e.g. if using visual editor or manually encoding) if ($this->setting_val(CrayonSettings::DECODE)) { $code = CrayonUtil::html_entity_decode($code); } // Save code so output is plain output is the same $this->code = $code; // Allow mixed if langauge supports it and setting is set CrayonParser::parse($this->language->id()); if (!$this->setting_val(CrayonSettings::MIXED) || !$this->language->mode(CrayonParser::ALLOW_MIXED)) { // Format the code with the generated regex and elements $this->formatted_code = CrayonFormatter::format_code($code, $this->language, $this); } else { // Format the code with Mixed Highlighting $this->formatted_code = CrayonFormatter::format_mixed_code($code, $this->language, $this); } } catch (Exception $e) { $this->error($e->message()); return; } $this->needs_format = FALSE; $this->runtime[CRAYON_FORMAT_TIME] = $tmr->stop(); } }