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


PHP GeSHi::enable_strict_mode方法代码示例

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


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

示例1: AdvancedCodeTag

function AdvancedCodeTag($source, $settings)
{
    global $languages, $languagesPath, $codeTag;
    $language = array_shift($settings);
    // [arg1]
    // [arg1]
    if ($language == '') {
        $language = 'text';
    }
    if ($language == "list") {
        // list all languages supported
        return "<br>List of supported languages for <b>Geshi " . GESHI_VERSION . "</b>:<br>" . implode("<br>", $languages);
    }
    if ($language != "" && !in_array($language, $languages)) {
        // list languages if invalid argument
        return "<br>Invalid language argument, \"<b>" . $language . "</b>\", select one from the list:<br>" . implode("<br>", $languages);
    }
    // set geshi
    $geshi = new GeSHi(trim($source), $language, $languagesPath);
    $geshi->enable_strict_mode($codeTag["advanced"]["strict"]);
    // [arg2 or more]
    if (in_array('n', $settings)) {
        // display line numbers
        $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
    }
    /*
       Add more GeSHi features from [ http://qbnz.com/highlighter/geshi-doc.html  ]
       template:
    		  if( in_array( '<PARAMETER NAME>', $settings ) )
    		  {
    			$geshi-><GESHI FUNCTION CALL>
    		  }
    */
    // removes newlines replaces with <br />
    return str_replace("\n", '<br />', $geshi->parse_code());
}
开发者ID:kidaa,项目名称:aur,代码行数:36,代码来源:GeshiCodeTag.php

示例2: _code

 public static function _code($action, $attributes, $content, $params, &$node_object)
 {
     if ($action == 'validate') {
         if (isset($attributes['default'])) {
             $highlighter = new GeSHi($content, $attributes['default']);
             if ($highlighter->error() === false) {
                 $highlighter->enable_strict_mode(GESHI_MAYBE);
                 $highlighter->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
                 $node_object->highlighter =& $highlighter;
                 return true;
             }
             return false;
         }
         return true;
     } else {
         $content = trim($content, "\r\n");
         if (isset($attributes['default'])) {
             $content = $node_object->highlighter->parse_code();
         } else {
             $content = htmlspecialchars($content);
             $content = '<pre><ol><li>' . preg_replace("/\\s*\n/", '</li><li>', $content) . '</li></ol></div>';
         }
         /**
          * STATISCHE SPRACHE
          */
         return '<div class="code"><h4>' . 'Code-Ansicht' . ':</h4>' . $content . '</div>';
     }
 }
开发者ID:GamerSource,项目名称:Infected-CMS-2,代码行数:28,代码来源:bbcode.php

示例3: highlightSourceFile

 protected function highlightSourceFile($filename)
 {
     if ($this->geshipath) {
         require_once $this->geshipath . '/geshi.php';
         $source = file_get_contents($filename);
         $geshi = new GeSHi($source, 'php', $this->geshilanguagespath);
         $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
         $geshi->enable_strict_mode(true);
         $geshi->enable_classes(true);
         $geshi->set_url_for_keyword_group(3, '');
         $html = $geshi->parse_code();
         $lines = split("<li>|</li>", $html);
         // skip first and last line
         array_pop($lines);
         array_shift($lines);
         $lines = array_filter($lines);
         $lines = array_map(array($this, 'stripDiv'), $lines);
         return $lines;
     } else {
         $lines = file($filename);
         for ($i = 0; $i < count($lines); $i++) {
             $line = $lines[$i];
             $line = rtrim($line);
             if (function_exists('mb_convert_encoding')) {
                 $lines[$i] = mb_convert_encoding($line, 'UTF-8');
             } else {
                 $lines[$i] = utf8_encode($line);
             }
         }
         return $lines;
     }
 }
开发者ID:sensorsix,项目名称:app,代码行数:32,代码来源:CoverageReportTask.php

示例4: syntaxhighlighting

 /**
  * Highlights the content parts marked as source code using the GeSHi
  * class.
  * @author  Björn Detert <b.detert@mittwald.de>
  * @version 20. 9. 2006
  * @param   string $content The text to be parsed
  * @param   object $parent  The calling object (regulary of type tx_mmforum_pi1), so this
  *                          object inherits all configuration and language options from the
  *                          calling object.
  * @param   array  $conf    The calling plugin's configuration vars
  * @return  string          The parsed string
  */
 function syntaxhighlighting($content, $parent, $conf)
 {
     /* Path to Geshi Syntax-Highlighting files. */
     $path = GeneralUtility::getFileAbsFileName('EXT:mm_forum/res/geshi/geshi/', $onlyRelative = 1, $relToTYPO3_mainDir = 0);
     $conf['postparser.']['tsrefUrl'] ? define('GESHI_TS_REF', $conf['postparser.']['tsrefUrl']) : define('GESHI_TS_REF', 'www.typo3.net');
     $res = $this->databaseHandle->exec_SELECTquery('lang_title,lang_pattern,lang_code', 'tx_mmforum_syntaxhl', 'deleted=0');
     while ($data = $this->databaseHandle->sql_fetch_assoc($res)) {
         preg_match_all($data['lang_pattern'], $content, $source_arr);
         while (list($key, $value) = each($source_arr[1])) {
             $value = trim($this->decode_entities($value));
             if ($data['lang_title'] == 'php') {
                 if (!preg_match("/<\\?/", trim(substr($value, 0, 6)))) {
                     $value = "<?\n" . $value . "\n?>";
                 }
             }
             $geshi = new GeSHi($value, $data['lang_code'], $path);
             $geshi->set_header_type(GESHI_HEADER_PRE);
             #$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
             $geshi->set_line_style('background: ' . $conf['postparser.']['sh_linestyle_bg'] . ';', 'background: ' . $conf['postparser.']['sh_linestyle_bg2'] . ';', true);
             $geshi->set_overall_style('margin:0px;', true);
             $geshi->enable_classes();
             $style = '<style type="text/css"><!--';
             $style .= $geshi->get_stylesheet();
             $style .= '--></style>';
             $geshi->enable_strict_mode('FALSE');
             $replace = $geshi->parse_code();
             $time = $geshi->get_time();
             $CodeHead = '<div class="tx-mmforum-pi1-codeheader">' . strtoupper($data['lang_title']) . '</div>';
             // $code_header , check this out?? I get confused ^^
             $replace = '###DONT_PARSE_AGAIN_START###' . $CodeHead . '<div class="tx-mmforum-pi1-codeblock">' . $style . $replace . '</div>###DONT_PARSE_AGAIN_ENDE###';
             $content = str_replace($source_arr[0][$key], $replace, $content);
         }
     }
     return $content;
 }
开发者ID:rabe69,项目名称:mm_forum,代码行数:47,代码来源:class.tx_mmforum_postparser.php

示例5: wp_codebox_highlight_geshi

function wp_codebox_highlight_geshi ($match)
{
    global $codeid, $post;
    $codeid ++;
    //get option from DB
    $cb_plain_txt = get_option("cb_plain_txt");
    $cb_line = get_option("cb_line");
    $cb_colla = get_option("cb_colla");
    $cb_wrap_over = get_option("cb_wrap_over");
    $cb_highlight = get_option("cb_highlight");
    $cb_strict = get_option("cb_strict");
    $cb_caps = get_option("cb_caps");
    $cb_tab_width = intval(get_option("cb_tab_width"));
    $cb_keywords_link = get_option("cb_keywords_link");
    if ($match[1]) {
        $language = strtolower(trim($match[1]));
    } else {
        $language = "text";
    }
    $line = trim($match[4]);
    $file = trim($match[2]);
    $colla = trim($match[3]);
    $code = wp_codebox_code_trim($match[5]);
    $is_windowsie = wp_codebox_is_windowsie();
    $geshi = new GeSHi($code, $language);
    $geshi->enable_keyword_links($cb_keywords_link);
    $geshi->set_case_keywords($cb_caps);
    $geshi->set_tab_width($cb_tab_width);
    $geshi->enable_strict_mode($cb_strict);
    do_action_ref_array('wp_codebox_init_geshi', array(&$geshi));
    $output = "\n";
    if (! ($cb_plain_txt)) {
        $output .= "<div class=\"wp_codebox_msgheader";
        if (($cb_colla && (! ($colla == "+"))) || ($colla == "-")) {
            $output .= " wp_codebox_hide";
        }
        $output .= "\">";
        $output .= "<span class=\"right\">";
        $output .= "<sup><a href=\"http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples\" target=\"_blank\" title=\"WP-CodeBox HowTo?\"><span style=\"color: #99cc00\">?</span></a></sup>";
        if ($is_windowsie) {
            $output .= "<a href=\"javascript:;\" onclick=\"copycode('p" . $post->ID . "code" . $codeid . "');\">" . __('[Copy to clipboard]', 'wp-codebox') . "</a>";
        }
        /*
		$output .= "<a href=\"javascript:;\" onclick=\"toggle_collapse('p".$post->ID.$codeid."');\">[<span id=\"p".$post->ID.$codeid."_symbol\">";
		if (($cb_colla && (!($colla == "+"))) || ($colla == "-")){$output .= "+";} else {$output.= "-";}
		$output .= "</span>]</a>";
		*/
        $output .= "</span>";
        if ($file) {
            $output .= "<span class=\"left2\">" . __('Download', 'wp-codebox') . ' <a href="' . get_bloginfo('wpurl') . '/wp-content/plugins/wp-codebox/wp-codebox.php?p=' . $post->ID . '&amp;download=' . wp_specialchars($file) . '">' . wp_specialchars($file) . '</a>';
        } else {
            $output .= "<span class=\"left\">" . "<a href=\"javascript:;\" onclick=\"javascript:showCodeTxt('p" . $post->ID . "code" . $codeid . "'); return false;\">" . __('View Code', 'wp-codebox') . "</a> " . strtoupper($language);
        }
        $output .= "</span><div class=\"codebox_clear\"></div></div>";
    }
    $output .= "<div class=\"wp_codebox\">";
    $output .= "<table>";
    $output .= "<tr ";
    $output .= "id=\"p" . $post->ID . $codeid . "\">";
    if ($cb_line && (! ($line)))
        $line = "1";
    if (($line) && (! ($line == "n"))) {
        $output .= "<td class=\"line_numbers\">";
        $output .= wp_codebox_line_numbers($code, $line);
        $output .= "</td>";
    }
    $output .= "<td class=\"code\" id=\"p" . $post->ID . "code" . $codeid . "\">";
    $output .= $geshi->parse_code();
    $output .= "</td></tr></table></div>\n";
    return $output;
}
开发者ID:ramo01,项目名称:1kapp,代码行数:71,代码来源:main.php

示例6: LoadData

 /**
  * Loads data for this template
  */
 protected function LoadData()
 {
     $head = $this->GetProject()->GetHeadCommit();
     $this->tpl->assign('head', $head);
     $commit = $this->GetProject()->GetCommit($this->params['hashbase']);
     $this->tpl->assign('commit', $commit);
     if (!isset($this->params['hash']) && isset($this->params['file'])) {
         $this->params['hash'] = $commit->GetTree()->PathToHash($this->params['file']);
         if (empty($this->params['hash'])) {
             throw new GitPHP_FileNotFoundException($this->params['file']);
         }
     }
     $blob = $this->GetProject()->GetObjectManager()->GetBlob($this->params['hash']);
     if ($this->params['file']) {
         $blob->SetPath($this->params['file']);
     }
     $blob->SetCommit($commit);
     $this->tpl->assign('blob', $blob);
     $blame = new GitPHP_FileBlame($this->GetProject(), $commit, $this->params['file'], $this->exe);
     $this->tpl->assign('blame', $blame->GetBlame());
     if (isset($this->params['output']) && $this->params['output'] == 'js') {
         return;
     }
     $this->tpl->assign('tree', $commit->GetTree());
     if ($this->config->GetValue('geshi')) {
         include_once GITPHP_GESHIDIR . "geshi.php";
         if (class_exists('GeSHi')) {
             $geshi = new GeSHi("", 'php');
             if ($geshi) {
                 $lang = GitPHP_Util::GeshiFilenameToLanguage($blob->GetName());
                 if (empty($lang)) {
                     $lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(), '.'), 1));
                 }
                 if (!empty($lang)) {
                     $geshi->enable_classes();
                     $geshi->enable_strict_mode(GESHI_MAYBE);
                     $geshi->set_source($blob->GetData());
                     $geshi->set_language($lang);
                     $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
                     $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
                     $output = $geshi->parse_code();
                     $bodystart = strpos($output, '<td');
                     $bodyend = strrpos($output, '</tr>');
                     if ($bodystart !== false && $bodyend !== false) {
                         $geshihead = substr($output, 0, $bodystart);
                         $geshifoot = substr($output, $bodyend);
                         $geshibody = substr($output, $bodystart, $bodyend - $bodystart);
                         $this->tpl->assign('geshihead', $geshihead);
                         $this->tpl->assign('geshibody', $geshibody);
                         $this->tpl->assign('geshifoot', $geshifoot);
                         $this->tpl->assign('geshicss', $geshi->get_stylesheet());
                         $this->tpl->assign('geshi', true);
                     }
                 }
             }
         }
     }
 }
开发者ID:hmcclungiii,项目名称:gitphp,代码行数:61,代码来源:Controller_Blame.class.php

示例7: GeSHi

 function ch_highlight_code($matches)
 {
     global $ch_options;
     // undo nl and p formatting
     $plancode = $matches[2];
     $plancode = $this->entodec($plancode);
     $geshi = new GeSHi($plancode, strtolower($matches[1]));
     $geshi->set_encoding('utf-8');
     $geshi->set_header_type(GESHI_HEADER_DIV);
     $geshi->enable_classes(true);
     $language = $geshi->get_language_name();
     if ($language == 'PHP') {
         $geshi->add_keyword(2, 'protected');
         $geshi->add_keyword(2, 'private');
         $geshi->add_keyword(2, 'abstract');
         $geshi->add_keyword(2, 'static');
         $geshi->add_keyword(2, 'final');
         $geshi->add_keyword(2, 'implements');
     } elseif ($language == 'Bash') {
         $geshi->add_keyword(2, 'convert');
         $geshi->add_keyword(2, 'git');
     } elseif ($language == 'Vim Script') {
         $geshi->add_keyword(1, 'endfunction');
     }
     if (ch_go('ch_b_linenumber')) {
         $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
     }
     $geshi->enable_strict_mode(ch_go('ch_b_strict_mode'));
     $geshi->set_tab_width(ch_go('ch_in_tab_width'));
     $geshi->set_overall_class('dean_ch');
     $overall_style = '';
     if (!ch_go("ch_b_wrap_text")) {
         $overall_style .= 'white-space: nowrap;';
     } else {
         $overall_style .= 'white-space: wrap;';
     }
     if ($overall_style != '') {
         $geshi->set_overall_style($overall_style, false);
     }
     return $geshi->parse_code();
 }
开发者ID:senseb,项目名称:solr-vs-elasticsearch,代码行数:41,代码来源:deans_code_highlighter.php

示例8: LoadData

 /**
  * Loads data for this template
  */
 protected function LoadData()
 {
     $commit = $this->GetProject()->GetCommit($this->params['hashbase']);
     $this->tpl->assign('commit', $commit);
     $tree = $commit->GetTree();
     $this->tpl->assign('tree', $commit->GetTree());
     if (!isset($this->params['hash']) && isset($this->params['file'])) {
         $this->params['hash'] = $tree->PathToHash($this->params['file']);
         if (empty($this->params['hash'])) {
             throw new GitPHP_FileNotFoundException($this->params['file']);
         }
     }
     $blob = $this->GetProject()->GetObjectManager()->GetBlob($this->params['hash']);
     if (!empty($this->params['file'])) {
         $blob->SetPath($this->params['file']);
     }
     $blob->SetCommit($commit);
     $this->tpl->assign('blob', $blob);
     if ($this->Plain()) {
         return;
     }
     $head = $this->GetProject()->GetHeadCommit();
     $this->tpl->assign('head', $head);
     if ($this->config->GetValue('filemimetype')) {
         $mimeReader = new GitPHP_FileMimeTypeReader($blob, $this->GetMimeStrategy());
         $mimetype = $mimeReader->GetMimeType(true);
         if ($mimetype == 'image') {
             $this->tpl->assign('datatag', true);
             $this->tpl->assign('mime', $mimeReader->GetMimeType());
             $this->tpl->assign('data', base64_encode($blob->GetData()));
             return;
         }
     }
     if ($this->config->GetValue('geshi')) {
         include_once GITPHP_GESHIDIR . "geshi.php";
         if (class_exists('GeSHi')) {
             $geshi = new GeSHi("", 'php');
             if ($geshi) {
                 $lang = GitPHP_Util::GeshiFilenameToLanguage($blob->GetName());
                 if (empty($lang)) {
                     $lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(), '.'), 1));
                 }
                 if (!empty($lang)) {
                     $geshi->enable_classes();
                     $geshi->enable_strict_mode(GESHI_MAYBE);
                     $geshi->set_source($blob->GetData());
                     $geshi->set_language($lang);
                     $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
                     $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
                     $geshi->set_overall_id('blobData');
                     $this->tpl->assign('geshiout', $geshi->parse_code());
                     $this->tpl->assign('geshicss', $geshi->get_stylesheet());
                     $this->tpl->assign('geshi', true);
                     return;
                 }
             }
         }
     }
     $this->tpl->assign('bloblines', $blob->GetData(true));
 }
开发者ID:hmcclungiii,项目名称:gitphp,代码行数:63,代码来源:Controller_Blob.class.php

示例9: dirname


//.........这里部分代码省略.........
                         // there used to be a rather large block of code here, testing wether methods were callable and call them if
                         // that's the case.
                         // parse the code
                         $geshified = $geshi->parseCode();
                     } else {
                         $error = TRUE;
                     }
                 } else {
                     // use GeSHi 1.0
                     include_once dirname(__FILE__) . '/geshi-1.0/geshi.php';
                     // highlight code according to type setting, default to php
                     $geshi = new GeSHi($not_geshified, $match['type'] !== NULL ? $match['type'] : $this->settings['default_type']);
                     $str_error = $geshi->error();
                     if (empty($str_error)) {
                         // enable line numbers
                         $number_style = !empty($match['line']) ? $match['line'] : $this->settings['default_line'];
                         switch (strtolower(preg_replace('/\\d+/', '', $number_style))) {
                             case 'normal':
                                 $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
                                 break;
                             case 'fancy':
                                 $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, (int) preg_replace('/[^\\d]*/', '', $number_style));
                                 break;
                             case 'none':
                                 $geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS);
                                 break;
                         }
                         // set first line number
                         if ($match['start']) {
                             $geshi->start_line_numbers_at($match['start']);
                         }
                         // set strict mode
                         if ($match['strict']) {
                             $geshi->enable_strict_mode(TRUE);
                         }
                         // enable or disable keyword links
                         $geshi->enable_keyword_links((bool) ($match['keyword_links'] !== NULL) ? $match['keyword_links'] : $this->settings['keyword_links']);
                         // set overall class name
                         if ($match['overall_class'] != NULL) {
                             $geshi->set_overall_class($match['overall_class']);
                         }
                         // set overall id
                         if ($match['overall_id'] != NULL) {
                             $geshi->set_overall_id($match['overall_id']);
                         }
                         // set header type
                         switch ($this->settings['geshi_header_type']) {
                             case 'div':
                                 $geshi->set_header_type(GESHI_HEADER_DIV);
                                 break;
                             case 'pre':
                                 $geshi->set_header_type(GESHI_HEADER_PRE);
                                 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;
                         }
                         // set encoding (for legacy reasons afaik)
                         $geshi->set_encoding($this->settings['geshi_encoding']);
                         // parse the source code
开发者ID:neverpanic,项目名称:GeSHify,代码行数:67,代码来源:ext.geshify.php

示例10: fr_codesyntax_handler

/**
 * Function handler for coloring shortcodes. It's used in comments and for [filesyntax tag]
 *
 * @param string $atts
 * @param string $content
 * @return string
 */
function fr_codesyntax_handler($atts, $content = null, $cleanHTML = true, $commentProcessing = false)
{
    global $wp_sh_styling_type;
    if (empty($content)) {
        return '<font color="red"><b>' . __('WP-SYNHIGHLIGHT PLUGIN: NOTHING TO HIGHLIGHT! PLEASE READ README.TXT IN PLUGIN FOLDER!', 'wp-synhighlighter') . '</b></font>';
    }
    //Parsing paramters
    $params = shortcode_atts(array('title' => get_option('wp_synhighlight_default_codeblock_title') ? get_option('wp_synhighlight_default_codeblock_title') : __("Code block", 'wp-synhighlighter'), 'bookmarkname' => '', 'lang' => 'pascal', 'lines' => get_option('wp_synhighlight_default_lines') ? get_option('wp_synhighlight_default_lines') : 'fancy', 'lines_start' => get_option('wp_synhighlight_default_lines_start_with') ? get_option('wp_synhighlight_default_lines_start_with') : '1', 'container' => get_option('wp_synhighlight_default_container') ? get_option('wp_synhighlight_default_container') : 'pre', 'capitalize' => get_option('wp_synhighlight_default_capitalize_keywords') ? get_option('wp_synhighlight_default_capitalize_keywords') : 'no', 'tab_width' => get_option('wp_synhighlight_default_tab_width') ? get_option('wp_synhighlight_default_tab_width') : 4, 'strict' => get_option('wp_synhighlight_default_strict_mode') ? get_option('wp_synhighlight_default_strict_mode') : 'always', 'blockstate' => get_option('wp_synhighlight_default_blockstate') ? get_option('wp_synhighlight_default_blockstate') : 'default', 'highlight_lines' => "", 'doclinks' => !get_option('wp_synhighlight_doclinks_off')), $atts);
    if ($cleanHTML) {
        //Clearing all other HTML code
        $content = strip_tags($content);
        //Converting HTML entities
        $content = html_entity_decode($content, ENT_QUOTES);
    }
    //Trimming first and last incorrect newlines
    $content = trim($content);
    //Windows Live Writer patch
    foreach ($params as &$param) {
        $param = trim(html_entity_decode($param, ENT_QUOTES), '"');
    }
    //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;
//.........这里部分代码省略.........
开发者ID:yszar,项目名称:linuxwp,代码行数:101,代码来源:highlighter.php

示例11: LoadData

 /**
  * LoadData
  *
  * Loads data for this template
  *
  * @access protected
  */
 protected function LoadData()
 {
     $commit = $this->project->GetCommit($this->params['hashbase']);
     $this->tpl->assign('commit', $commit);
     if (!isset($this->params['hash']) && isset($this->params['file'])) {
         $this->params['hash'] = $commit->PathToHash($this->params['file']);
     }
     $blob = $this->project->GetBlob($this->params['hash']);
     if (!empty($this->params['file'])) {
         $blob->SetPath($this->params['file']);
     }
     $blob->SetCommit($commit);
     $this->tpl->assign('blob', $blob);
     if (isset($this->params['plain']) && $this->params['plain']) {
         return;
     }
     $head = $this->project->GetHeadCommit();
     $this->tpl->assign('head', $head);
     $this->tpl->assign('tree', $commit->GetTree());
     if (GitPHP_Config::GetInstance()->GetValue('filemimetype', true)) {
         $mime = $blob->FileMime();
         if ($mime) {
             $mimetype = strtok($mime, '/');
             if ($mimetype == 'image') {
                 $this->tpl->assign('datatag', true);
                 $this->tpl->assign('mime', $mime);
                 $this->tpl->assign('data', base64_encode($blob->GetData()));
                 return;
             }
         }
     }
     if (GitPHP_Config::GetInstance()->GetValue('geshi', true)) {
         include_once GitPHP_Util::AddSlash(GitPHP_Config::GetInstance()->GetValue('geshiroot', 'lib/geshi/')) . "geshi.php";
         if (class_exists('GeSHi')) {
             $geshi = new GeSHi("", 'php');
             if ($geshi) {
                 $lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(), '.'), 1));
                 if (!empty($lang)) {
                     $geshi->enable_classes();
                     $geshi->enable_strict_mode(GESHI_MAYBE);
                     $geshi->set_source($blob->GetData());
                     $geshi->set_language($lang);
                     $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
                     $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
                     $geshi->set_overall_id('blobData');
                     $this->tpl->assign('geshiout', $geshi->parse_code());
                     $this->tpl->assign('geshicss', $geshi->get_stylesheet());
                     $this->tpl->assign('geshi', true);
                     return;
                 }
             }
         }
     }
     $this->tpl->assign('bloblines', $blob->GetData(true));
 }
开发者ID:sandassha,项目名称:gitstack,代码行数:62,代码来源:Controller_Blob.class.php

示例12: AdvancedCodeTag

function AdvancedCodeTag($source, $settings)
{
    global $languages, $languagesPath, $codeTag;
    $language = array_shift($settings);
    // [arg1]
    $isNumbered = array_shift($settings);
    // [arg2]
    // [arg1]
    if ($language == '') {
        $language = 'text';
        // bugfix: to work for existing <code> tags, simply use "text"
    }
    if ($language == "list") {
        // list all languages supported
        return "<br>List of supported languages for <b>Geshi " . GESHI_VERSION . "</b>:<br>" . implode("<br>", $languages);
    }
    if ($language != "" && !in_array($language, $languages)) {
        // list languages if invalid argument
        return "<br>Invalid language argument, \"<b>" . $language . "</b>\", select one from the list:<br>" . implode("<br>", $languages);
    }
    // set geshi
    $geshi = new GeSHi(trim($source), $language, $languagesPath);
    $geshi->enable_strict_mode($codeTag["advanced"]["strict"]);
    // [arg2]
    if ($isNumbered == "n") {
        // display line numbers
        $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
    }
    /*
      Add more GeSHi features below
      http://qbnz.com/highlighter/geshi-doc.html 
    */
    return $geshi->parse_code();
}
开发者ID:saper,项目名称:organic-extensions,代码行数:34,代码来源:GeSHiCodeTag.php


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