This document contains information for an outdated version <% if $Version %>($Version)<% end_if %> and may not be maintained any more. If some of your projects still use this version, consider upgrading as soon as possible.
6 | <% else_if FutureRelease %>
7 |
This document contains information about a future release <% if $VersionWarning.StableVersion %>and not the current stable version ($VersionWarning.StableVersion)<% end_if %>. Be aware that information on this page may change and API's may not be stable for production use.
46 | <% end_if %>
--------------------------------------------------------------------------------
/templates/OpenSearchDescription.ss:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | <% if ShortName %>$ShortName<% end_if %>
5 | <% if Description %>$Description<% end_if %>
6 | <% if Tags %>$Tags<% end_if %>
7 | <% if Contact %>$Content<% end_if %>
8 |
9 | <% if SearchPageLink %><% end_if %>
10 | <% if SearchPageAtom %><% end_if %>
11 | <% if SearchPageJson %><% end_if %>
12 |
--------------------------------------------------------------------------------
/templates/OpenSearchResults.ss:
--------------------------------------------------------------------------------
1 |
2 |
3 | $Title
4 | $Link
5 |
6 | $Author
7 |
8 |
9 | $Now
10 | $TotalResults
11 | $StartResult
12 | $PageLength
13 |
14 | <% loop Results %>
15 |
16 | <% if BreadcrumbTitle %>$BreadcrumbTitle<% else %>$Title<% end_if %>
17 | $Link
18 | urn:uuid:$ID
19 | $Content.LimitCharacters(200)
20 |
21 | <% end_loop %>
22 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Exception.php:
--------------------------------------------------------------------------------
1 | _filters[] = $filter;
80 | }
81 |
82 | /**
83 | * Apply filters to the token. Can return null when the token was removed.
84 | *
85 | * @param Zend_Search_Lucene_Analysis_Token $token
86 | * @return Zend_Search_Lucene_Analysis_Token
87 | */
88 | public function normalize(Zend_Search_Lucene_Analysis_Token $token)
89 | {
90 | foreach ($this->_filters as $filter) {
91 | $token = $filter->normalize($token);
92 |
93 | // resulting token can be null if the filter removes it
94 | if ($token === null) {
95 | return null;
96 | }
97 | }
98 |
99 | return $token;
100 | }
101 | }
102 |
103 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php:
--------------------------------------------------------------------------------
1 | _position = 0;
53 |
54 | if ($this->_input === null) {
55 | return;
56 | }
57 |
58 | // convert input into ascii
59 | if (PHP_OS != 'AIX') {
60 | $this->_input = iconv($this->_encoding, 'ASCII//TRANSLIT', $this->_input);
61 | }
62 | $this->_encoding = 'ASCII';
63 | }
64 |
65 | /**
66 | * Tokenization stream API
67 | * Get next token
68 | * Returns null at the end of stream
69 | *
70 | * @return Zend_Search_Lucene_Analysis_Token|null
71 | */
72 | public function nextToken()
73 | {
74 | if ($this->_input === null) {
75 | return null;
76 | }
77 |
78 |
79 | do {
80 | if (! preg_match('/[a-zA-Z]+/', $this->_input, $match, PREG_OFFSET_CAPTURE, $this->_position)) {
81 | // It covers both cases a) there are no matches (preg_match(...) === 0)
82 | // b) error occured (preg_match(...) === FALSE)
83 | return null;
84 | }
85 |
86 | $str = $match[0][0];
87 | $pos = $match[0][1];
88 | $endpos = $pos + strlen($str);
89 |
90 | $this->_position = $endpos;
91 |
92 | $token = $this->normalize(new Zend_Search_Lucene_Analysis_Token($str, $pos, $endpos));
93 | } while ($token === null); // try again if token is skipped
94 |
95 | return $token;
96 | }
97 | }
98 |
99 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Analysis/Analyzer/Common/Text/CaseInsensitive.php:
--------------------------------------------------------------------------------
1 | addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_LowerCase());
49 | }
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum.php:
--------------------------------------------------------------------------------
1 | _position = 0;
53 |
54 | if ($this->_input === null) {
55 | return;
56 | }
57 |
58 | // convert input into ascii
59 | if (PHP_OS != 'AIX') {
60 | $this->_input = iconv($this->_encoding, 'ASCII//TRANSLIT', $this->_input);
61 | }
62 | $this->_encoding = 'ASCII';
63 | }
64 |
65 | /**
66 | * Tokenization stream API
67 | * Get next token
68 | * Returns null at the end of stream
69 | *
70 | * @return Zend_Search_Lucene_Analysis_Token|null
71 | */
72 | public function nextToken()
73 | {
74 | if ($this->_input === null) {
75 | return null;
76 | }
77 |
78 | do {
79 | if (! preg_match('/[a-zA-Z0-9]+/', $this->_input, $match, PREG_OFFSET_CAPTURE, $this->_position)) {
80 | // It covers both cases a) there are no matches (preg_match(...) === 0)
81 | // b) error occured (preg_match(...) === FALSE)
82 | return null;
83 | }
84 |
85 | $str = $match[0][0];
86 | $pos = $match[0][1];
87 | $endpos = $pos + strlen($str);
88 |
89 | $this->_position = $endpos;
90 |
91 | $token = $this->normalize(new Zend_Search_Lucene_Analysis_Token($str, $pos, $endpos));
92 | } while ($token === null); // try again if token is skipped
93 |
94 | return $token;
95 | }
96 | }
97 |
98 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum/CaseInsensitive.php:
--------------------------------------------------------------------------------
1 | addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_LowerCase());
49 | }
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8.php:
--------------------------------------------------------------------------------
1 | _position = 0;
74 | $this->_bytePosition = 0;
75 |
76 | // convert input into UTF-8
77 | if (strcasecmp($this->_encoding, 'utf8') != 0
78 | && strcasecmp($this->_encoding, 'utf-8') != 0
79 | ) {
80 | $this->_input = iconv($this->_encoding, 'UTF-8', $this->_input);
81 | $this->_encoding = 'UTF-8';
82 | }
83 | }
84 |
85 | /**
86 | * Tokenization stream API
87 | * Get next token
88 | * Returns null at the end of stream
89 | *
90 | * @return Zend_Search_Lucene_Analysis_Token|null
91 | */
92 | public function nextToken()
93 | {
94 | if ($this->_input === null) {
95 | return null;
96 | }
97 |
98 | do {
99 | if (! preg_match('/[\p{L}]+/u', $this->_input, $match, PREG_OFFSET_CAPTURE, $this->_bytePosition)) {
100 | // It covers both cases a) there are no matches (preg_match(...) === 0)
101 | // b) error occured (preg_match(...) === FALSE)
102 | return null;
103 | }
104 |
105 | // matched string
106 | $matchedWord = $match[0][0];
107 |
108 | // binary position of the matched word in the input stream
109 | $binStartPos = $match[0][1];
110 |
111 | // character position of the matched word in the input stream
112 | $startPos = $this->_position +
113 | iconv_strlen(
114 | substr(
115 | $this->_input,
116 | $this->_bytePosition,
117 | $binStartPos - $this->_bytePosition
118 | ),
119 | 'UTF-8'
120 | );
121 | // character postion of the end of matched word in the input stream
122 | $endPos = $startPos + iconv_strlen($matchedWord, 'UTF-8');
123 |
124 | $this->_bytePosition = $binStartPos + strlen($matchedWord);
125 | $this->_position = $endPos;
126 |
127 | $token = $this->normalize(new Zend_Search_Lucene_Analysis_Token($matchedWord, $startPos, $endPos));
128 | } while ($token === null); // try again if token is skipped
129 |
130 | return $token;
131 | }
132 | }
133 |
134 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8/CaseInsensitive.php:
--------------------------------------------------------------------------------
1 | addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8());
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num.php:
--------------------------------------------------------------------------------
1 | _position = 0;
74 | $this->_bytePosition = 0;
75 |
76 | // convert input into UTF-8
77 | if (strcasecmp($this->_encoding, 'utf8') != 0
78 | && strcasecmp($this->_encoding, 'utf-8') != 0
79 | ) {
80 | $this->_input = iconv($this->_encoding, 'UTF-8', $this->_input);
81 | $this->_encoding = 'UTF-8';
82 | }
83 | }
84 |
85 | /**
86 | * Tokenization stream API
87 | * Get next token
88 | * Returns null at the end of stream
89 | *
90 | * @return Zend_Search_Lucene_Analysis_Token|null
91 | */
92 | public function nextToken()
93 | {
94 | if ($this->_input === null) {
95 | return null;
96 | }
97 |
98 | do {
99 | if (! preg_match('/[\p{L}\p{N}]+/u', $this->_input, $match, PREG_OFFSET_CAPTURE, $this->_bytePosition)) {
100 | // It covers both cases a) there are no matches (preg_match(...) === 0)
101 | // b) error occured (preg_match(...) === FALSE)
102 | return null;
103 | }
104 |
105 | // matched string
106 | $matchedWord = $match[0][0];
107 |
108 | // binary position of the matched word in the input stream
109 | $binStartPos = $match[0][1];
110 |
111 | // character position of the matched word in the input stream
112 | $startPos = $this->_position +
113 | iconv_strlen(
114 | substr(
115 | $this->_input,
116 | $this->_bytePosition,
117 | $binStartPos - $this->_bytePosition
118 | ),
119 | 'UTF-8'
120 | );
121 | // character postion of the end of matched word in the input stream
122 | $endPos = $startPos + iconv_strlen($matchedWord, 'UTF-8');
123 |
124 | $this->_bytePosition = $binStartPos + strlen($matchedWord);
125 | $this->_position = $endPos;
126 |
127 | $token = $this->normalize(new Zend_Search_Lucene_Analysis_Token($matchedWord, $startPos, $endPos));
128 | } while ($token === null); // try again if token is skipped
129 |
130 | return $token;
131 | }
132 | }
133 |
134 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num/CaseInsensitive.php:
--------------------------------------------------------------------------------
1 | addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_LowerCaseUtf8());
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Analysis/Token.php:
--------------------------------------------------------------------------------
1 | _termText = $text;
90 | $this->_startOffset = $start;
91 | $this->_endOffset = $end;
92 |
93 | $this->_positionIncrement = 1;
94 | }
95 |
96 |
97 | /**
98 | * positionIncrement setter
99 | *
100 | * @param integer $positionIncrement
101 | */
102 | public function setPositionIncrement($positionIncrement)
103 | {
104 | $this->_positionIncrement = $positionIncrement;
105 | }
106 |
107 | /**
108 | * Returns the position increment of this Token.
109 | *
110 | * @return integer
111 | */
112 | public function getPositionIncrement()
113 | {
114 | return $this->_positionIncrement;
115 | }
116 |
117 | /**
118 | * Returns the Token's term text.
119 | *
120 | * @return string
121 | */
122 | public function getTermText()
123 | {
124 | return $this->_termText;
125 | }
126 |
127 | /**
128 | * Returns this Token's starting offset, the position of the first character
129 | * corresponding to this token in the source text.
130 | *
131 | * Note:
132 | * The difference between getEndOffset() and getStartOffset() may not be equal
133 | * to strlen(Zend_Search_Lucene_Analysis_Token::getTermText()), as the term text may have been altered
134 | * by a stemmer or some other filter.
135 | *
136 | * @return integer
137 | */
138 | public function getStartOffset()
139 | {
140 | return $this->_startOffset;
141 | }
142 |
143 | /**
144 | * Returns this Token's ending offset, one greater than the position of the
145 | * last character corresponding to this token in the source text.
146 | *
147 | * @return integer
148 | */
149 | public function getEndOffset()
150 | {
151 | return $this->_endOffset;
152 | }
153 | }
154 |
155 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Analysis/TokenFilter.php:
--------------------------------------------------------------------------------
1 | getTermText()),
52 | $srcToken->getStartOffset(),
53 | $srcToken->getEndOffset()
54 | );
55 |
56 | $newToken->setPositionIncrement($srcToken->getPositionIncrement());
57 |
58 | return $newToken;
59 | }
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Analysis/TokenFilter/LowerCaseUtf8.php:
--------------------------------------------------------------------------------
1 | getTermText(), 'UTF-8'),
64 | $srcToken->getStartOffset(),
65 | $srcToken->getEndOffset()
66 | );
67 |
68 | $newToken->setPositionIncrement($srcToken->getPositionIncrement());
69 |
70 | return $newToken;
71 | }
72 | }
73 |
74 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Analysis/TokenFilter/ShortWords.php:
--------------------------------------------------------------------------------
1 | length = $length;
57 | }
58 |
59 | /**
60 | * Normalize Token or remove it (if null is returned)
61 | *
62 | * @param Zend_Search_Lucene_Analysis_Token $srcToken
63 | * @return Zend_Search_Lucene_Analysis_Token
64 | */
65 | public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
66 | {
67 | if (strlen($srcToken->getTermText()) < $this->length) {
68 | return null;
69 | } else {
70 | return $srcToken;
71 | }
72 | }
73 | }
74 |
75 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Analysis/TokenFilter/StopWords.php:
--------------------------------------------------------------------------------
1 | 1, 'an' => '1');
31 | *
32 | * We do recommend to provide all words in lowercase and concatenate this class after the lowercase filter.
33 | *
34 | * @category Zend
35 | * @package Zend_Search_Lucene
36 | * @subpackage Analysis
37 | * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
38 | * @license http://framework.zend.com/license/new-bsd New BSD License
39 | */
40 |
41 | class Zend_Search_Lucene_Analysis_TokenFilter_StopWords extends Zend_Search_Lucene_Analysis_TokenFilter
42 | {
43 | /**
44 | * Stop Words
45 | *
46 | * @var array
47 | */
48 | private $_stopSet;
49 |
50 | /**
51 | * Constructs new instance of this filter.
52 | *
53 | * @param array $stopwords array (set) of words that will be filtered out
54 | */
55 | public function __construct($stopwords = array())
56 | {
57 | $this->_stopSet = array_flip($stopwords);
58 | }
59 |
60 | /**
61 | * Normalize Token or remove it (if null is returned)
62 | *
63 | * @param Zend_Search_Lucene_Analysis_Token $srcToken
64 | * @return Zend_Search_Lucene_Analysis_Token
65 | */
66 | public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
67 | {
68 | if (array_key_exists($srcToken->getTermText(), $this->_stopSet)) {
69 | return null;
70 | } else {
71 | return $srcToken;
72 | }
73 | }
74 |
75 | /**
76 | * Fills stopwords set from a text file. Each line contains one stopword, lines with '#' in the first
77 | * column are ignored (as comments).
78 | *
79 | * You can call this method one or more times. New stopwords are always added to current set.
80 | *
81 | * @param string $filepath full path for text file with stopwords
82 | * @throws Zend_Search_Exception When the file doesn`t exists or is not readable.
83 | */
84 | public function loadFromFile($filepath = null)
85 | {
86 | if (! $filepath || ! file_exists($filepath)) {
87 | include_once 'Zend/Search/Lucene/Exception.php';
88 | throw new Zend_Search_Lucene_Exception('You have to provide valid file path');
89 | }
90 | $fd = fopen($filepath, "r");
91 | if (! $fd) {
92 | include_once 'Zend/Search/Lucene/Exception.php';
93 | throw new Zend_Search_Lucene_Exception('Cannot open file ' . $filepath);
94 | }
95 | while (!feof($fd)) {
96 | $buffer = trim(fgets($fd));
97 | if (strlen($buffer) > 0 && $buffer[0] != '#') {
98 | $this->_stopSet[$buffer] = 1;
99 | }
100 | }
101 | if (!fclose($fd)) {
102 | include_once 'Zend/Search/Lucene/Exception.php';
103 | throw new Zend_Search_Lucene_Exception('Cannot close file ' . $filepath);
104 | }
105 | }
106 | }
107 |
108 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Document.php:
--------------------------------------------------------------------------------
1 | getFieldValue($offset);
68 | }
69 |
70 |
71 | /**
72 | * Add a field object to this document.
73 | *
74 | * @param Zend_Search_Lucene_Field $field
75 | * @return Zend_Search_Lucene_Document
76 | */
77 | public function addField(Zend_Search_Lucene_Field $field)
78 | {
79 | $this->_fields[$field->name] = $field;
80 |
81 | return $this;
82 | }
83 |
84 |
85 | /**
86 | * Return an array with the names of the fields in this document.
87 | *
88 | * @return array
89 | */
90 | public function getFieldNames()
91 | {
92 | return array_keys($this->_fields);
93 | }
94 |
95 |
96 | /**
97 | * Returns Zend_Search_Lucene_Field object for a named field in this document.
98 | *
99 | * @param string $fieldName
100 | * @return Zend_Search_Lucene_Field
101 | */
102 | public function getField($fieldName)
103 | {
104 | if (!array_key_exists($fieldName, $this->_fields)) {
105 | include_once 'Zend/Search/Lucene/Exception.php';
106 | throw new Zend_Search_Lucene_Exception("Field name \"$fieldName\" not found in document.");
107 | }
108 | return $this->_fields[$fieldName];
109 | }
110 |
111 |
112 | /**
113 | * Returns the string value of a named field in this document.
114 | *
115 | * @see __get()
116 | * @return string
117 | */
118 | public function getFieldValue($fieldName)
119 | {
120 | return $this->getField($fieldName)->value;
121 | }
122 |
123 | /**
124 | * Returns the string value of a named field in UTF-8 encoding.
125 | *
126 | * @see __get()
127 | * @return string
128 | */
129 | public function getFieldUtf8Value($fieldName)
130 | {
131 | return $this->getField($fieldName)->getUtf8Value();
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Document/Exception.php:
--------------------------------------------------------------------------------
1 | getFromName("_rels/.rels"));
89 | foreach ($relations->Relationship as $rel) {
90 | if ($rel["Type"] == Zend_Search_Lucene_Document_OpenXml::SCHEMA_COREPROPERTIES) {
91 | // Found core properties! Read in contents...
92 | $contents = simplexml_load_string(
93 | $package->getFromName(dirname($rel["Target"]) . "/" . basename($rel["Target"]))
94 | );
95 |
96 | foreach ($contents->children(Zend_Search_Lucene_Document_OpenXml::SCHEMA_DUBLINCORE) as $child) {
97 | $coreProperties[$child->getName()] = (string)$child;
98 | }
99 | foreach ($contents->children(Zend_Search_Lucene_Document_OpenXml::SCHEMA_COREPROPERTIES) as $child) {
100 | $coreProperties[$child->getName()] = (string)$child;
101 | }
102 | foreach ($contents->children(Zend_Search_Lucene_Document_OpenXml::SCHEMA_DUBLINCORETERMS) as $child) {
103 | $coreProperties[$child->getName()] = (string)$child;
104 | }
105 | }
106 | }
107 |
108 | return $coreProperties;
109 | }
110 |
111 | /**
112 | * Determine absolute zip path
113 | *
114 | * @param string $path
115 | * @return string
116 | */
117 | protected function absoluteZipPath($path)
118 | {
119 | $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
120 | $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
121 | $absolutes = array();
122 | foreach ($parts as $part) {
123 | if ('.' == $part) { continue;
124 | }
125 | if ('..' == $part) {
126 | array_pop($absolutes);
127 | } else {
128 | $absolutes[] = $part;
129 | }
130 | }
131 | return implode('/', $absolutes);
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Exception.php:
--------------------------------------------------------------------------------
1 | _object = $object;
56 | $this->_method = $method;
57 | }
58 |
59 | public function doAction()
60 | {
61 | $methodName = $this->_method;
62 | $this->_object->$methodName();
63 | }
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Index/DocsFilter.php:
--------------------------------------------------------------------------------
1 | => array( => ,
41 | * => ,
42 | * => ,
43 | * ... ),
44 | * => array( => ,
45 | * => ,
46 | * => ,
47 | * ... ),
48 | * => array( => ,
49 | * => ,
50 | * => ,
51 | * ... ),
52 | * ...
53 | * )
54 | *
55 | * @var array
56 | */
57 | public $segmentFilters = array();
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Index/FieldInfo.php:
--------------------------------------------------------------------------------
1 | name = $name;
43 | $this->isIndexed = $isIndexed;
44 | $this->number = $number;
45 | $this->storeTermVector = $storeTermVector;
46 | $this->normsOmitted = $normsOmitted;
47 | $this->payloadsStored = $payloadsStored;
48 | }
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Index/SegmentWriter/StreamWriter.php:
--------------------------------------------------------------------------------
1 | _fdxFile = $this->_directory->createFile($this->_name . '.fdx');
55 | $this->_fdtFile = $this->_directory->createFile($this->_name . '.fdt');
56 |
57 | $this->_files[] = $this->_name . '.fdx';
58 | $this->_files[] = $this->_name . '.fdt';
59 | }
60 |
61 | public function addNorm($fieldName, $normVector)
62 | {
63 | if (isset($this->_norms[$fieldName])) {
64 | $this->_norms[$fieldName] .= $normVector;
65 | } else {
66 | $this->_norms[$fieldName] = $normVector;
67 | }
68 | }
69 |
70 | /**
71 | * Close segment, write it to disk and return segment info
72 | *
73 | * @return Zend_Search_Lucene_Index_SegmentInfo
74 | */
75 | public function close()
76 | {
77 | if ($this->_docCount == 0) {
78 | return null;
79 | }
80 |
81 | $this->_dumpFNM();
82 | $this->_generateCFS();
83 |
84 | /**
85 | * Zend_Search_Lucene_Index_SegmentInfo
86 | */
87 | include_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
88 |
89 | return new Zend_Search_Lucene_Index_SegmentInfo(
90 | $this->_directory,
91 | $this->_name,
92 | $this->_docCount,
93 | -1,
94 | null,
95 | true,
96 | true
97 | );
98 | }
99 | }
100 |
101 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Index/Term.php:
--------------------------------------------------------------------------------
1 | field = ($field === null)? Zend_Search_Lucene::getDefaultSearchField() : $field;
61 | $this->text = $text;
62 | }
63 |
64 |
65 | /**
66 | * Returns term key
67 | *
68 | * @return string
69 | */
70 | public function key()
71 | {
72 | return $this->field . chr(0) . $this->text;
73 | }
74 |
75 | /**
76 | * Get term prefix
77 | *
78 | * @param string $str
79 | * @param integer $length
80 | * @return string
81 | */
82 | public static function getPrefix($str, $length)
83 | {
84 | $prefixBytes = 0;
85 | $prefixChars = 0;
86 | while ($prefixBytes < strlen($str) && $prefixChars < $length) {
87 | $charBytes = 1;
88 | if ((ord($str[$prefixBytes]) & 0xC0) == 0xC0) {
89 | $charBytes++;
90 | if (ord($str[$prefixBytes]) & 0x20 ) {
91 | $charBytes++;
92 | if (ord($str[$prefixBytes]) & 0x10 ) {
93 | $charBytes++;
94 | }
95 | }
96 | }
97 |
98 | if ($prefixBytes + $charBytes > strlen($str)) {
99 | // wrong character
100 | break;
101 | }
102 |
103 | $prefixChars++;
104 | $prefixBytes += $charBytes;
105 | }
106 |
107 | return substr($str, 0, $prefixBytes);
108 | }
109 |
110 | /**
111 | * Get UTF-8 string length
112 | *
113 | * @param string $str
114 | * @return string
115 | */
116 | public static function getLength($str)
117 | {
118 | $bytes = 0;
119 | $chars = 0;
120 | while ($bytes < strlen($str)) {
121 | $charBytes = 1;
122 | if ((ord($str[$bytes]) & 0xC0) == 0xC0) {
123 | $charBytes++;
124 | if (ord($str[$bytes]) & 0x20 ) {
125 | $charBytes++;
126 | if (ord($str[$bytes]) & 0x10 ) {
127 | $charBytes++;
128 | }
129 | }
130 | }
131 |
132 | if ($bytes + $charBytes > strlen($str)) {
133 | // wrong character
134 | break;
135 | }
136 |
137 | $chars++;
138 | $bytes += $charBytes;
139 | }
140 |
141 | return $chars;
142 | }
143 | }
144 |
145 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Index/TermInfo.php:
--------------------------------------------------------------------------------
1 | docFreq = $docFreq;
74 | $this->freqPointer = $freqPointer;
75 | $this->proxPointer = $proxPointer;
76 | $this->skipOffset = $skipOffset;
77 | $this->indexPointer = $indexPointer;
78 | }
79 | }
80 |
81 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Index/TermsPriorityQueue.php:
--------------------------------------------------------------------------------
1 | currentTerm()->key(), $termsStream2->currentTerm()->key()) < 0;
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Index/TermsStream/Interface.php:
--------------------------------------------------------------------------------
1 | _heap);
66 | $parentId = ($nodeId-1) >> 1; // floor( ($nodeId-1)/2 )
67 |
68 | while ($nodeId != 0 && $this->_less($element, $this->_heap[$parentId])) {
69 | // Move parent node down
70 | $this->_heap[$nodeId] = $this->_heap[$parentId];
71 |
72 | // Move pointer to the next level of tree
73 | $nodeId = $parentId;
74 | $parentId = ($nodeId-1) >> 1; // floor( ($nodeId-1)/2 )
75 | }
76 |
77 | // Put new node into the tree
78 | $this->_heap[$nodeId] = $element;
79 | }
80 |
81 |
82 | /**
83 | * Return least element of the queue
84 | *
85 | * Constant time
86 | *
87 | * @return mixed
88 | */
89 | public function top()
90 | {
91 | if (count($this->_heap) == 0) {
92 | return null;
93 | }
94 |
95 | return $this->_heap[0];
96 | }
97 |
98 |
99 | /**
100 | * Removes and return least element of the queue
101 | *
102 | * O(log(N)) time
103 | *
104 | * @return mixed
105 | */
106 | public function pop()
107 | {
108 | if (count($this->_heap) == 0) {
109 | return null;
110 | }
111 |
112 | $top = $this->_heap[0];
113 | $lastId = count($this->_heap) - 1;
114 |
115 | /**
116 | * Find appropriate position for last node
117 | */
118 | $nodeId = 0; // Start from a top
119 | $childId = 1; // First child
120 |
121 | // Choose smaller child
122 | if ($lastId > 2 && $this->_less($this->_heap[2], $this->_heap[1])) {
123 | $childId = 2;
124 | }
125 |
126 | while ($childId < $lastId &&
127 | $this->_less($this->_heap[$childId], $this->_heap[$lastId])
128 | ) {
129 | // Move child node up
130 | $this->_heap[$nodeId] = $this->_heap[$childId];
131 |
132 | $nodeId = $childId; // Go down
133 | $childId = ($nodeId << 1) + 1; // First child
134 |
135 | // Choose smaller child
136 | if (($childId+1) < $lastId
137 | && $this->_less($this->_heap[$childId+1], $this->_heap[$childId])
138 | ) {
139 | $childId++;
140 | }
141 | }
142 |
143 | // Move last element to the new position
144 | $this->_heap[$nodeId] = $this->_heap[$lastId];
145 | unset($this->_heap[$lastId]);
146 |
147 | return $top;
148 | }
149 |
150 |
151 | /**
152 | * Clear queue
153 | */
154 | public function clear()
155 | {
156 | $this->_heap = array();
157 | }
158 |
159 |
160 | /**
161 | * Compare elements
162 | *
163 | * Returns true, if $el1 is less than $el2; else otherwise
164 | *
165 | * @param mixed $el1
166 | * @param mixed $el2
167 | * @return boolean
168 | */
169 | abstract protected function _less($el1, $el2);
170 | }
171 |
172 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Search/Highlighter/Default.php:
--------------------------------------------------------------------------------
1 | _doc = $document;
71 | }
72 |
73 | /**
74 | * Get document for highlighting.
75 | *
76 | * @return Zend_Search_Lucene_Document_Html $document
77 | */
78 | public function getDocument()
79 | {
80 | return $this->_doc;
81 | }
82 |
83 | /**
84 | * Highlight specified words
85 | *
86 | * @param string|array $words Words to highlight. They could be organized using the array or string.
87 | */
88 | public function highlight($words)
89 | {
90 | $color = $this->_highlightColors[$this->_currentColorIndex];
91 | $this->_currentColorIndex = ($this->_currentColorIndex + 1) % count($this->_highlightColors);
92 |
93 | $this->_doc->highlight($words, $color);
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Search/Highlighter/Interface.php:
--------------------------------------------------------------------------------
1 | ';
138 | }
139 | }
140 |
141 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Search/Query/Insignificant.php:
--------------------------------------------------------------------------------
1 | ';
139 | }
140 | }
141 |
142 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Search/Query/Preprocessing.php:
--------------------------------------------------------------------------------
1 | _boost *= $boostFactor;
64 | }
65 |
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Search/QueryEntry/Phrase.php:
--------------------------------------------------------------------------------
1 | _phrase = $phrase;
76 | $this->_field = $field;
77 | }
78 |
79 | /**
80 | * Process modifier ('~')
81 | *
82 | * @param mixed $parameter
83 | */
84 | public function processFuzzyProximityModifier($parameter = null)
85 | {
86 | $this->_proximityQuery = true;
87 |
88 | if ($parameter !== null) {
89 | $this->_wordsDistance = $parameter;
90 | }
91 | }
92 |
93 | /**
94 | * Transform entry to a subquery
95 | *
96 | * @param string $encoding
97 | * @return Zend_Search_Lucene_Search_Query
98 | * @throws Zend_Search_Lucene_Search_QueryParserException
99 | */
100 | public function getQuery($encoding)
101 | {
102 | /**
103 | * Zend_Search_Lucene_Search_Query_Preprocessing_Phrase
104 | */
105 | include_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Phrase.php';
106 | $query = new Zend_Search_Lucene_Search_Query_Preprocessing_Phrase(
107 | $this->_phrase,
108 | $encoding,
109 | ($this->_field !== null)?
110 | iconv($encoding, 'UTF-8', $this->_field) :
111 | null
112 | );
113 |
114 | if ($this->_proximityQuery) {
115 | $query->setSlop($this->_wordsDistance);
116 | }
117 |
118 | $query->setBoost($this->_boost);
119 |
120 | return $query;
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Search/QueryEntry/Subquery.php:
--------------------------------------------------------------------------------
1 | _query = $query;
52 | }
53 |
54 | /**
55 | * Process modifier ('~')
56 | *
57 | * @param mixed $parameter
58 | * @throws Zend_Search_Lucene_Search_QueryParserException
59 | */
60 | public function processFuzzyProximityModifier($parameter = null)
61 | {
62 | include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
63 | throw new Zend_Search_Lucene_Search_QueryParserException('\'~\' sign must follow term or phrase');
64 | }
65 |
66 |
67 | /**
68 | * Transform entry to a subquery
69 | *
70 | * @param string $encoding
71 | * @return Zend_Search_Lucene_Search_Query
72 | */
73 | public function getQuery($encoding)
74 | {
75 | $this->_query->setBoost($this->_boost);
76 |
77 | return $this->_query;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Search/QueryEntry/Term.php:
--------------------------------------------------------------------------------
1 | _term = $term;
76 | $this->_field = $field;
77 | }
78 |
79 | /**
80 | * Process modifier ('~')
81 | *
82 | * @param mixed $parameter
83 | */
84 | public function processFuzzyProximityModifier($parameter = null)
85 | {
86 | $this->_fuzzyQuery = true;
87 |
88 | if ($parameter !== null) {
89 | $this->_similarity = $parameter;
90 | } else {
91 | /**
92 | * Zend_Search_Lucene_Search_Query_Fuzzy
93 | */
94 | include_once 'Zend/Search/Lucene/Search/Query/Fuzzy.php';
95 | $this->_similarity = Zend_Search_Lucene_Search_Query_Fuzzy::DEFAULT_MIN_SIMILARITY;
96 | }
97 | }
98 |
99 | /**
100 | * Transform entry to a subquery
101 | *
102 | * @param string $encoding
103 | * @return Zend_Search_Lucene_Search_Query
104 | * @throws Zend_Search_Lucene_Search_QueryParserException
105 | */
106 | public function getQuery($encoding)
107 | {
108 | if ($this->_fuzzyQuery) {
109 | /**
110 | * Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy
111 | */
112 | include_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Fuzzy.php';
113 | $query = new Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy(
114 | $this->_term,
115 | $encoding,
116 | ($this->_field !== null)?
117 | iconv($encoding, 'UTF-8', $this->_field) :
118 | null,
119 | $this->_similarity
120 | );
121 | $query->setBoost($this->_boost);
122 | return $query;
123 | }
124 |
125 |
126 | /**
127 | * Zend_Search_Lucene_Search_Query_Preprocessing_Term
128 | */
129 | include_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Term.php';
130 | $query = new Zend_Search_Lucene_Search_Query_Preprocessing_Term(
131 | $this->_term,
132 | $encoding,
133 | ($this->_field !== null)?
134 | iconv($encoding, 'UTF-8', $this->_field) :
135 | null
136 | );
137 | $query->setBoost($this->_boost);
138 | return $query;
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Search/QueryHit.php:
--------------------------------------------------------------------------------
1 | _index = new Zend_Search_Lucene_Proxy($index);
73 | }
74 |
75 |
76 | /**
77 | * Convenience function for getting fields from the document
78 | * associated with this hit.
79 | *
80 | * @param string $offset
81 | * @return string
82 | */
83 | public function __get($offset)
84 | {
85 | return $this->getDocument()->getFieldValue($offset);
86 | }
87 |
88 |
89 | /**
90 | * Return the document object for this hit
91 | *
92 | * @return Zend_Search_Lucene_Document
93 | */
94 | public function getDocument()
95 | {
96 | if (!$this->_document instanceof Zend_Search_Lucene_Document) {
97 | $this->_document = $this->_index->getDocument($this->id);
98 | }
99 |
100 | return $this->_document;
101 | }
102 |
103 |
104 | /**
105 | * Return the index object for this hit
106 | *
107 | * @return Zend_Search_Lucene_Interface
108 | */
109 | public function getIndex()
110 | {
111 | return $this->_index;
112 | }
113 | }
114 |
115 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Search/QueryParserException.php:
--------------------------------------------------------------------------------
1 | createWeight().
28 | * The sumOfSquaredWeights() method is then called on the top-level
29 | * query to compute the query normalization factor Similarity->queryNorm(float).
30 | * This factor is then passed to normalize(float). At this point the weighting
31 | * is complete.
32 | *
33 | * @category Zend
34 | * @package Zend_Search_Lucene
35 | * @subpackage Search
36 | * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
37 | * @license http://framework.zend.com/license/new-bsd New BSD License
38 | */
39 | abstract class Zend_Search_Lucene_Search_Weight
40 | {
41 | /**
42 | * Normalization factor.
43 | * This value is stored only for query expanation purpose and not used in any other place
44 | *
45 | * @var float
46 | */
47 | protected $_queryNorm;
48 |
49 | /**
50 | * Weight value
51 | *
52 | * Weight value may be initialized in sumOfSquaredWeights() or normalize()
53 | * because they both are invoked either in Query::_initWeight (for top-level query) or
54 | * in corresponding methods of parent query's weights
55 | *
56 | * @var float
57 | */
58 | protected $_value;
59 |
60 |
61 | /**
62 | * The weight for this query.
63 | *
64 | * @return float
65 | */
66 | public function getValue()
67 | {
68 | return $this->_value;
69 | }
70 |
71 | /**
72 | * The sum of squared weights of contained query clauses.
73 | *
74 | * @return float
75 | */
76 | abstract public function sumOfSquaredWeights();
77 |
78 | /**
79 | * Assigns the query normalization factor to this.
80 | *
81 | * @param $norm
82 | */
83 | abstract public function normalize($norm);
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Search/Weight/Boolean.php:
--------------------------------------------------------------------------------
1 | _query = $query;
75 | $this->_reader = $reader;
76 | $this->_weights = array();
77 |
78 | $signs = $query->getSigns();
79 |
80 | foreach ($query->getSubqueries() as $num => $subquery) {
81 | if ($signs === null || $signs[$num] === null || $signs[$num]) {
82 | $this->_weights[$num] = $subquery->createWeight($reader);
83 | }
84 | }
85 | }
86 |
87 |
88 | /**
89 | * The weight for this query
90 | * Standard Weight::$_value is not used for boolean queries
91 | *
92 | * @return float
93 | */
94 | public function getValue()
95 | {
96 | return $this->_query->getBoost();
97 | }
98 |
99 |
100 | /**
101 | * The sum of squared weights of contained query clauses.
102 | *
103 | * @return float
104 | */
105 | public function sumOfSquaredWeights()
106 | {
107 | $sum = 0;
108 | foreach ($this->_weights as $weight) {
109 | // sum sub weights
110 | $sum += $weight->sumOfSquaredWeights();
111 | }
112 |
113 | // boost each sub-weight
114 | $sum *= $this->_query->getBoost() * $this->_query->getBoost();
115 |
116 | // check for empty query (like '-something -another')
117 | if ($sum == 0) {
118 | $sum = 1.0;
119 | }
120 | return $sum;
121 | }
122 |
123 |
124 | /**
125 | * Assigns the query normalization factor to this.
126 | *
127 | * @param float $queryNorm
128 | */
129 | public function normalize($queryNorm)
130 | {
131 | // incorporate boost
132 | $queryNorm *= $this->_query->getBoost();
133 |
134 | foreach ($this->_weights as $weight) {
135 | $weight->normalize($queryNorm);
136 | }
137 | }
138 | }
139 |
140 |
141 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Search/Weight/Empty.php:
--------------------------------------------------------------------------------
1 | _query = $query;
75 | $this->_reader = $reader;
76 | $this->_weights = array();
77 |
78 | $signs = $query->getSigns();
79 |
80 | foreach ($query->getTerms() as $id => $term) {
81 | if ($signs === null || $signs[$id] === null || $signs[$id]) {
82 | include_once 'Zend/Search/Lucene/Search/Weight/Term.php';
83 | $this->_weights[$id] = new Zend_Search_Lucene_Search_Weight_Term($term, $query, $reader);
84 | $query->setWeight($id, $this->_weights[$id]);
85 | }
86 | }
87 | }
88 |
89 |
90 | /**
91 | * The weight for this query
92 | * Standard Weight::$_value is not used for boolean queries
93 | *
94 | * @return float
95 | */
96 | public function getValue()
97 | {
98 | return $this->_query->getBoost();
99 | }
100 |
101 |
102 | /**
103 | * The sum of squared weights of contained query clauses.
104 | *
105 | * @return float
106 | */
107 | public function sumOfSquaredWeights()
108 | {
109 | $sum = 0;
110 | foreach ($this->_weights as $weight) {
111 | // sum sub weights
112 | $sum += $weight->sumOfSquaredWeights();
113 | }
114 |
115 | // boost each sub-weight
116 | $sum *= $this->_query->getBoost() * $this->_query->getBoost();
117 |
118 | // check for empty query (like '-something -another')
119 | if ($sum == 0) {
120 | $sum = 1.0;
121 | }
122 | return $sum;
123 | }
124 |
125 |
126 | /**
127 | * Assigns the query normalization factor to this.
128 | *
129 | * @param float $queryNorm
130 | */
131 | public function normalize($queryNorm)
132 | {
133 | // incorporate boost
134 | $queryNorm *= $this->_query->getBoost();
135 |
136 | foreach ($this->_weights as $weight) {
137 | $weight->normalize($queryNorm);
138 | }
139 | }
140 | }
141 |
142 |
143 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Search/Weight/Phrase.php:
--------------------------------------------------------------------------------
1 | _query = $query;
71 | $this->_reader = $reader;
72 | }
73 |
74 | /**
75 | * The sum of squared weights of contained query clauses.
76 | *
77 | * @return float
78 | */
79 | public function sumOfSquaredWeights()
80 | {
81 | // compute idf
82 | $this->_idf = $this->_reader->getSimilarity()->idf($this->_query->getTerms(), $this->_reader);
83 |
84 | // compute query weight
85 | $this->_queryWeight = $this->_idf * $this->_query->getBoost();
86 |
87 | // square it
88 | return $this->_queryWeight * $this->_queryWeight;
89 | }
90 |
91 |
92 | /**
93 | * Assigns the query normalization factor to this.
94 | *
95 | * @param float $queryNorm
96 | */
97 | public function normalize($queryNorm)
98 | {
99 | $this->_queryNorm = $queryNorm;
100 |
101 | // normalize query weight
102 | $this->_queryWeight *= $queryNorm;
103 |
104 | // idf for documents
105 | $this->_value = $this->_queryWeight * $this->_idf;
106 | }
107 | }
108 |
109 |
110 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Search/Weight/Term.php:
--------------------------------------------------------------------------------
1 | _term = $term;
89 | $this->_query = $query;
90 | $this->_reader = $reader;
91 | }
92 |
93 |
94 | /**
95 | * The sum of squared weights of contained query clauses.
96 | *
97 | * @return float
98 | */
99 | public function sumOfSquaredWeights()
100 | {
101 | // compute idf
102 | $this->_idf = $this->_reader->getSimilarity()->idf($this->_term, $this->_reader);
103 |
104 | // compute query weight
105 | $this->_queryWeight = $this->_idf * $this->_query->getBoost();
106 |
107 | // square it
108 | return $this->_queryWeight * $this->_queryWeight;
109 | }
110 |
111 |
112 | /**
113 | * Assigns the query normalization factor to this.
114 | *
115 | * @param float $queryNorm
116 | */
117 | public function normalize($queryNorm)
118 | {
119 | $this->_queryNorm = $queryNorm;
120 |
121 | // normalize query weight
122 | $this->_queryWeight *= $queryNorm;
123 |
124 | // idf for documents
125 | $this->_value = $this->_queryWeight * $this->_idf;
126 | }
127 | }
128 |
129 |
--------------------------------------------------------------------------------
/thirdparty/Zend/Search/Lucene/Storage/Directory.php:
--------------------------------------------------------------------------------
1 |
18 |
19 |
20 | ```
21 |
22 | This will find and highlight code inside of `
` tags; it tries
23 | to detect the language automatically. If automatic detection doesn’t
24 | work for you, you can specify the language in the `class` attribute:
25 |
26 | ```html
27 |
...
28 | ```
29 |
30 | The list of supported language classes is available in the [class
31 | reference][2]. Classes can also be prefixed with either `language-` or
32 | `lang-`.
33 |
34 | To disable highlighting altogether use the `nohighlight` class:
35 |
36 | ```html
37 |
...
38 | ```
39 |
40 | ## Custom Initialization
41 |
42 | When you need a bit more control over the initialization of
43 | highlight.js, you can use the [`highlightBlock`][3] and [`configure`][4]
44 | functions. This allows you to control *what* to highlight and *when*.
45 |
46 | Here’s an equivalent way to calling [`initHighlightingOnLoad`][1] using
47 | jQuery:
48 |
49 | ```javascript
50 | $(document).ready(function() {
51 | $('pre code').each(function(i, block) {
52 | hljs.highlightBlock(block);
53 | });
54 | });
55 | ```
56 |
57 | You can use any tags instead of `
` to mark up your code. If
58 | you don't use a container that preserve line breaks you will need to
59 | configure highlight.js to use the ` ` tag:
60 |
61 | ```javascript
62 | hljs.configure({useBR: true});
63 |
64 | $('div.code').each(function(i, block) {
65 | hljs.highlightBlock(block);
66 | });
67 | ```
68 |
69 | For other options refer to the documentation for [`configure`][4].
70 |
71 |
72 | ## Web Workers
73 |
74 | You can run highlighting inside a web worker to avoid freezing the browser
75 | window while dealing with very big chunks of code.
76 |
77 | In your main script:
78 |
79 | ```javascript
80 | addEventListener('load', function() {
81 | var code = document.querySelector('#code');
82 | var worker = new Worker('worker.js');
83 | worker.onmessage = function(event) { code.innerHTML = event.data; }
84 | worker.postMessage(code.textContent);
85 | })
86 | ```
87 |
88 | In worker.js:
89 |
90 | ```javascript
91 | onmessage = function(event) {
92 | importScripts('/highlight.pack.js');
93 | var result = self.hljs.highlightAuto(event.data);
94 | postMessage(result.value);
95 | }
96 | ```
97 |
98 |
99 | ## Getting the Library
100 |
101 | You can get highlight.js as a hosted, or custom-build, browser script or
102 | as a server module. Right out of the box the browser script supports
103 | both AMD and CommonJS, so if you wish you can use RequireJS or
104 | Browserify without having to build from source. The server module also
105 | works perfectly fine with Browserify, but there is the option to use a
106 | build specific to browsers rather than something meant for a server.
107 | Head over to the [download page][5] for all the options.
108 |
109 | **Don't link to GitHub directly.** The library is not supposed to work straight
110 | from the source, it requires building. If none of the pre-packaged options
111 | work for you refer to the [building documentation][6].
112 |
113 | **The CDN-hosted package doesn't have all the languages.** Otherwise it'd be
114 | too big. If you don't see the language you need in the ["Common" section][5],
115 | it can be added manually:
116 |
117 | ```html
118 |
119 | ```
120 |
121 | **On Almond.** You need to use the optimizer to give the module a name. For
122 | example:
123 |
124 | ```
125 | r.js -o name=hljs paths.hljs=/path/to/highlight out=highlight.js
126 | ```
127 |
128 |
129 | ## License
130 |
131 | Highlight.js is released under the BSD License. See [LICENSE][7] file
132 | for details.
133 |
134 | ## Links
135 |
136 | The official site for the library is at .
137 |
138 | Further in-depth documentation for the API and other topics is at
139 | .
140 |
141 | Authors and contributors are listed in the [AUTHORS.en.txt][8] file.
142 |
143 | [1]: http://highlightjs.readthedocs.io/en/latest/api.html#inithighlightingonload
144 | [2]: http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html
145 | [3]: http://highlightjs.readthedocs.io/en/latest/api.html#highlightblock-block
146 | [4]: http://highlightjs.readthedocs.io/en/latest/api.html#configure-options
147 | [5]: https://highlightjs.org/download/
148 | [6]: http://highlightjs.readthedocs.io/en/latest/building-testing.html
149 | [7]: https://github.com/isagalaev/highlight.js/blob/master/LICENSE
150 | [8]: https://github.com/isagalaev/highlight.js/blob/master/AUTHORS.en.txt
151 |
--------------------------------------------------------------------------------
/thirdparty/highlight/README.ru.md:
--------------------------------------------------------------------------------
1 | # Highlight.js
2 |
3 | Highlight.js — это инструмент для подсветки синтаксиса, написанный на JavaScript. Он работает
4 | и в браузере, и на сервере. Он работает с практически любой HTML разметкой, не
5 | зависит от каких-либо фреймворков и умеет автоматически определять язык.
6 |
7 |
8 | ## Начало работы
9 |
10 | Минимум, что нужно сделать для использования highlight.js на веб-странице — это
11 | подключить библиотеку, CSS-стили и вызывать [`initHighlightingOnLoad`][1]:
12 |
13 | ```html
14 |
15 |
16 |
17 | ```
18 |
19 | Библиотека найдёт и раскрасит код внутри тегов `
`, попытавшись
20 | автоматически определить язык. Когда автоопределение не срабатывает, можно явно
21 | указать язык в атрибуте class:
22 |
23 | ```html
24 |
...
25 | ```
26 |
27 | Список поддерживаемых классов языков доступен в [справочнике по классам][2].
28 | Класс также можно предварить префиксами `language-` или `lang-`.
29 |
30 | Чтобы отключить подсветку для какого-то блока, используйте класс `nohighlight`:
31 |
32 | ```html
33 |
...
34 | ```
35 |
36 | ## Инициализация вручную
37 |
38 | Чтобы иметь чуть больше контроля за инициализацией подсветки, вы можете
39 | использовать функции [`highlightBlock`][3] и [`configure`][4]. Таким образом
40 | можно управлять тем, *что* и *когда* подсвечивать.
41 |
42 | Вот пример инициализации, эквивалентной вызову [`initHighlightingOnLoad`][1], но
43 | с использованием jQuery:
44 |
45 | ```javascript
46 | $(document).ready(function() {
47 | $('pre code').each(function(i, block) {
48 | hljs.highlightBlock(block);
49 | });
50 | });
51 | ```
52 |
53 | Вы можете использовать любые теги разметки вместо `
`. Если
54 | используете контейнер, не сохраняющий переводы строк, вам нужно сказать
55 | highlight.js использовать для них тег ` `:
56 |
57 | ```javascript
58 | hljs.configure({useBR: true});
59 |
60 | $('div.code').each(function(i, block) {
61 | hljs.highlightBlock(block);
62 | });
63 | ```
64 |
65 | Другие опции можно найти в документации функции [`configure`][4].
66 |
67 |
68 | ## Web Workers
69 |
70 | Подсветку можно запустить внутри web worker'а, чтобы окно
71 | браузера не подтормаживало при работе с большими кусками кода.
72 |
73 | В основном скрипте:
74 |
75 | ```javascript
76 | addEventListener('load', function() {
77 | var code = document.querySelector('#code');
78 | var worker = new Worker('worker.js');
79 | worker.onmessage = function(event) { code.innerHTML = event.data; }
80 | worker.postMessage(code.textContent);
81 | })
82 | ```
83 |
84 | В worker.js:
85 |
86 | ```javascript
87 | onmessage = function(event) {
88 | importScripts('/highlight.pack.js');
89 | var result = self.hljs.highlightAuto(event.data);
90 | postMessage(result.value);
91 | }
92 | ```
93 |
94 |
95 | ## Установка библиотеки
96 |
97 | Highlight.js можно использовать в браузере прямо с CDN хостинга или скачать
98 | индивидуальную сборку, а также установив модуль на сервере. На
99 | [странице загрузки][5] подробно описаны все варианты.
100 |
101 | **Не подключайте GitHub напрямую.** Библиотека не предназначена для
102 | использования в виде исходного кода, а требует отдельной сборки. Если вам не
103 | подходит ни один из готовых вариантов, читайте [документацию по сборке][6].
104 |
105 | **Файл на CDN содержит не все языки.** Иначе он будет слишком большого размера.
106 | Если нужного вам языка нет в [категории "Common"][5], можно дообавить его
107 | вручную:
108 |
109 | ```html
110 |
111 | ```
112 |
113 | **Про Almond.** Нужно задать имя модуля в оптимизаторе, например:
114 |
115 | ```
116 | r.js -o name=hljs paths.hljs=/path/to/highlight out=highlight.js
117 | ```
118 |
119 |
120 | ## Лицензия
121 |
122 | Highlight.js распространяется под лицензией BSD. Подробнее читайте файл
123 | [LICENSE][7].
124 |
125 |
126 | ## Ссылки
127 |
128 | Официальный сайт билиотеки расположен по адресу .
129 |
130 | Более подробная документация по API и другим темам расположена на
131 | .
132 |
133 | Авторы и контрибьюторы перечислены в файле [AUTHORS.ru.txt][8] file.
134 |
135 | [1]: http://highlightjs.readthedocs.io/en/latest/api.html#inithighlightingonload
136 | [2]: http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html
137 | [3]: http://highlightjs.readthedocs.io/en/latest/api.html#highlightblock-block
138 | [4]: http://highlightjs.readthedocs.io/en/latest/api.html#configure-options
139 | [5]: https://highlightjs.org/download/
140 | [6]: http://highlightjs.readthedocs.io/en/latest/building-testing.html
141 | [7]: https://github.com/isagalaev/highlight.js/blob/master/LICENSE
142 | [8]: https://github.com/isagalaev/highlight.js/blob/master/AUTHORS.ru.txt
143 |
--------------------------------------------------------------------------------