コード例 #1
0
 public static function capture_replace_pre($capture, $original, $id, $is_inline, $wp_content, $args = array())
 {
     $code = $capture['code'];
     $oldAtts = $capture['atts'];
     $newAtts = array();
     $encode = isset($args['encode']) ? $args['encode'] : FALSE;
     if (!isset($oldAtts[CrayonSettings::DECODE]) && $encode) {
         // Encode the content, since no decode information exists.
         $code = CrayonUtil::htmlentities($code);
     }
     // We always set decode=1 irrespectively - so at this point the code is assumed to be encoded
     $oldAtts[CrayonSettings::DECODE] = TRUE;
     $newAtts['class'] = CrayonUtil::html_attributes($oldAtts, CrayonGlobalSettings::val_str(CrayonSettings::ATTR_SEP), '');
     return str_replace($original, CrayonUtil::html_element('pre', $code, $newAtts), $wp_content);
 }
コード例 #2
0
 public static function plain_code($code, $encoded = TRUE)
 {
     if (is_array($code)) {
         // When used as a preg_replace_callback
         $code = $code[1];
     }
     if (!$encoded) {
         $code = CrayonUtil::htmlentities($code);
     }
     if (CrayonGlobalSettings::val(CrayonSettings::TRIM_WHITESPACE)) {
         $code = trim($code);
     }
     return '<pre class="crayon-plain-tag">' . $code . '</pre>';
 }