Skip to content

Commit bc92698

Browse files
committed
Revert "remove highlight-js"
This reverts commit 05f08d1.
1 parent dc90455 commit bc92698

File tree

97 files changed

+9644
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+9644
-0
lines changed

docs/highlight/CHANGES.md

Lines changed: 1803 additions & 0 deletions
Large diffs are not rendered by default.

docs/highlight/LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2006, Ivan Sagalaev
2+
All rights reserved.
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above copyright
9+
notice, this list of conditions and the following disclaimer in the
10+
documentation and/or other materials provided with the distribution.
11+
* Neither the name of highlight.js nor the names of its contributors
12+
may be used to endorse or promote products derived from this software
13+
without specific prior written permission.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
16+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18+
DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
19+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

docs/highlight/README.md

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
# Highlight.js
2+
3+
[![Build Status](https://travis-ci.org/highlightjs/highlight.js.svg?branch=master)](https://travis-ci.org/highlightjs/highlight.js) [![Greenkeeper badge](https://badges.greenkeeper.io/highlightjs/highlight.js.svg)](https://greenkeeper.io/)
4+
5+
Highlight.js is a syntax highlighter written in JavaScript. It works in
6+
the browser as well as on the server. It works with pretty much any
7+
markup, doesn’t depend on any framework, and has automatic language
8+
detection.
9+
10+
## Getting Started
11+
12+
The bare minimum for using highlight.js on a web page is linking to the
13+
library along with one of the styles and calling
14+
[`initHighlightingOnLoad`][1]:
15+
16+
```html
17+
<link rel="stylesheet" href="/path/to/styles/default.css">
18+
<script src="/path/to/highlight.pack.js"></script>
19+
<script>hljs.initHighlightingOnLoad();</script>
20+
```
21+
22+
This will find and highlight code inside of `<pre><code>` 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+
<pre><code class="html">...</code></pre>
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 make arbitrary text look like code, but without highlighting, use the
35+
`plaintext` class:
36+
37+
```html
38+
<pre><code class="plaintext">...</code></pre>
39+
```
40+
41+
To disable highlighting altogether use the `nohighlight` class:
42+
43+
```html
44+
<pre><code class="nohighlight">...</code></pre>
45+
```
46+
47+
## Custom Initialization
48+
49+
When you need a bit more control over the initialization of
50+
highlight.js, you can use the [`highlightBlock`][3] and [`configure`][4]
51+
functions. This allows you to control *what* to highlight and *when*.
52+
53+
Here’s an equivalent way to calling [`initHighlightingOnLoad`][1] using
54+
vanilla JS:
55+
56+
```js
57+
document.addEventListener('DOMContentLoaded', (event) => {
58+
document.querySelectorAll('pre code').forEach((block) => {
59+
hljs.highlightBlock(block);
60+
});
61+
});
62+
```
63+
64+
You can use any tags instead of `<pre><code>` to mark up your code. If
65+
you don't use a container that preserves line breaks you will need to
66+
configure highlight.js to use the `<br>` tag:
67+
68+
```js
69+
hljs.configure({useBR: true});
70+
71+
document.querySelectorAll('div.code').forEach((block) => {
72+
hljs.highlightBlock(block);
73+
});
74+
```
75+
76+
For other options refer to the documentation for [`configure`][4].
77+
78+
79+
## Web Workers
80+
81+
You can run highlighting inside a web worker to avoid freezing the browser
82+
window while dealing with very big chunks of code.
83+
84+
In your main script:
85+
86+
```js
87+
addEventListener('load', () => {
88+
const code = document.querySelector('#code');
89+
const worker = new Worker('worker.js');
90+
worker.onmessage = (event) => { code.innerHTML = event.data; }
91+
worker.postMessage(code.textContent);
92+
});
93+
```
94+
95+
In worker.js:
96+
97+
```js
98+
onmessage = (event) => {
99+
importScripts('<path>/highlight.pack.js');
100+
const result = self.hljs.highlightAuto(event.data);
101+
postMessage(result.value);
102+
};
103+
```
104+
105+
106+
## Getting the Library
107+
108+
You can get highlight.js as a hosted, or custom-build, browser script or
109+
as a server module. Right out of the box the browser script supports
110+
both AMD and CommonJS, so if you wish you can use RequireJS or
111+
Browserify without having to build from source. The server module also
112+
works perfectly fine with Browserify, but there is the option to use a
113+
build specific to browsers rather than something meant for a server.
114+
Head over to the [download page][5] for all the options.
115+
116+
**Don't link to GitHub directly.** The library is not supposed to work straight
117+
from the source, it requires building. If none of the pre-packaged options
118+
work for you refer to the [building documentation][6].
119+
120+
**The CDN-hosted package doesn't have all the languages.** Otherwise it'd be
121+
too big. If you don't see the language you need in the ["Common" section][5],
122+
it can be added manually:
123+
124+
```html
125+
<script
126+
charset="UTF-8"
127+
src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/go.min.js"></script>
128+
```
129+
130+
**On Almond.** You need to use the optimizer to give the module a name. For
131+
example:
132+
133+
```bash
134+
r.js -o name=hljs paths.hljs=/path/to/highlight out=highlight.js
135+
```
136+
137+
138+
### CommonJS
139+
140+
You can import Highlight.js as a CommonJS-module:
141+
142+
```bash
143+
npm install highlight.js --save
144+
```
145+
146+
In your application:
147+
148+
```js
149+
import hljs from 'highlight.js';
150+
```
151+
152+
The default import imports all languages! Therefore it is likely to be more efficient to import only the library and the languages you need:
153+
154+
```js
155+
import hljs from 'highlight.js/lib/highlight';
156+
import javascript from 'highlight.js/lib/languages/javascript';
157+
hljs.registerLanguage('javascript', javascript);
158+
```
159+
160+
To set the syntax highlighting style, if your build tool processes CSS from your JavaScript entry point, you can import the stylesheet directly into your CommonJS-module:
161+
162+
```js
163+
import hljs from 'highlight.js/lib/highlight';
164+
import 'highlight.js/styles/github.css';
165+
```
166+
167+
## License
168+
169+
Highlight.js is released under the BSD License. See [LICENSE][7] file
170+
for details.
171+
172+
## Links
173+
174+
The official site for the library is at <https://highlightjs.org/>.
175+
176+
Further in-depth documentation for the API and other topics is at
177+
<http://highlightjs.readthedocs.io/>.
178+
179+
Authors and contributors are listed in the [AUTHORS.en.txt][8] file.
180+
181+
[1]: http://highlightjs.readthedocs.io/en/latest/api.html#inithighlightingonload
182+
[2]: http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html
183+
[3]: http://highlightjs.readthedocs.io/en/latest/api.html#highlightblock-block
184+
[4]: http://highlightjs.readthedocs.io/en/latest/api.html#configure-options
185+
[5]: https://highlightjs.org/download/
186+
[6]: http://highlightjs.readthedocs.io/en/latest/building-testing.html
187+
[7]: https://github.com/highlightjs/highlight.js/blob/master/LICENSE
188+
[8]: https://github.com/highlightjs/highlight.js/blob/master/AUTHORS.en.txt

docs/highlight/README.ru.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
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+
<link rel="stylesheet" href="/path/to/styles/default.css">
15+
<script src="/path/to/highlight.pack.js"></script>
16+
<script>hljs.initHighlightingOnLoad();</script>
17+
```
18+
19+
Библиотека найдёт и раскрасит код внутри тегов `<pre><code>`, попытавшись
20+
автоматически определить язык. Когда автоопределение не срабатывает, можно явно
21+
указать язык в атрибуте class:
22+
23+
```html
24+
<pre><code class="html">...</code></pre>
25+
```
26+
27+
Список поддерживаемых классов языков доступен в [справочнике по классам][2].
28+
Класс также можно предварить префиксами `language-` или `lang-`.
29+
30+
Чтобы отключить подсветку для какого-то блока, используйте класс `nohighlight`:
31+
32+
```html
33+
<pre><code class="nohighlight">...</code></pre>
34+
```
35+
36+
## Инициализация вручную
37+
38+
Чтобы иметь чуть больше контроля за инициализацией подсветки, вы можете
39+
использовать функции [`highlightBlock`][3] и [`configure`][4]. Таким образом
40+
можно управлять тем, *что* и *когда* подсвечивать.
41+
42+
Вот пример инициализации, эквивалентной вызову [`initHighlightingOnLoad`][1], но
43+
с использованием `document.addEventListener`:
44+
45+
```js
46+
document.addEventListener('DOMContentLoaded', (event) => {
47+
document.querySelectorAll('pre code').forEach((block) => {
48+
hljs.highlightBlock(block);
49+
});
50+
});
51+
```
52+
53+
Вы можете использовать любые теги разметки вместо `<pre><code>`. Если
54+
используете контейнер, не сохраняющий переводы строк, вам нужно сказать
55+
highlight.js использовать для них тег `<br>`:
56+
57+
```js
58+
hljs.configure({useBR: true});
59+
60+
document.querySelectorAll('div.code').forEach((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+
```js
76+
addEventListener('load', () => {
77+
const code = document.querySelector('#code');
78+
const worker = new Worker('worker.js');
79+
worker.onmessage = (event) => { code.innerHTML = event.data; }
80+
worker.postMessage(code.textContent);
81+
});
82+
```
83+
84+
В worker.js:
85+
86+
```js
87+
onmessage = (event) => {
88+
importScripts('<path>/highlight.pack.js');
89+
const 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+
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/languages/go.min.js"></script>
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+
Официальный сайт билиотеки расположен по адресу <https://highlightjs.org/>.
129+
130+
Более подробная документация по API и другим темам расположена на
131+
<http://highlightjs.readthedocs.io/>.
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/highlightjs/highlight.js/blob/master/LICENSE
142+
[8]: https://github.com/highlightjs/highlight.js/blob/master/AUTHORS.ru.txt

0 commit comments

Comments
 (0)