当前位置: 首页>>代码示例>>PHP>>正文


PHP GeSHi::highlight_lines_extra方法代码示例

本文整理汇总了PHP中GeSHi::highlight_lines_extra方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::highlight_lines_extra方法的具体用法?PHP GeSHi::highlight_lines_extra怎么用?PHP GeSHi::highlight_lines_extra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GeSHi的用法示例。


在下文中一共展示了GeSHi::highlight_lines_extra方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: main

 /**
  * The main method of the Plugin
  *
  * @param	string		$content: The PlugIn content
  * @param	array		$conf: The PlugIn configuration
  * @return	The content that is displayed on the website
  */
 function main($content, $config)
 {
     if (!t3lib_extMgm::isLoaded('geshilib')) {
         return "Geshi library not loaded";
     }
     // get content
     $this->pi_initPIflexForm();
     $config['content.']['lang'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'cLang', 'sVIEW');
     $config['content.']['code'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'cCode', 'sVIEW');
     $config['content.']['highlight'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'cHighlight', 'sOPTIONS');
     $config['content.']['startnumber'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'cStartnumber', 'sOPTIONS');
     // init geshi library
     $this->geshi = new GeSHi($config['content.']['code'], $config['content.']['lang']);
     // defaults
     $this->geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
     // set highlighted lines
     if ($config['content.']['highlight'] !== '') {
         $this->geshi->highlight_lines_extra(split(',', $config['content.']['highlight']));
     }
     // set startnumber
     if (isset($config['content.']['startnumber'])) {
         $this->geshi->start_line_numbers_at($config['content.']['startnumber']);
     }
     // style
     if (isset($config['default.'])) {
         $this->_styleSubjects($config['default.']);
     }
     if (isset($config[$config['content.']['lang'] . '.'])) {
         $this->_styleSubjects($config[$config['content.']['lang'] . '.']);
     }
     // external stylesheets
     if (isset($config['global.']['external']) && $config['global.']['external'] == 0) {
         // do not use external style sheets
     } else {
         // mtness.net modification: I love stylesheets!
         $this->geshi->enable_classes();
         // Echo out the stylesheet for this code block And continue echoing the page
         $this->geshiCSS = '<style type="text/css"><!--' . $this->geshi->get_stylesheet() . '--></style>';
         // additional headerdata to include the styles
         $GLOBALS['TSFE']->additionalHeaderData['sema_sourcecode:' . $config['content.']['lang']] = $this->geshiCSS;
     }
     // xhtml compliance
     if (isset($config['global.']['xhtmlcompliant']) && $config['global.']['xhtmlcompliant'] == 1) {
         $this->geshi->force_xhtml_compliance = true;
     }
     // check for errors
     if ($this->geshi->error() !== false) {
         // log an error, this happens if the language file is missing or non-readable. Other input
         // specific errors can also occour, eg. if a non-existing container type is set for the engine.
         $GLOBALS['BE_USER']->simplelog($this->geshi->error(), $extKey = 'sema_sourcecode', 1);
     }
     // render
     return $this->pi_wrapInBaseClass($this->geshi->parse_code());
 }
开发者ID:sema,项目名称:typo3-source-code-highlighter,代码行数:61,代码来源:class.tx_semasourcecode_pi1.php

示例2: setExtra

 /**
  * Выделение строк
  *
  * @return Code
  */
 protected function setExtra()
 {
     if (isset($this->attributes['extra'])) {
         $extra = explode(',', $this->attributes['extra']);
         $this->geshi->highlight_lines_extra($extra);
     }
     return $this;
 }
开发者ID:thunder-spb,项目名称:xBBCode,代码行数:13,代码来源:Code.php

示例3: vorschau

function vorschau($K_Egl, $BenutzerId, $fid, $tid, $sid, $bid, $zid, $neu, $bemerkung)
{
    if (!$K_Egl) {
        fehler(__FILE__, __LINE__, 1, 'Zwichenablage fuer die Vorschau wurde nicht aktualisiert, da nicht eingeloggt');
    }
    $comp = trim($_POST['text']);
    $code = $_POST['codearea'];
    if (strlen($code)) {
        include_once '../forum/geshi/geshi.php';
        $sprachen = array('bash' => 'bash', 'C', 'c', 'cpp', 'cpp', 'HTML' => 'html4strict', 'Java' => 'java', 'JavaScript' => 'javascript', 'lisp' => 'lisp', 'PHP' => 'php-brief', 'Perl' => 'perl', 'Python' => 'python');
        $sprache = 'text';
        if (isset($_POST['codelang'])) {
            $sprache = $sprachen[$_POST['codelang']];
            if ($sprache == '') {
                $sprache = 'text';
            } else {
                $t = stripslashes($code);
                $ersatz = array('&gt;' => '>', '&lt;' => '<', '&quot;' => '"', '&#039;' => '\'', '&amp;' => '&');
                $t = strtr($t, $ersatz);
                if (isset($_POST['codezz']) and $_POST['codezz'] != "") {
                    $a = explode(',', $_POST['codezz']);
                    if (count($a) == 2) {
                        $code_start = intval($a[0]);
                        $code_ende = intval($a[1]);
                    }
                }
                $geshi = new GeSHi($t, $sprache, 'geshi/geshi');
                $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
                if (isset($code_start)) {
                    $geshi->highlight_lines_extra(range($code_start, $code_ende));
                }
                $code = $geshi->parse_code();
            }
        }
        if (isset($_POST['textarea_zeile']) and intval($_POST['textarea_zeile']) != -1) {
            $zeilen = intval($_POST['textarea_zeile']);
            $vorderteil = implode("\n", array_slice(explode("\n", $comp, $zeilen + 1), 0, $zeilen));
            $hinterteil = ltrim(substr($comp, strlen($vorderteil)));
            $vorderteil = rtrim($vorderteil);
            $comp = $vorderteil . '<div class="code-bereich">' . $code . '</div>' . $hinterteil;
        } else {
            $comp = $comp . '<div class="code-bereich">' . $code . '</div>';
        }
    }
    $comp = addslashes($comp);
    mysql_query("UPDATE Benutzer\n                SET Ablage = '{$comp}'\n                WHERE BenutzerId = '{$BenutzerId}'") or fehler(__FILE__, __LINE__, 0, 'Zwischenablage fuer die Vorschau konnte nicht aktualisiert werden');
    $vorschau = strlen($comp) ? 'j' : 'n';
    $bemerkung = rawurlencode($bemerkung);
    $titel = rawurlencode(substr(strip_tags(trim($_POST['titel'])), 0, 50));
    include 'gz-beitraege.php';
}
开发者ID:BackupTheBerlios,项目名称:babylon,代码行数:51,代码来源:vorschau.php

示例4: getCode

 public function getCode($data)
 {
     $code = array();
     foreach ($data as $part => $options) {
         $data = file_get_contents($options['file']);
         $geshi = new \GeSHi($data, $options['type']);
         //             $geshi->set_header_type(GESHI_HEADER_NONE);
         $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
         $geshi->set_line_style('background: #fcfcfc;', 'background: #fcfcfc;');
         if (array_key_exists('highlight', $options)) {
             $geshi->highlight_lines_extra($options['highlight']);
         }
         $title = sprintf('%s: %s', $part, basename($options['file']));
         $code[$title] = $geshi->parse_code();
     }
     return $code;
 }
开发者ID:bf13,项目名称:sandbox,代码行数:17,代码来源:DemoExtension.php

示例5: GeSHi

 /**
  * Easy way to highlight stuff. Behaves just like highlight_string
  *
  * @param string The code to highlight
  * @param string The language to highlight the code in
  * @param string The path to the language files. You can leave this blank if you need
  *               as from version 1.0.7 the path should be automatically detected
  * @param boolean Whether to return the result or to echo
  * @return string The code highlighted (if $return is true)
  * @since 1.0.2
  */
 function geshi_highlight($string, $language, $path = null, $return = false)
 {
     $geshi = new GeSHi($string, $language, $path);
     $geshi->set_header_type(GESHI_HEADER_PRE_VALID);
     $geshi->enable_classes();
     $geshi->enable_keyword_links(false);
     $geshi->highlight_lines_extra(array(8, 9, 10, 11, 13, 14, 15, 16, 18, 19, 24, 32, 80));
     if ($return) {
         return '<code>' . $geshi->parse_code() . '</code>';
     }
     echo '<code>' . $geshi->parse_code() . '</code>';
     if ($geshi->error()) {
         return false;
     }
     return true;
 }
开发者ID:robingchan,项目名称:Code-Viewer-Syntax-Highlighter,代码行数:27,代码来源:geshi.php

示例6: getPaste

 /**
  * get the data for the paste-poste
  * 
  * @return type 
  */
 public function getPaste()
 {
     $conf = \Pste\Registry::getInstance()->config;
     $pid = $this->pid;
     $paste = new \Pste\Model\Paste($pid);
     $post = $paste->getContent();
     if (!$post) {
         return $this->forward(new StaticPage(array('template' => 'components/paste_invalid.php')));
     }
     $this->followUp(new PasteForm(array('request' => $this->request)));
     $postPass = $this->request->hasParam('thePassword') ? $this->request->getParam('thePassword') : null;
     $pass = $post['password'];
     $restrictedPost = null !== $pass && $pass !== sha1("EMPTY") ? true : false;
     $accessAllowed = !$restrictedPost || sha1($postPass) == $pass ? true : false;
     $passwordFail = $restrictedPost && null !== $postPass && $postPass !== $pass ? true : false;
     if (!$accessAllowed) {
         require_once 'components/StaticPage.php';
         return $this->forward(new StaticPage(array('template' => 'components/paste_password.php', 'fail' => $passwordFail)));
     }
     $paste = $post;
     // Show a quick reference url, poster and parents .
     $expires = is_null($post['expires']) ? "Never Expires" : "Expires on " . date("F D jS g:i A", strtotime($post['expires']));
     $paste['posttitle'] = "Posted as {$post['poster']} on {$post['postdate']} - {$expires}";
     $paste['editcode'] = $paste['code'];
     // Preprocess
     $highlight = array();
     $prefix_size = strlen($this->conf['highlight_prefix']);
     if ($prefix_size) {
         $lines = explode("\n", $post['code']);
         $paste['editcode'] = "";
         foreach ($lines as $idx => $line) {
             if (substr($line, 0, $prefix_size) == $conf['highlight_prefix']) {
                 $highlight[] = $idx + 1;
                 $line = substr($line, $prefix_size);
             }
             $paste['editcode'] .= $line . "\n";
         }
         $paste['editcode'] = rtrim($post['editcode']);
     }
     $requestedFormat = $this->request->getParam('udf');
     $format = $requestedFormat ? $requestedFormat : $post['format'];
     // Get formatted version of code
     if (0 && strlen($post['codefmt']) > 0 && $format == $post['format']) {
         $paste['codefmt'] = $post['codefmt'];
     } else {
         $geshi = new \GeSHi($paste['editcode'], $format);
         $geshi->enable_classes();
         $geshi->set_header_type(GESHI_HEADER_DIV);
         $geshi->set_line_style('background: #ffffff;', 'background: #f4f4f4;');
         if (count($highlight)) {
             $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
             $geshi->highlight_lines_extra($highlight);
             $geshi->set_highlight_lines_extra_style('color:black;background:#FFFF88;');
         } else {
             $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 2);
         }
         $paste['codefmt'] = $geshi->parse_code();
         $paste['codecss'] = $geshi->get_stylesheet();
     }
     $paste['pid'] = $pid;
     $paste['downloadurl'] = $conf->url . $post['pid'];
     $this->url = $conf->url;
     $this->post = $paste;
     $this->geshiformats = $conf->get('geshiformats');
     $this->popular_syntax = $conf->get('popular_syntax');
     $this->format = $format;
 }
开发者ID:nicolask,项目名称:Indechse-pste,代码行数:72,代码来源:SinglePaste.php

示例7: getPost

 /**
  * Get formatted post, ready for inserting into a page
  * Returns an array of useful information
  */
 function getPost($pid)
 {
     $post = $this->db->getPost($pid, $this->conf['subdomain']);
     if ($post) {
         //show a quick reference url, poster and parents
         $post['posttitle'] = "Posted by {$post['poster']} on {$post['postdate']}";
         if ($post['parent_pid'] != '0') {
             $parent_pid = $post['parent_pid'];
             $parent = $this->db->getPost($parent_pid, $this->conf['subdomain']);
             if ($parent) {
                 $post['parent_poster'] = trim($parent['poster']);
                 if (strlen($post['parent_poster']) == 0) {
                     $post['parent_poster'] = 'Anonymous';
                 }
                 $post['parent_url'] = $this->getPostUrl($parent_pid);
                 $post['parent_postdate'] = $parent['postdate'];
                 $post['parent_diffurl'] = $this->conf['this_script'] . "?diff={$pid}";
             }
         }
         //any amendments - note that a db class might have already
         //filled this if efficient, othewise we grab it on demand
         if (!isset($post['followups'])) {
             $post['followups'] = $this->db->getFollowupPosts($pid);
         }
         foreach ($post['followups'] as $idx => $followup) {
             $post['followups'][$idx]['followup_url'] = $this->getPostUrl($followup['pid']);
         }
         $post['downloadurl'] = $this->conf['this_script'] . "?dl={$pid}";
         $post['deleteurl'] = $this->conf['this_script'] . "?erase={$pid}";
         //store the code for later editing
         $post['editcode'] = $post['code'];
         //preprocess
         $highlight = array();
         $prefix_size = strlen($this->conf['highlight_prefix']);
         if ($prefix_size) {
             $lines = explode("\n", $post['editcode']);
             $post['editcode'] = "";
             foreach ($lines as $idx => $line) {
                 if (substr($line, 0, $prefix_size) == $this->conf['highlight_prefix']) {
                     $highlight[] = $idx + 1;
                     $line = substr($line, $prefix_size);
                 }
                 $post['editcode'] .= $line . "\n";
             }
             $post['editcode'] = rtrim($post['editcode']);
         }
         //get formatted version of code
         if (strlen($post['codefmt']) == 0) {
             $geshi = new GeSHi($post['editcode'], $post['format']);
             $geshi->set_encoding($this->conf['htmlentity_encoding']);
             $geshi->enable_classes();
             $geshi->set_header_type(GESHI_HEADER_DIV);
             $geshi->set_line_style('background: #ffffff;', 'background: #f8f8f8;');
             //$geshi->set_comments_style(1, 'color: #008800;',true);
             //$geshi->set_comments_style('multi', 'color: #008800;',true);
             //$geshi->set_strings_style('color:#008888',true);
             //$geshi->set_keyword_group_style(1, 'color:#000088',true);
             //$geshi->set_keyword_group_style(2, 'color:#000088;font-weight: normal;',true);
             //$geshi->set_keyword_group_style(3, 'color:black;font-weight: normal;',true);
             //$geshi->set_keyword_group_style(4, 'color:#000088',true);
             //$geshi->set_symbols_style('color:#ff0000');
             if (count($highlight)) {
                 $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
                 $geshi->highlight_lines_extra($highlight);
                 $geshi->set_highlight_lines_extra_style('color:black;background:#FFFF88;');
             } else {
                 $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 2);
             }
             $post['codefmt'] = $geshi->parse_code();
             $post['codecss'] = $geshi->get_stylesheet();
             //save it!
             $this->db->saveFormatting($pid, $post['codefmt'], $post['codecss']);
         }
         $post['pid'] = $pid;
     } else {
         $post['codefmt'] = "<b>Unknown post id, it may have been deleted</b><br />";
     }
     return $post;
 }
开发者ID:carriercomm,项目名称:pastebin,代码行数:83,代码来源:pastebin.class.php

示例8: substr

            $highlight[] = $idx + 1;
            $line = substr($line, $DROP_CONF['highlight_len']);
        }
        $drop['text'] = array_merge($drop['text'], array($line));
        if (isset($drops[1])) {
            if ($ilines == 9) {
                $drop['text'] = array_merge($drop['text'], array("... This Drop is longer than 10 lines. Click the name above to see it all ..."));
                break;
            }
        }
    }
    $drop['text'] = implode("\n", $drop['text']);
}
//geshi object
$geshi = new GeSHi(stripslashes($drop['text']), $drop['lang']);
$geshi->highlight_lines_extra($highlight);
$geshi->set_tab_width(4);
$geshi->set_highlight_lines_extra_style('background:#FFFF88;');
$geshi->enable_keyword_links(false);
//geshi line numbers
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
$geshi->set_header_type(GESHI_HEADER_DIV);
//geshi styling for syntax box
$geshi->set_overall_style('color: #000066; border: 1px solid #d0d0d0; background-color: #fdfdf6; line-height:1.3em;', true);
$geshi->set_line_style('font: normal normal \'Courier New\', Courier, monospace; color: #003030;', 'font-weight: bold; color: #006060; padding-right: 5px;', true);
$geshi->set_code_style('color: #000020;', 'color: #000020;');
if ($drop['editable'] == 1) {
    if (!isset($_GET['passkey'])) {
        $editable = ' You may <a href="' . $DROP_CONF_siteURL . '/' . $drop['id'] . '/edit">edit this</a> drop.';
    } else {
        $editable = ' You may <a href="' . substr($_SERVER['REQUEST_URI'], 0, -30) . '/edit?pkey=' . $_GET['passkey'] . '">edit this</a> drop.';
开发者ID:jakedahn,项目名称:dropbin,代码行数:31,代码来源:highlighting.php

示例9: wp_syntax_highlight

function wp_syntax_highlight($match)
{
    global $wp_syntax_matches;
    // ADD YOUR THEME HERE
    $themes = array('slate' => '-slate');
    $i = intval($match[1]);
    $match = $wp_syntax_matches[$i];
    /******************** BEGIN EDITS *********************/
    $theme = $match[5];
    /******************** END EDITS *********************/
    $language = strtolower(trim($match[1]));
    foreach ($themes as $mytheme => $suffix) {
        if ($theme == $mytheme) {
            $language .= $suffix;
            break;
        }
    }
    $line = trim($match[2]);
    $escaped = trim($match[3]);
    // ORIGINAL LINE:
    //$code = wp_syntax_code_trim($match[5]);
    /******************** BEGIN EDITS *********************/
    $code = wp_syntax_code_trim($match[6]);
    /******************** END EDITS *********************/
    if ($escaped == "true") {
        $code = htmlspecialchars_decode($code);
    }
    $geshi = new GeSHi($code, $language);
    $geshi->enable_keyword_links(false);
    do_action_ref_array('wp_syntax_init_geshi', array(&$geshi));
    //START LINE HIGHLIGHT SUPPORT
    $highlight = array();
    if (!empty($match[4])) {
        $highlight = strpos($match[4], ',') == false ? array($match[4]) : explode(',', $match[4]);
        $h_lines = array();
        for ($i = 0; $i < sizeof($highlight); $i++) {
            $h_range = explode('-', $highlight[$i]);
            if (sizeof($h_range) == 2) {
                $h_lines = array_merge($h_lines, range($h_range[0], $h_range[1]));
            } else {
                array_push($h_lines, $highlight[$i]);
            }
        }
        $geshi->highlight_lines_extra($h_lines);
    }
    //END LINE HIGHLIGHT SUPPORT
    if ($theme == "slate") {
        $output = "\n<div class=\"wp_syntax_slate\">";
    } else {
        $output = "\n<div class=\"wp_syntax\">";
    }
    if ($line) {
        $output .= "<table><tr><td class=\"line_numbers\" style=\"padding: 6px 6px\">";
        $output .= wp_syntax_line_numbers($code, $line, $language);
        $output .= "</td><td class=\"code\" style=\"padding: 6px;\">";
        $output .= $geshi->parse_code();
        $output .= "</td></tr></table>";
    } else {
        $output .= "<table><tr><td class=\"code\" style=\"padding: 6px;\">";
        $output .= $geshi->parse_code();
        $output .= "</td></tr></table>";
    }
    $output .= "</div>\n";
    return $output;
}
开发者ID:rendon,项目名称:WP-Syntax-Themeable,代码行数:65,代码来源:wp-syntax.php

示例10: fr_codesyntax_handler


//.........这里部分代码省略.........
    }
    //Highlighting
    $geshi = new GeSHi($content, $params['lang']);
    if (!$commentProcessing and ($wp_sh_styling_type == 'theme' or $wp_sh_styling_type == 'embedbody')) {
        $geshi->enable_classes();
    }
    //Setting Geshi options
    //Lines
    switch ($params['lines']) {
        case 'normal':
            $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
            break;
        case 'fancy':
            $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
            break;
        case 'no':
            $geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS);
            break;
    }
    $geshi->start_line_numbers_at($params['lines_start']);
    //Container
    switch ($params['container']) {
        case 'pre':
            $geshi->set_header_type(GESHI_HEADER_PRE);
            break;
        case 'div':
            $geshi->set_header_type(GESHI_HEADER_DIV);
            break;
        case 'pre_valid':
            $geshi->set_header_type(GESHI_HEADER_PRE_VALID);
            break;
        case 'pre_table':
            $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
            break;
        case 'none':
            $geshi->set_header_type(GESHI_HEADER_NONE);
            break;
    }
    //Keywords capitalization
    switch ($params['capitalize']) {
        case 'no':
            $geshi->set_case_keywords(GESHI_CAPS_NO_CHANGE);
            break;
        case 'upper':
            $geshi->set_case_keywords(GESHI_CAPS_UPPER);
            break;
        case 'lower':
            $geshi->set_case_keywords(GESHI_CAPS_LOWER);
            break;
    }
    //Tab width
    $geshi->set_tab_width($params['tab_width']);
    //Strict mode
    switch ($params['strict']) {
        case 'always':
            $geshi->enable_strict_mode(GESHI_ALWAYS);
            break;
        case 'maybe':
            $geshi->enable_strict_mode(GESHI_MAYBE);
            break;
        case 'never':
            $geshi->enable_strict_mode(GESHI_NEVER);
            break;
    }
    //Block state
    switch ($params['blockstate']) {
        case 'collapsed':
            $initiallyHidden = true;
            break;
        case 'default':
        case 'expanded':
        default:
            $initiallyHidden = false;
            break;
    }
    //Controlling doclinks
    $geshi->enable_keyword_links($params['doclinks']);
    static $instanceNumber = 0;
    $instanceNumber++;
    $bookmarkName = empty($params['bookmarkname']) ? "codesyntax_" . $instanceNumber : $params['bookmarkname'];
    //Highlighting lines
    if (!empty($params['highlight_lines'])) {
        $geshi->highlight_lines_extra(explode(',', $params['highlight_lines']));
    }
    //Checking for geshi errors
    if ($geshi->error()) {
        return '<font color="red"><b>' . $geshi->error() . '</b></font>';
    }
    //Styling codeblock
    $header = wp_synhighlight_get_tpl_header($instanceNumber, $params['title'], $bookmarkName, $initiallyHidden);
    //Embedding only one copy of each used language style
    static $embeddedStylesheets = array();
    if ($wp_sh_styling_type == 'embedbody' and !in_array($params['lang'], $embeddedStylesheets)) {
        $header = '<style type="text/css"><!--' . "\r\n" . $geshi->get_stylesheet() . "\r\n" . '-->' . "\r\n" . '</style>' . $header;
        $embeddedStylesheets[] = $params['lang'];
    }
    $footer = wp_synhighlight_get_tpl_footer();
    $result = $header . $geshi->parse_code() . $footer;
    return $result;
}
开发者ID:yszar,项目名称:linuxwp,代码行数:101,代码来源:highlighter.php

示例11: array

    array('name' => 'style', 'type' => 'text',   'description' => 'CSS style'),
    array('name' => 'lang',  'type' => 'select', 'options' => array('php', 'sql', 'html'), 'description' => 'language type'),
    array('name' => 'lines', 'type' => 'text',   'description' => 'lines to be highlighted')
);
**/
if (isset($p['style'])) {
    $p['style'] = ' style="' . $p['style'] . '"';
} else {
    $p['style'] = '';
}
if (!$p['lang']) {
    $p['lang'] = 'php-brief';
} else {
    $p['lang'] = $p['lang'];
}
@(list($type, $body) = explode(':', $body, 2));
if ($type == 'file') {
    $geshi = new GeSHi(trim(file_get_contents("{$g['base_path']}/codes/{$body}")), $p['lang']);
    $geshi->set_header_content('Filename: ' . $body);
} elseif ($type == 'code') {
    $geshi = new GeSHi(trim($body), $p['lang']);
}
if (@count($p['lines'])) {
    $geshi->highlight_lines_extra(explode(',', $p['lines']));
    $geshi->set_highlight_lines_extra_style('background: #330');
}
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
$geshi->set_line_style('margin: 3px 0;');
$geshi->set_header_content_style('font-size: 0.8em; color: #333');
$geshi->set_header_type(GESHI_HEADER_DIV);
@($g['slide'] .= '<div class="code">' . $geshi->parse_code() . '</div>');
开发者ID:NabiKAZ,项目名称:PHPresentation,代码行数:31,代码来源:code.php

示例12: wp_syntax_highlight

function wp_syntax_highlight($match)
{
    global $wp_syntax_matches;
    $i = intval($match[1]);
    $match = $wp_syntax_matches[$i];
    $language = strtolower(trim($match[1]));
    $line = trim($match[2]);
    $escaped = trim($match[3]);
    $code = wp_syntax_code_trim($match[5]);
    if ($escaped == "true") {
        $code = htmlspecialchars_decode($code);
    }
    $geshi = new GeSHi($code, $language);
    $geshi->enable_keyword_links(false);
    do_action_ref_array('wp_syntax_init_geshi', array(&$geshi));
    //START LINE HIGHLIGHT SUPPORT
    $highlight = array();
    if (!empty($match[4])) {
        $highlight = strpos($match[4], ',') == false ? array($match[4]) : explode(',', $match[4]);
        $h_lines = array();
        for ($i = 0; $i < sizeof($highlight); $i++) {
            $h_range = explode('-', $highlight[$i]);
            if (sizeof($h_range) == 2) {
                $h_lines = array_merge($h_lines, range($h_range[0], $h_range[1]));
            } else {
                array_push($h_lines, $highlight[$i]);
            }
        }
        $geshi->highlight_lines_extra($h_lines);
    }
    //END LINE HIGHLIGHT SUPPORT
    $output = "\n<div class=\"wp_syntax\">";
    if ($line) {
        $output .= "<table><tr><td class=\"line_numbers\">";
        $output .= wp_syntax_line_numbers($code, $line);
        $output .= "</td><td class=\"code\">";
        $output .= $geshi->parse_code();
        $output .= "</td></tr></table>";
    } else {
        $output .= "<div class=\"code\">";
        $output .= $geshi->parse_code();
        $output .= "</div>";
    }
    return $output .= "</div>\n";
    return $output;
}
开发者ID:shieldsdesignstudio,项目名称:forefield,代码行数:46,代码来源:wp-syntax.php

示例13: getPaste

 function getPaste($pid)
 {
     $post = $this->db->getPaste($pid);
     if ($post) {
         // Show a quick reference url, title and parents.
         $expires = is_null($post['expires']) ? " (Never Expires) " : " - Expires on " . date("D, F jS @ g:ia", strtotime($post['expires']));
         $post['posttitle'] = "<b>{$post['title']}</b> - Posted on {$post['postdate']} {$expires}";
         if ($post['parent_pid'] > 0) {
             $parent_pid = $post['parent_pid'];
             $parent = $this->db->getPaste($parent_pid);
             if ($parent) {
                 $post['parent_title'] = $parent['title'];
                 $post['parent_url'] = $this->getPasteUrl($parent_pid);
                 $post['parent_postdate'] = $parent['postdate'];
                 $post['parent_diffurl'] = $this->conf['diff_url'] . "{$pid}";
             }
         }
         // Amendments
         $post['followups'] = $this->db->getFollowupPosts($pid);
         foreach ($post['followups'] as $idx => $followup) {
             $post['followups'][$idx]['followup_url'] = $this->getPasteUrl($followup['pid']);
         }
         if ($post['password'] != 'EMPTY') {
             $post['downloadurl'] = $this->conf['url'] . "?dl={$pid}&pass=" . $post['password'];
         } else {
             $post['downloadurl'] = $this->conf['url'] . "?dl={$pid}";
         }
         // Store the code for later editing
         $post['editcode'] = $post['code'];
         // Preprocess
         $highlight = array();
         $prefix_size = strlen($this->conf['highlight_prefix']);
         if ($prefix_size) {
             $lines = explode("\n", $post['editcode']);
             $post['editcode'] = "";
             foreach ($lines as $idx => $line) {
                 if (substr($line, 0, $prefix_size) == $this->conf['highlight_prefix']) {
                     $highlight[] = $idx + 1;
                     $line = substr($line, $prefix_size);
                 }
                 $post['editcode'] .= $line . "\n";
             }
             $post['editcode'] = rtrim($post['editcode']);
         }
         // Get formatted version of code
         if (strlen($post['codefmt']) == 0) {
             $geshi = new GeSHi($post['editcode'], $post['format']);
             $geshi->enable_classes();
             $geshi->set_header_type(GESHI_HEADER_DIV);
             $geshi->set_line_style('background: #ffffff;', 'background: #f4f4f4;');
             if (count($highlight)) {
                 $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
                 $geshi->highlight_lines_extra($highlight);
                 $geshi->set_highlight_lines_extra_style('color:black;background:#FFFF88;');
             } else {
                 $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 2);
             }
             $post['codefmt'] = $geshi->parse_code();
             $post['codecss'] = $geshi->get_stylesheet();
             // Save it!
             $this->db->saveFormatting($pid, $post['codefmt'], $post['codecss']);
         }
         $post['pid'] = $pid;
     } else {
         $post['codefmt'] = "<b>Unknown post ID, it probably expired.</b><br />";
     }
     return $post;
 }
开发者ID:KingNoosh,项目名称:Teknik,代码行数:68,代码来源:paste.php

示例14: highlight

 public static function highlight($match)
 {
     // global $wp_syntax_matches;
     $i = intval($match[1]);
     $match = self::$matches[$i];
     $language = strtolower(trim($match[1]));
     $line = trim($match[2]);
     $escaped = trim($match[3]);
     $caption = self::caption($match[5]);
     $code = self::trimCode($match[6]);
     if ($escaped == 'true') {
         $code = htmlspecialchars_decode($code);
     }
     $geshi = new GeSHi($code, $language);
     $geshi->enable_keyword_links(FALSE);
     do_action_ref_array('wp_syntax_init_geshi', array(&$geshi));
     if (!empty($match[4])) {
         $linespecs = strpos($match[4], ",") == FALSE ? array($match[4]) : explode(',', $match[4]);
         $lines = array();
         foreach ($linespecs as $spec) {
             $range = explode('-', $spec);
             $lines = array_merge($lines, count($range) == 2 ? range($range[0], $range[1]) : $range);
         }
         $geshi->highlight_lines_extra($lines);
     }
     $output = "\n" . '<div class="wp_syntax">';
     $output .= '<table>';
     if (!empty($caption)) {
         $output .= '<caption>' . $caption . '</caption>';
     }
     $output .= '<tr>';
     if ($line) {
         $output .= '<td class="line_numbers">' . self::lineNumbers($code, $line) . '</td>';
     }
     $output .= '<td class="code">';
     $output .= $geshi->parse_code();
     $output .= '</td></tr></table>';
     $output .= '</div>' . "\n";
     return $output;
 }
开发者ID:Ferrair,项目名称:MyPage,代码行数:40,代码来源:wp-syntax.php


注:本文中的GeSHi::highlight_lines_extra方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。