public static function highlight($code) { $crayon_str = ''; $captures = CrayonWP::capture_crayons(0, $code); $the_captures = $captures['capture']; $the_content = $captures['content']; foreach ($the_captures as $capture) { $id = $capture['id']; $atts = $capture['atts']; $no_enqueue = array(CrayonSettings::ENQUEUE_THEMES => FALSE, CrayonSettings::ENQUEUE_FONTS => FALSE); $atts = array_merge($atts, $no_enqueue); $code = $capture['code']; $crayon = CrayonWP::shortcode($atts, $code, $id); $crayon_formatted = $crayon->output(TRUE, FALSE); $the_content = CrayonUtil::preg_replace_escape_back(self::regex_with_id($id), $crayon_formatted, $the_content, 1, $count); } return $the_content; }
public static function highlight($code, $add_tags = FALSE) { $captures = CrayonWP::capture_crayons(0, $code); $the_captures = $captures['capture']; if (count($the_captures) == 0 && $add_tags) { // Nothing captured, so wrap in a pre and try again $code = '<pre>' . $code . '</pre>'; $captures = CrayonWP::capture_crayons(0, $code); $the_captures = $captures['capture']; } $the_content = $captures['content']; foreach ($the_captures as $id => $capture) { $atts = $capture['atts']; $no_enqueue = array(CrayonSettings::ENQUEUE_THEMES => FALSE, CrayonSettings::ENQUEUE_FONTS => FALSE); $atts = array_merge($atts, $no_enqueue); $code = $capture['code']; $crayon = CrayonWP::shortcode($atts, $code, $id); $crayon_formatted = $crayon->output(TRUE, FALSE); $the_content = CrayonUtil::preg_replace_escape_back(self::regex_with_id($id), $crayon_formatted, $the_content, 1, $count); } return $the_content; }
public static function highlight($code) { $crayon_str = ''; $captures = CrayonWP::capture_crayons(0, $code); $captures = $captures['capture']; foreach ($captures as $capture) { $id = $capture['id']; $atts = $capture['atts']; $no_enqueue = array(CrayonSettings::ENQUEUE_THEMES => FALSE, CrayonSettings::ENQUEUE_FONTS => FALSE); $atts = array_merge($atts, $no_enqueue); $content = $capture['code']; $crayon = CrayonWP::shortcode($atts, $content, $id); $crayon_formatted = $crayon->output(TRUE, FALSE); $crayon_str .= $crayon_formatted; } return $crayon_str; }