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


PHP GeSHi::enable_ids方法代码示例

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


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

示例1: getGeSHI

 /**
  * Get a geshi object for this source. This function is for internal use.
  * @return GeSHI! The geshi object associated with the source.
  */
 protected function getGeSHI()
 {
     if (!isset($this->geshi)) {
         // truncante long lines and limit the number of lines
         $text = "";
         $linesTruncated = array();
         $lines = explode("\n", $this->plainSourceCode);
         $nbOfLines = count($lines);
         $n = 0;
         while ($n < $nbOfLines && $n < MAX_NB_OF_LINES) {
             $line = $lines[$n];
             if (strlen($line) > MAX_LINE_LENGTH) {
                 $msg = "line #" . ($n + 1) . " has been truncated to " . MAX_LINE_LENGTH . " characters (out of " . strlen($line) . " characters)\n";
                 $lines[$n] = substr($lines[$n], 0, MAX_LINE_LENGTH) . "... TRUNCATED";
                 trigger_error($msg);
             }
             $text .= $line . "\n";
             $n++;
         }
         if (count($linesTruncated)) {
             $text = "WARNING: Some long lines have been truncated." . "The file might not display correcly\n" . $text;
         }
         $text = implode("\n", $lines);
         if ($nbOfLines > MAX_NB_OF_LINES) {
             $msg = "\nFILE truncated to " . MAX_NB_OF_LINES . " lines (out of " . $nbOfLines . " lines)\n";
             $text .= $msg;
             trigger_error($msg);
         }
         $geshi = new GeSHi();
         $geshi->set_source($text);
         $geshi->set_language($this->geshiLanguage);
         $geshi->set_overall_id($this->sourceId);
         $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
         $geshi->enable_classes();
         $geshi->enable_ids(true);
         $this->geshi = $geshi;
     }
     return $this->geshi;
 }
开发者ID:GitHubTianPeng,项目名称:101worker,代码行数:43,代码来源:megalib_leftover.php


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