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


PHP GeSHi::enable_keyword_links方法代码示例

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


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

示例1: 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]);
    $code = wp_syntax_code_trim($match[3]);
    $geshi = new GeSHi($code, $language);
    $geshi->enable_keyword_links(false);
    do_action_ref_array('wp_syntax_init_geshi', array(&$geshi));
    $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:jeremyboles,项目名称:cappuccino-website,代码行数:26,代码来源:wp-syntax.php

示例2: bb_syntax_highlight

function bb_syntax_highlight($match)
{
    global $bb_syntax_matches;
    $i = intval($match[1]);
    $match = $bb_syntax_matches[$i];
    $language = strtolower(trim($match[1]));
    $line = trim($match[2]);
    $escaped = trim($match[3]);
    $code = bb_syntax_code_trim($match[4]);
    //if ($escaped == "true") $code = htmlspecialchars_decode($code);
    $code = htmlspecialchars_decode($code);
    //$code = str_replace("&lt;", "<", $code);
    //$code = str_replace("&gt;", ">", $code);
    $geshi = new GeSHi($code, $language);
    $geshi->enable_keyword_links(false);
    do_action_ref_array('bb_syntax_init_geshi', array(&$geshi));
    $output = "\n<div class=\"bb_syntax\">";
    if ($line) {
        $output .= "<table><tr><td class=\"line_numbers\">";
        $output .= bb_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>";
    }
    $output .= "</div>\n";
    return $output;
}
开发者ID:achorg,项目名称:DH-Answers,代码行数:31,代码来源:bb-syntax.php

示例3: load

 function load()
 {
     if ($this->exists() == true) {
         $this->import();
         $this->lng = $this->data['language'];
         $this->source = $this->data['source'];
     } else {
         if (!class_exists('GeSHi')) {
             include_once 'classes/class.geshi.php';
         }
         global $lang;
         $language = $this->hasLanguage() ? $this->lng : 'text';
         $geshi = new GeSHi($this->source, $language, 'classes/geshi');
         $geshi->set_encoding($lang->charset());
         $geshi->enable_classes(false);
         $geshi->set_header_type(GESHI_HEADER_DIV);
         $geshi->enable_keyword_links(true);
         $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 5);
         if (!$this->hasLanguage()) {
             $geshi->enable_highlighting(false);
             $geshi->set_numbers_highlighting(false);
             $geshi->set_brackets_highlighting(false);
             $language = '';
         } else {
             $language = $geshi->get_language_name();
         }
         $this->data = array('language' => $language, 'parsed' => $geshi->parse_code(), 'source' => $this->source);
         $this->export();
     }
 }
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:30,代码来源:UniversalCodeCache.inc.php

示例4: codeReplace

 public function codeReplace($text)
 {
     // check if geshi available
     $geshiPath = dirname(__FILE__) . '/../vendor/geshi/geshi.php';
     if (!file_exists($geshiPath)) {
         return $text;
     }
     $regexp = '@<code class="(\\w+)">(.+?)<\\/code>@s';
     // replace codes
     if (preg_match_all($regexp, $text, $found)) {
         require_once $geshiPath;
         for ($index = 0; $index < count($found) - 1; $index++) {
             if (!isset($found[1][$index])) {
                 continue;
             }
             $language = $found[1][$index];
             $code = trim($found[2][$index]);
             $geshi = new GeSHi($code, $language);
             $geshi->set_header_type(GESHI_HEADER_NONE);
             $geshi->enable_classes();
             $geshi->set_tab_width(2);
             $geshi->enable_keyword_links(false);
             if (in_array($language, array('php', 'css', 'shell', 'ruby', 'python', 'bash', 'sql')) && String::numberOfLines($code) > 5) {
                 //$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 2);
             }
             // replace image place holders
             $text = str_replace($code, $geshi->parse_code(), $text);
         }
     }
     return $text;
 }
开发者ID:Ephigenia,项目名称:harrison,代码行数:31,代码来源:BlogPostFormater.php

示例5: GeSHi

 static function generic_render_code($source, $lang, $line_numbers = false)
 {
     require_once self::$geshi_file;
     $geshi = new GeSHi($source, $lang);
     if ($line_numbers) {
         $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
     }
     $geshi->enable_keyword_links(false);
     return $geshi->parse_code();
 }
开发者ID:black2279,项目名称:Tracy-openshift,代码行数:10,代码来源:CodeGen.php

示例6: register

 public function register(Application $app)
 {
     $app['geshi'] = function () use($app) {
         $geshi = new \GeSHi();
         $geshi->enable_classes();
         // this must be the first method (see Geshi doc)
         $geshi->set_encoding($app['app.charset']);
         $geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS);
         $geshi->enable_keyword_links(false);
         return $geshi;
     };
 }
开发者ID:oiat,项目名称:e-book-creator,代码行数:12,代码来源:GeshiServiceProvider.php

示例7: highlight

function highlight($code, $lang)
{
    if ($lang == 'php-html') {
        return smartHighlight($code);
    }
    $geshi = new GeSHi($code, $lang);
    $geshi->set_header_type(GESHI_HEADER_NONE);
    $geshi->enable_classes();
    $geshi->enable_keyword_links(false);
    $code = $geshi->parse_code();
    return '<span class="' . $lang . '">' . $code . '</span>';
}
开发者ID:scheibome,项目名称:kirbycms-extensions,代码行数:12,代码来源:highlight.php

示例8: setLinks

 /**
  * Ссылки на документацию
  *
  * @return Code
  */
 protected function setLinks()
 {
     if (isset($this->attributes['links'])) {
         if ('1' === $this->attributes['links'] || 'true' === $this->attributes['links']) {
             $this->geshi->enable_keyword_links(true);
         } else {
             $this->geshi->enable_keyword_links(false);
         }
     } else {
         $this->geshi->enable_keyword_links($this->getKeywordLinks());
     }
     return $this;
 }
开发者ID:thunder-spb,项目名称:xBBCode,代码行数:18,代码来源:Code.php

示例9: callGeshi

 protected function callGeshi($text, $language)
 {
     if ($language == 'html') {
         $language = 'html4strict';
     }
     $text = html_entity_decode($text);
     $geshi = new GeSHi($text, $language);
     $geshi->enable_classes();
     // disable links on PHP functions, HTML tags, ...
     $geshi->enable_keyword_links(false);
     $ret = @$geshi->parse_code();
     //fix extra space at bottom
     return str_replace("&nbsp;</pre>", "</pre>", $ret);
 }
开发者ID:kbond,项目名称:zsUtilPlugin,代码行数:14,代码来源:zsMarkdownDocument.class.php

示例10: bbcodeCodeHighlight

function bbcodeCodeHighlight($contents, $arg)
{
    include_once "geshi.php";
    if (!$arg) {
        return '<div class="codeblock">' . htmlentities($contents) . '</div>';
    } else {
        $language = $arg;
        $geshi = new GeSHi(trim($contents), $language, null);
        $geshi->set_header_type(GESHI_HEADER_NONE);
        $geshi->enable_classes();
        $geshi->enable_keyword_links(false);
        $code = str_replace("\n", "", $geshi->parse_code());
        $code = decodeCrapEntities($code);
        return "<div class=\"codeblock geshi\">{$code}</div>";
    }
}
开发者ID:Servault,项目名称:Blargboard,代码行数:16,代码来源:bbcode.php

示例11: wp_syntax_highlight_mpdf

function wp_syntax_highlight_mpdf($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[4]);
    $code = htmlspecialchars_decode($code);
    $geshi = new GeSHi($code, $language);
    $geshi->enable_keyword_links(false);
    $geshi->set_header_type(GESHI_HEADER_DIV);
    $geshi->set_tab_width(4);
    do_action_ref_array('wp_syntax_init_geshi', array(&$geshi));
    $output = "\n<div class=\"wp_syntax\">";
    //Beim Printen immer Line numbern anmachen
    $line = get_option('mpdf_geshi_linenumbers');
    if ($line) {
        $lineMode = explode("\n", $code);
        $output .= '<table>';
        for ($i = 0; $i < count($lineMode); $i++) {
            $geshi->set_source($lineMode[$i]);
            if ($i % 2) {
                $output .= '<tr style="background-color: #f5f5f5;">';
            } else {
                $output .= '<tr>';
            }
            $output .= '<td class="line_numbers" style="vertical-align: top;">';
            if (($i + 1) % 5) {
                $output .= $i + 1;
            } else {
                $output .= '<b>' . ($i + 1) . '</b>';
            }
            $output .= '</td><td class="code">';
            $output .= $geshi->parse_code();
            $output .= '</td></tr>';
        }
        $output .= '</table>';
    } else {
        $output .= "<div class=\"code\">";
        $output .= $geshi->parse_code();
        $output .= "</div>";
    }
    return $output .= "</div>\n";
    return $output;
}
开发者ID:huntercoxIG,项目名称:edc,代码行数:47,代码来源:wp_syntax_functions.inc.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: highlight_sql_query

function highlight_sql_query($sql)
{
    require_once 'classes/class.geshi.php';
    $path = 'classes/geshi';
    $language = 'mysql';
    if (!file_exists($path . '/' . $language . '.php')) {
        $language = 'sql';
        if (!file_exists($path . '/' . $language . '.php')) {
            return null;
        }
    }
    $geshi = new GeSHi($sql, $language, $path);
    $geshi->enable_classes(false);
    $geshi->set_header_type(GESHI_HEADER_DIV);
    $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 5);
    $geshi->enable_keyword_links(false);
    return $geshi->parse_code();
}
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:18,代码来源:db.php

示例14: bbcode_highlite

function bbcode_highlite($s, $language = false)
{
    $s = base64_decode($s);
    if (!$language) {
        return '<code>' . htmlspecialchars($s, ENT_COMPAT, 'UTF-8') . '</code>';
    }
    $geshi = new GeSHi($s, $language);
    $geshi->enable_classes(true);
    $geshi->set_header_type(GESHI_HEADER_DIV);
    $geshi->enable_keyword_links(false);
    $geshi->set_tab_width(4);
    $output = $geshi->parse_code();
    if ($geshi->error()) {
        return false;
    }
    head('stylesheet', 'geshi/' . $language, 'screen');
    return '<div class="geshi">' . $output . '</div>';
}
开发者ID:RazorMarx,项目名称:izend,代码行数:18,代码来源:bbcode.php

示例15: bbcodeCodeHighlight

function bbcodeCodeHighlight($dom, $contents, $arg)
{
    // in <pre> style
    $contents = preg_replace('/^\\n|\\n$/', "", $contents);
    include_once "geshi.php";
    if (!$arg) {
        $div = $dom->createElement('div');
        $div->setAttribute('class', 'codeblock');
        $div->appendChild($dom->createTextNode($contents));
        return $div;
    } else {
        $language = $arg;
        $geshi = new GeSHi($contents, $language);
        $geshi->set_header_type(GESHI_HEADER_NONE);
        $geshi->enable_classes();
        $geshi->enable_keyword_links(false);
        $code = str_replace("\n", "", $geshi->parse_code());
        return markupToMarkup($dom, "<div class=\"codeblock geshi\">{$code}</div>");
    }
}
开发者ID:RoadrunnerWMC,项目名称:ABXD-plugins,代码行数:20,代码来源:bbcode.php


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