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


PHP GeSHi::set_language_path方法代码示例

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


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

示例1: onExtra

 function onExtra($name)
 {
     $output = NULL;
     if ($name == "header") {
         if (!$this->yellow->config->get("highlightStylesheetDefault")) {
             $locationStylesheet = $this->yellow->config->get("serverBase") . $this->yellow->config->get("pluginLocation") . "highlight.css";
             $fileNameStylesheet = $this->yellow->config->get("pluginDir") . "highlight.css";
             if (is_file($fileNameStylesheet)) {
                 $output = "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"{$locationStylesheet}\" />\n";
             }
         } else {
             $geshi = new GeSHi();
             $geshi->set_language_path($this->yellow->config->get("pluginDir") . "/highlight/");
             foreach ($geshi->get_supported_languages() as $language) {
                 if ($language == "geshi") {
                     continue;
                 }
                 $geshi->set_language($language);
                 $output .= $geshi->get_stylesheet(false);
             }
             $output = "<style type=\"text/css\">\n{$output}</style>";
         }
     }
     return $output;
 }
开发者ID:nogginfuel,项目名称:yellow-extensions,代码行数:25,代码来源:highlight.php

示例2: parse_single

 /**
  * Method highlights single code block. If the language file is overriden
  * in sfGeshiPlugin/lib/custom directory, it uses it. Otherwise, it uses
  * default GeSHi language file from its lib.
  *
  * @param String $code - code block.
  * @param String $language - language name of the code block.
  */
 public static function parse_single($code, $language)
 {
     $geshi_object = new GeSHi($code, $language);
     $alternative_directory = GESHI_LANG_ROOT . '../../custom/';
     $alternative_file = $alternative_directory . strtolower($language) . '.php';
     if (file_exists($alternative_file)) {
         $geshi_object->set_language_path($alternative_directory);
     }
     return $geshi_object->parse_code();
 }
开发者ID:skoop,项目名称:phpCodeControl,代码行数:18,代码来源:sfGeshi.class.php

示例3: prepare

 /**
  * Initialise a GeSHi object to format some code, performing
  * common setup for all our uses of it
  *
  * @param string $text
  * @param string $lang
  * @return GeSHi
  */
 public static function prepare($text, $lang)
 {
     global $wgTitle, $wgOut;
     self::initialise();
     $geshi = new GeSHi($text, $lang);
     if ($geshi->error() == GESHI_ERROR_NO_SUCH_LANG) {
         return null;
     }
     $geshi->set_encoding('UTF-8');
     $geshi->enable_classes();
     $geshi->set_overall_class("source-{$lang}");
     $geshi->enable_keyword_links(false);
     // Wikia change start
     if ($wgTitle instanceof Title && EditPageLayoutHelper::isCodeSyntaxHighlightingEnabled($wgTitle)) {
         $theme = 'solarized-light';
         if (SassUtil::isThemeDark()) {
             $theme = 'solarized-dark';
         }
         $geshi->set_language_path(GESHI_ROOT . $theme . DIRECTORY_SEPARATOR);
         $geshi->set_overall_id('theme-' . $theme);
         $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/SyntaxHighlight_GeSHi/styles/solarized.scss'));
     }
     // Wikia change end
     return $geshi;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:33,代码来源:SyntaxHighlight_GeSHi.class.php

示例4: do_geshi

/**
 * do_geshi() - Performs GeSHi transforms on XHTML blobs
 *
 * @param $blob str  - The blob to transform
 * @param $open str  - Opening expression to match
 * @param $close str - Closing expression to match
 * @param $lang str  - Language file to use
 *
 **********************************************************/
function do_geshi($blob, $open = '<pre>', $close = '</pre>', $lang = 'c')
{
    $out = FALSE;
    $regexp = '|' . $open . '(.*?)' . $close . '|si';
    echo $regexp . "\n\n";
    while (preg_match($regexp, $blob, $matches)) {
        $geshi = new GeSHi($matches[1], $lang);
        $geshi->set_language_path($geshi_lang);
        $blob_new = $geshi->parse_code();
        // Strip annoying final <br />
        $blob_new = preg_replace('/\\n&nbsp;<\\/pre>/', '</pre>', $blob_new);
        // Fix annoying GeSHI-injected attributes
        $blob_new = preg_replace('/<pre.*>/i', '<pre>', $blob_new);
        $blob = preg_replace($regexp, $blob_new, $blob, 1);
        unset($geshi);
    }
    return $out;
}
开发者ID:hinike,项目名称:opera,代码行数:27,代码来源:vp8_doc_tools.php

示例5: geshiFactory

 /**
  * Helper function for generating a GeSHi object.
  *
  * @param string $source_code
  *   The source code to process.
  * @param string $language
  *   The language to generate a GeSHi object for.
  *
  * @return \GeSHi
  *   Return a Geshi class object.
  */
 public static function geshiFactory($source_code, $language)
 {
     $available_languages = GeshiFilter::getAvailableLanguages();
     $geshi = new \GeSHi($source_code, $language);
     $geshi->set_language_path($available_languages[$language]['language_path']);
     return $geshi;
 }
开发者ID:hugronaphor,项目名称:cornel,代码行数:18,代码来源:GeshiFilterProcess.php

示例6: GeSHi

$regexp = '|<pre><code>(.*?)<\\/code><\\/pre>|si';
while (preg_match($regexp, $page_body, $matches) > 0) {
    // Replace 1st match with token
    $page_body = preg_replace($regexp, $tmp_token, $page_body, 1);
    $block_new = $matches[1];
    // Un-encode ampersand entities
    $block_new = decode_markdown($block_new);
    // Replace token with revised string
    $page_body = preg_replace("|{$tmp_token}|", '<div class="codeblock">' . $block_new . '</div>', $page_body);
}
// Run GeSHi over code blocks
$regexp = '|<div class="codeblock">(.*?)<\\/div>|si';
$language = 'c';
while (preg_match($regexp, $page_body, $matches)) {
    $geshi = new GeSHi($matches[1], $language);
    $geshi->set_language_path($geshi_path);
    $block_new = $geshi->parse_code();
    // Strip annoying final newline
    $block_new = preg_replace('|\\n&nbsp;<\\/pre>|', '</pre>', $block_new);
    // Remove style attribute (TODO: Research this in GeSHi)
    $block_new = preg_replace('| style="font-family:monospace;"|', '', $block_new);
    $page_body = preg_replace($regexp, $block_new, $page_body, 1);
    unset($geshi);
    // Clean up
}
unset($block_new);
// Clean up
// Apply typographic flourishes
$page_body = SmartyPants($page_body);
/**
 *  Generate Doxygen Body
开发者ID:hinike,项目名称:opera,代码行数:31,代码来源:gen_example_doxy.php

示例7: getAvailableLanguages

 /**
  * List of available languages.
  *
  * @return array
  *   An array mapping language code to array with the language path and
  *   full language name.
  */
 public static function getAvailableLanguages()
 {
     // Try to get it from cache (database actually).
     $cache = \Drupal::cache();
     $available_languages = $cache->get('geshifilter_available_languages_cache');
     if (!$available_languages) {
         // Not in cache: build the array of available_languages.
         $geshi_library = libraries_load('geshi');
         $available_languages = array();
         if ($geshi_library['loaded']) {
             $dirs = array($geshi_library['library path'] . '/geshi', drupal_get_path('module', 'geshifilter') . '/geshi-extra');
             foreach ($dirs as $dir) {
                 foreach (file_scan_directory($dir, '/.[pP][hH][pP]$/i') as $filename => $fileinfo) {
                     // Short name.
                     $name = $fileinfo->name;
                     // Get full name.
                     $geshi = new \GeSHi('', $name);
                     $geshi->set_language_path($dir);
                     $fullname = $geshi->get_language_name();
                     unset($geshi);
                     // Store.
                     $available_languages[$name] = array('language_path' => $dir, 'fullname' => $fullname);
                 }
             }
             ksort($available_languages);
             // Save array to database.
             $cache->set('geshifilter_available_languages_cache', $available_languages);
         }
     } else {
         $available_languages = $available_languages->data;
     }
     return $available_languages;
 }
开发者ID:hugronaphor,项目名称:cornel,代码行数:40,代码来源:GeshiFilter.php


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