function highlight($post, $words, $content)
 {
     $highlight = new Highlighter(get_the_category_list(',', '', $post->ID), $words, true);
     if ($highlight->has_matches()) {
         $highlight->mark_words();
         return '<p><strong>' . __('Category', 'search-unleashed') . ':</strong> ' . $highlight->get() . '</p>';
     }
     return '';
 }
 function highlight($post, $words, $content)
 {
     $highlight = new Highlighter(get_the_author_meta('display_name', $post->post_author), $words, true);
     if ($highlight->has_matches()) {
         $highlight->mark_words();
         return '<p><strong>' . __('Author', 'search-unleashed') . ':</strong> ' . $this->get_author($highlight->get(), $post) . '</p>';
     }
     return '';
 }
 function highlight($post, $words, $content)
 {
     $highlight = new Highlighter($this->get_permalink($post->ID), $words, true);
     if ($highlight->has_matches()) {
         $highlight->mark_words();
         return '<p><strong>' . __('Permalink', 'search-unleashed') . ':</strong> ' . $highlight->get() . '</p>';
     }
     return '';
 }
 function highlight($post, $words, $content)
 {
     if ($this->show) {
         $highlight = new Highlighter($this->gather($post), $words, true);
         if ($highlight->has_matches()) {
             $highlight->mark_words();
             return '<p><strong>' . __('Tags', 'search-unleashed') . ':</strong> ' . $highlight->get() . '</p>';
         }
     }
     return '';
 }
 function highlight($post, $words, $content)
 {
     if (isset($post->comment_id)) {
         $comment = get_comment($post->comment_id);
         $highlight = new Highlighter($this->gather($comment), $words, true);
         if ($highlight->has_matches()) {
             $highlight->mark_words();
             return '<p><strong>' . __('Comment author', 'search-unleashed') . ':</strong> ' . $highlight->get() . '</p>';
         }
     }
     return '';
 }
 function highlight($post, $words, $content)
 {
     global $search_spider;
     // First check if the excerpt is not the same as the content
     $highlight = new Highlighter($content, $words, true);
     if ($highlight->has_matches() && $search_spider->has_highlighted_content == false) {
         $highlight->zoom($this->before, $this->after);
         $highlight->mark_words();
         return '<p><strong>' . __('Excerpt', 'search-unleashed') . ':</strong> ' . $highlight->get() . '</p>';
     }
     return '';
 }
 function highlight($post, $words, $content)
 {
     $meta = $this->the_post_custom($post->ID);
     if (!empty($meta)) {
         $highlight = new Highlighter($meta, $words, true);
         if ($highlight->has_matches()) {
             $highlight->zoom(40, 80);
             $highlight->mark_words();
             return '<p><strong>' . __('Meta-data', 'search-unleashed') . ':</strong> ' . $highlight->get() . '</p>';
         }
     }
     return '';
 }
 /**
  * @covers Xmf\Highlighter::apply
  * @todo   Implement testApply().
  */
 public function testApply()
 {
     $output = Highlighter::apply('test', 'This test is OK.');
     $this->assertEquals($output, 'This <strong>test</strong> is OK.');
     $output = Highlighter::apply(array('test', 'ok'), 'This test is OK.', '<i>', '</i>');
     $this->assertEquals($output, 'This <i>test</i> is <i>OK</i>.');
 }
Exemple #9
0
 /**
  * Create a new highlighter instance for the given format.
  *
  * We use a factory so you can return different objects/classes
  * per format.
  *
  * @param string $format Output format (pdf, xhtml, troff, ...)
  *
  * @return PhDHighlighter Highlighter object
  */
 public static function factory($format)
 {
     if ($format != 'xhtml') {
         return parent::factory($format);
     }
     return new self();
 }
Exemple #10
0
 /**
  * Apply highlight to words in body text
  *
  * Surround occurances of words in body with pre in front and post
  * behing. Considers only occurances of words outside of HTML tags.
  *
  * @param mixed  $words words to highlight
  * @param string $body  body of html text to highlight
  * @param string $pre   string to begin a highlight
  * @param string $post  string to end a highlight
  *
  * @return string highlighted body
  */
 public static function apply($words, $body, $pre = '<strong>', $post = '</strong>')
 {
     if (!is_array($words)) {
         $words = str_replace('  ', ' ', $words);
         $words = explode(' ', $words);
     }
     foreach ($words as $word) {
         $body = Highlighter::splitOnTag($word, $body, $pre, $post);
     }
     return $body;
 }
 function highlight($post, $words, $content)
 {
     $high = new Highlighter($content, $words, true);
     if ($this->noindex === false) {
         global $search_spider;
         $search_spider->has_highlighted_content = true;
         $content = apply_filters('search_unleashed_content', $content, $post);
         $high->zoom($this->before, $this->after);
         $high->mark_words();
     } else {
         $high->zoom($this->before, $this->after);
     }
     return $high->reformat($high->get());
 }
 /**
  * @see	\wcf\system\bbcode\highlighter\Highlighter::highlight()
  */
 public function highlight($string)
 {
     $string = str_replace('span', '053a0024219422ca9215c0a3ed0578ee76cff477', $string);
     // fix to not highlight the spans of the highlighter
     $string = str_replace(':link', ':li@@nk', $string);
     // fix to highlight pseudo-class different than tag
     $string = str_replace(array('right:', 'left:'), array('r@@ight:', 'l@@eft:'), $string);
     // fix to highlight properties different than values
     $string = strtr($string, self::$duplicates);
     // fix to highlight properties different than tags
     $string = parent::highlight($string);
     $string = strtr($string, array_flip(self::$duplicates));
     // fix to highlight properties different than tags
     $string = str_replace(array('r@@ight', 'l@@eft'), array('right', 'left'), $string);
     // fix to highlight properties different than values
     $string = str_replace('li@@nk', 'link', $string);
     // fix to highlight pseudo-class different than tag
     return str_replace('053a0024219422ca9215c0a3ed0578ee76cff477', 'span', $string);
     // fix to not highlight the spans of the highlighter
 }
	function highlight( $post, $words, $content ) {
		if ( isset( $post->comment_id ) ) {
			$comment   = get_comment( $post->comment_id );
			$highlight = new Highlighter( $this->gather( $comment ), $words, true );

			if ( $highlight->has_matches() ) {
				$highlight->zoom( $this->before, $this->after );
				$highlight->mark_words();
			
				if ( $this->include == 'content' )
					return sprintf( __( '<p><strong>Comment:</strong> %s</p>', 'search-unleashed' ), $highlight->get() );
				else if ($this->include == 'link')
					return sprintf( __( '<p><strong>Comment by %s:</strong> %s</p>', 'search-unleashed' ), $this->get_comment_author_link( $comment ), $highlight->get() );
				else if ($this->include == 'name')
					return sprintf( __( '<p><strong>Comment by %s:</strong> %s</p>', 'search-unleashed' ), apply_filters( 'comment_author', apply_filters( 'get_comment_author', $comment->comment_author ) ), $highlight->get() );
			}
		}
		
		return '';
	}
 protected function compare($original, $expected)
 {
     $output = $this->uut->getWholeFile($original);
     $this->assertEquals($expected, $output);
 }
 /**
  * Highlighting for post titles.
  * Note that the_title may be called several times in a theme to display a single post. For this reason we have a 'theme_title_position' so that we only
  * highlight the title on the nth call to this function, per post display
  *
  * @param string $text
  * @return string Title
  */
 function the_title($text)
 {
     // Only if loop_start has been sent
     if (in_the_loop()) {
         global $post;
         // Reset our variables if this is the first time on this post
         if ($this->last_post_id != $post->ID) {
             $this->last_post_id = $post->ID;
             $this->last_post_count = 0;
         }
         $options = $this->get_options();
         // Compare position
         $this->last_post_count++;
         if ($this->last_post_count - 1 == $options['theme_title_position']) {
             $high = new Highlighter($text, $this->engine->get_terms());
             $high->mark_words();
             return $high->get();
         }
     }
     return $text;
 }
*
* copyright Eric Feldstein 2003 2004 mailto:garfield_fr@tiscali.fr
* copyright Didier Loiseau 2004
*
* Licence : la meme que wikini (voir le fichier LICENCE).
* Vous êtes libre d'utiliser et de modifier ce code à condition de laisser le copyright
* d'origine. Vous pouvez  bien sur vous ajouter à la liste des auteurs.
*
* Installation : copier le fichier dans le repertoire "formatters" de WikiNi
*/
// protection contre les appels directs
if (!defined('WIKINI_VERSION')) {
    die('Appel direct interdit');
}
include_once 'formatters/highlighter.class.php';
$DH = new Highlighter();
$DH->isCaseSensitiv = false;
//************* commentaires *************
$DH->comment = array('({[^$][^}]*})', '(\\(\\*[^$](.*)\\*\\))');
$DH->commentLine = array('(//.*(\\n|$))');
//commentaire //
$DH->commentStyle = "color: red; font-style: italic";
//style CSS pour balise SPAN
//************* directives de compilation *************
$DH->directive = array('({\\$[^{}]*})', '(\\(\\*\\$(.*)\\*\\))');
$DH->directiveStyle = "color: green";
//style CSS pour balise SPAN
//************* chaines de caracteres *************
/**
* @todo correction pour l'échappement des guillemets simples
*/
Exemple #17
0
		$CateTitle=\'\';
		//-------------------0
		$SqlStr	= \'SELECT `title` FROM `\'.DB_TABLE_PRE.\'article_cate`\';
		$SqlStr.= \' WHERE 1=1\';
				
		//栏目
		$SqlStr.=$this->SqlCateTitleId;
		
		$MyDatabase=new Database();
		$MyDatabase->SqlStr = $SqlStr;
		if ($MyDatabase->Query ()) {
			$DB_Record = $MyDatabase->ResultArr [0];
			
			$CateTitle= $DB_Record[0];
		}
		return $CateTitle;
	}
?>

<script language=javascript>
alert("as中文dfdsaf");
</script>
<?php
	phpinfo();
?></code>
asdfdsafsadfd<br>saa中文fsafsaf
';
echo Highlighter::Str($str_test);
echo "<hr>";
highlight_string($str_test);
/**/
 private function processSubLanguage()
 {
     try {
         $hl = new Highlighter();
         $hl->autodetectSet = $this->autodetectSet;
         $explicit = is_string($this->top->subLanguage);
         if ($explicit && !isset(array_flip(self::$languages)[$this->top->subLanguage])) {
             return $this->escape($this->modeBuffer);
         }
         if ($explicit) {
             $res = $hl->highlight($this->top->subLanguage, $this->modeBuffer, true, isset($this->continuations[$this->top->subLanguage]) ? $this->continuations[$this->top->subLanguage] : null);
         } else {
             $res = $hl->highlightAuto($this->modeBuffer, count($this->top->subLanguage) ? $this->top->subLanguage : null);
         }
         // Counting embedded language score towards the host language may
         // be disabled with zeroing the containing mode relevance. Usecase
         // in point is Markdown that allows XML everywhere and makes every
         // XML snippet to have a much larger Markdown score.
         if ($this->top->relevance > 0) {
             $this->relevance += $res->relevance;
         }
         if ($explicit) {
             $this->continuations[$this->top->subLanguage] = $res->top;
         }
         return $this->buildSpan($res->language, $res->value, false, true);
     } catch (\Exception $e) {
         error_log("TODO, is this a relevant catch?");
         error_log($e);
         return $this->escape($this->modeBuffer);
     }
 }
 /**
  * Creates a new paste via the API
  *
  * @param  string  $mode
  * @return \Illuminate\Support\Facades\View
  */
 public function postCreate($mode)
 {
     $api = API::make($mode);
     // Set custom messages for validation module
     $custom = array('title.max' => 'title_max_30', 'data.required' => 'data_required', 'data.auth' => 'cannot_post', 'data.mbmax' => 'data_too_big', 'language.required' => 'lang_required', 'language.in' => 'lang_invalid', 'expire.integer' => 'expire_integer', 'expire.in' => 'expire_invalid');
     // Define validation rules
     $validator = Validator::make(Input::all(), array('title' => 'max:30', 'data' => 'required|auth|mbmax:' . Site::config('general')->maxPasteSize, 'language' => 'required|in:' . Highlighter::make()->languages(TRUE), 'expire' => 'integer|in:' . Paste::getExpiration('create', TRUE)), $custom);
     // Run validations
     if ($validator->fails()) {
         return $api->error($validator->messages()->first());
     }
     // Set custom messages for the antispam module
     $custom = array('ipban' => 'antispam_ipban', 'stealth' => 'antispam_stealth', 'censor' => 'antispam_censor', 'noflood' => 'antispam_noflood', 'php' => 'antispam_php');
     // Instantiate the antispam module
     $antispam = Antispam::make('api_call', 'data', $custom);
     // Run the anti-spam modules
     if ($antispam->fails()) {
         return $api->error($antispam->message());
     }
     // Create the paste like a boss!
     $paste = Paste::createNew('api', Input::all());
     // All done! Now we need to output the urlkey and hash
     $data = array('urlkey' => $paste->urlkey, 'hash' => $paste->hash);
     // Return the output
     return $api->out('create', $data);
 }
Exemple #20
0
 /**
  * Highlight a given piece of source code.
  *
  * @param string $text   Text to highlight
  * @param string $role   Source code role to use (php, xml, html, ...)
  * @param string $format Output format (pdf, xhtml, troff, ...)
  *
  * @return string Highlighted code
  */
 public function highlight($text, $role, $format)
 {
     $this->geshi->setSource($text);
     $lang = $this->getGeSHiLanguage($role);
     if ($lang === null) {
         //GeSHi does not support this language.
         // fall back to the default highlighter
         return parent::highlight($text, $role, $format);
     }
     //FIXME: perhaps it is more efficient to
     // keep a geshi instance for each single programming language.
     $this->geshi->setLanguage($lang);
     return $this->geshi->parseCode();
 }
                // Storage
                $lines[$i] = preg_replace('/(class|function|new|public|private|protected|var|interface) /', '<span class="storage">$1</span> ', $lines[$i]);
                // Storage Modifier
                $lines[$i] = preg_replace('/(abstract|extends|implements) /', '<span class="modifier">$1</span> ', $lines[$i]);
            }
        }
        $output = '';
        foreach ($lines as $line) {
            if (!empty($line)) {
                $output .= $line . "\r\n";
            }
        }
        return "<pre class=\"{$lang}\">\n" . $output . "</pre>\n";
    }
}
$hl = new Highlighter();
echo $hl->format('
/**
 * Class Name
 * Description
 * $var
 * @PHPDoc tags
 */
class ClassName extends AnotherClass
{
    function __construct($param)
    {
        # code...
        $classclassclassfunction
        //functionclass
        $this->route = (empty($_GET[\'route\'])) ? $this->c_default : trim($_GET[\'route\'], \'/\\\');
 private function doreplacetag($tag)
 {
     $out = array();
     $child = array();
     $last_root = 0;
     $diff = 0;
     $oldlen = 0;
     $newlen = 0;
     $out = array_reverse($this->out_arr);
     $lastlevel = 0;
     //print_r($out);
     foreach ($out as $key => $item) {
         $idx = !empty($item['attr'][0]) ? 1 : 0;
         $cfgtag = $this->template_tag[$tag][$idx];
         $calcLen = $item['innerLen'] + $diff;
         $innerText = substr($this->html, $item['innerPos'], $calcLen);
         $left = preg_replace("/\\%attr1\\%/si", $item['attr'][0], $cfgtag['begin']);
         for ($i = 1; $i < count($item['attr']) - 1; $i++) {
             $regex = "/\\%attr{$i}\\%/si";
             $left = preg_replace($regex, $item['attr'][$i], $left);
         }
         switch ($tag) {
             case 'list':
                 $inner = preg_replace("#<br>|<br />#si", "", $innerText);
                 $inner = $this->process_list_items($inner);
                 break;
             case 'quote':
                 $inner = $innerText;
                 break;
             case 'code':
                 $inner = preg_replace("#<br>|<br />#si", "", $innerText);
                 // for geshi highlighter
                 if (preg_match('/' . $this->highlight_lang . '/usi', $item['attr'][0])) {
                     $inner = Highlighter::parse($inner, $item['attr'][0]);
                     $inner = preg_replace("#\r?\n#si", "", $inner);
                 }
                 break;
             case 'chk':
                 $chk_arr = preg_split("/[^\\d]+/si", trim($item['attr'][0]));
                 $chk_list = implode("|", $chk_arr);
                 //Kohana::$log->add(Log::INFO,$chk_list." ".trim($item['attr'][0]));
                 $inner = preg_replace("#<br>|<br />#si", "", $innerText);
                 $inner = preg_replace("/\\b({$chk_list})\\b/si", "<span style=\"background-color:orange;\">\$1</span>", $inner);
                 break;
             default:
                 $inner = $innerText;
         }
         //$right = (!empty($item['attr'])) ? $cfgtag['altPos'] : $cfgtag['fPos'] ;
         $right = preg_replace("/\\%attr1\\%/si", $item['attr'][0], $cfgtag['end']);
         for ($i = 1; $i < count($item['attr']) - 1; $i++) {
             $regex = "/\\%attr{$i}\\%/si";
             $right = preg_replace($regex, $item['attr'][$i], $right);
         }
         $newstr = $left . $inner . $right;
         $newlen = strlen($newstr);
         $oldlen = $calcLen + strlen($item['tagLeft']) + strlen($item['tagRight']);
         $this->html = substr_replace($this->html, $newstr, $item['pos'], $oldlen);
         $lastlevel = $item['level'];
         $diff_flag = $lastlevel > 1;
         $diff = $diff_flag ? $diff + ($newlen - $oldlen) : 0;
     }
 }
Exemple #23
0
 </span></pre>
<p>
Single header only, extremely light-weight high performance logging library for C++11 (or higher) applications.<br/>For lower version of C++ (non-C++11), please consider using <a href='https://github.com/easylogging/easyloggingpp/tree/v8.91' target='_blank'>Easylogging++ v8.91</a>.
</p><p>
The strengths of Easylogging++ are its speed and simplicity. It is extremely light-weight, robust, fast performing, thread and type safe and consists of many built-in features. It fits in small to medium sized projects, it provides ability to write logs in your own customized format and also provide support for logging your classes, third-party libraries, STL and third-party containers etc.
</p>
<p>
You may wish to have a look at <a href='http://easylogging.org/sample.log'>sample log file</a> generated from a project.
</p>
<table width="100%">
<tr>
<td width="50%">
    <?php 
require_once "tools/syntax_highlighter/cppToHtmlSyntaxHighlighter.php";
$codeBlock = "[cpp_code_no_line]:Simple Example;\n    #include \"easylogging++.h\"\n\n    INITIALIZE_EASYLOGGINGPP\n\n    int main(int argc, const char** argv) {\n        LOG(INFO) << \"Hello, world\";\n        return 0;\n    }[/cpp_code]";
$highlighter = new Highlighter();
$htmlCppCode = $highlighter->findCppCodeInHtmlBlock($codeBlock);
print $htmlCppCode;
?>
</td>
<td width="50%">
    <a href='https://github.com/easylogging/easyloggingpp/releases/latest' class='big-link'><img src='/images/download.png' />&nbsp;Download Easylogging++</a><br/>
    <a href='/release-notes-latest.txt?v=<?php 
print $currentVersion;
?>
' class='big-link'><img src='/images/notes.png' />&nbsp;Release Notes</a><br/>
    <a href='https://github.com/easylogging/easyloggingpp/blob/master/README.md' class='big-link'><img src='/images/help.png' />&nbsp;Manual</a><br/>
    <a href='https://github.com/easylogging/easyloggingpp' class='big-link'><img src='/images/github.png' />&nbsp;Source @ Github</a><br/>
    <a href='https://github.com/easylogging/easyloggingpp/tree/master/samples' class='big-link'><img src='/images/sample.png' />&nbsp;Samples</a><br/>
</td>
</tr>
 /**
  * Editor window for creating a revision
  *
  * @param  string  $urlkey
  * @return \Illuminate\Support\Facades\View|\Illuminate\Support\Facades\Redirect
  */
 public function getRevision($urlkey)
 {
     $paste = Paste::where('urlkey', $urlkey)->first();
     // Paste was not found
     if (is_null($paste)) {
         App::abort(404);
         // Not found
     } else {
         // We only allow the user to revise public pastes
         // Private pastes need to be toggled before being revised
         if ($paste->private or $paste->password) {
             Session::flash('messages.error', Lang::get('create.revise_private'));
             return Redirect::to(URL::previous())->withInput();
         }
         // Now that we are good, we save the paste ID in session so that
         // when the edited paste is POSTed, we can validate against this
         Session::put('paste.revision', $paste->id);
     }
     // Output the view
     $data = array('languages' => Highlighter::make()->languages(), 'language' => 'text', 'paste' => $paste, 'action' => 'CreateController@postRevision', 'disabled' => 'disabled', 'attach' => FALSE);
     return View::make('site/create', $data);
 }