├── source ├── images │ ├── dot.png │ ├── logo.png │ ├── more.png │ ├── rss.png │ ├── top.png │ ├── cancel.png │ ├── favicon.ico │ └── category-icon.png ├── font │ ├── Inconsolata.otf │ └── Inconsolata.ttf ├── js │ ├── highlight │ │ ├── styles │ │ │ ├── pojoaque.jpg │ │ │ ├── school-book.png │ │ │ ├── brown-papersq.png │ │ │ ├── darkula.css │ │ │ ├── ascetic.css │ │ │ ├── mono-blue.css │ │ │ ├── dark.css │ │ │ ├── androidstudio.css │ │ │ ├── codepen-embed.css │ │ │ ├── brown-paper.css │ │ │ ├── vs.css │ │ │ ├── far.css │ │ │ ├── arta.css │ │ │ ├── ir-black.css │ │ │ ├── color-brewer.css │ │ │ ├── magula.css │ │ │ ├── darcula.css │ │ │ ├── monokai.css │ │ │ ├── gml.css │ │ │ ├── tomorrow.css │ │ │ ├── school-book.css │ │ │ ├── zenburn.css │ │ │ ├── ocean.css │ │ │ ├── paraiso-dark.css │ │ │ ├── paraiso-light.css │ │ │ ├── dracula.css │ │ │ ├── qtcreator_dark.css │ │ │ ├── qtcreator_light.css │ │ │ ├── rainbow.css │ │ │ ├── github-gist.css │ │ │ ├── kimbie.dark.css │ │ │ ├── kimbie.light.css │ │ │ ├── atelier-dune-dark.css │ │ │ ├── monokai-sublime.css │ │ │ ├── atelier-dune-light.css │ │ │ ├── atelier-heath-dark.css │ │ │ ├── atelier-heath-light.css │ │ │ ├── atelier-forest-dark.css │ │ │ ├── atelier-forest-light.css │ │ │ ├── tomorrow-night-bright.css │ │ │ ├── tomorrow-night-eighties.css │ │ │ ├── arduino-light.css │ │ │ ├── atelier-seaside-dark.css │ │ │ ├── atelier-seaside-light.css │ │ │ ├── atelier-lakeside-dark.css │ │ │ ├── atelier-lakeside-light.css │ │ │ ├── googlecode.css │ │ │ ├── hopscotch.css │ │ │ ├── lightfair.css │ │ │ ├── xt256.css │ │ │ ├── atelier-sulphurpool-dark.css │ │ │ ├── atelier-sulphurpool-light.css │ │ │ ├── obsidian.css │ │ │ ├── tomorrow-night.css │ │ │ ├── foundation.css │ │ │ ├── tomorrow-night-blue.css │ │ │ ├── pojoaque.css │ │ │ ├── solarized-dark.css │ │ │ ├── solarized-light.css │ │ │ ├── docco.css │ │ │ ├── an-old-hope.css │ │ │ ├── idea.css │ │ │ ├── atelier-cave-dark.css │ │ │ ├── atelier-cave-light.css │ │ │ ├── atelier-estuary-dark.css │ │ │ ├── atelier-plateau-dark.css │ │ │ ├── atelier-savanna-dark.css │ │ │ ├── github.css │ │ │ ├── atelier-estuary-light.css │ │ │ ├── atelier-plateau-light.css │ │ │ ├── atelier-savanna-light.css │ │ │ ├── atom-one-dark.css │ │ │ ├── default.css │ │ │ ├── atom-one-light.css │ │ │ ├── sunburst.css │ │ │ ├── xcode.css │ │ │ ├── shades-of-purple.css │ │ │ ├── railscasts.css │ │ │ ├── routeros.css │ │ │ ├── agate.css │ │ │ ├── atom-one-dark-reasonable.css │ │ │ ├── hybrid.css │ │ │ ├── gradient-dark.css │ │ │ ├── isbl-editor-light.css │ │ │ ├── a11y-dark.css │ │ │ ├── a11y-light.css │ │ │ ├── isbl-editor-dark.css │ │ │ ├── gruvbox-dark.css │ │ │ ├── gruvbox-light.css │ │ │ ├── vs2015.css │ │ │ ├── grayscale.css │ │ │ ├── purebasic.css │ │ │ ├── night-owl.css │ │ │ └── nord.css │ │ ├── LICENSE │ │ ├── README.ru.md │ │ └── README.md │ └── main.js └── css │ ├── font.css │ ├── footer.css │ ├── index.css │ ├── custom.css │ ├── archive.css │ ├── slider.css │ ├── aside.css │ ├── post.css │ ├── header.css │ ├── paginator.css │ ├── layout.css │ ├── markdown.css │ └── main.css ├── layout ├── footer.ejs ├── _partial │ ├── slider.ejs │ └── paginator.ejs ├── index.ejs ├── archive.ejs ├── header.ejs ├── post.ejs ├── aside.ejs └── layout.ejs ├── _config.yml ├── README.md └── LICENSE /source/images/dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junbin123/hexo-theme-binbin/HEAD/source/images/dot.png -------------------------------------------------------------------------------- /source/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junbin123/hexo-theme-binbin/HEAD/source/images/logo.png -------------------------------------------------------------------------------- /source/images/more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junbin123/hexo-theme-binbin/HEAD/source/images/more.png -------------------------------------------------------------------------------- /source/images/rss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junbin123/hexo-theme-binbin/HEAD/source/images/rss.png -------------------------------------------------------------------------------- /source/images/top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junbin123/hexo-theme-binbin/HEAD/source/images/top.png -------------------------------------------------------------------------------- /source/images/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junbin123/hexo-theme-binbin/HEAD/source/images/cancel.png -------------------------------------------------------------------------------- /source/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junbin123/hexo-theme-binbin/HEAD/source/images/favicon.ico -------------------------------------------------------------------------------- /source/font/Inconsolata.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junbin123/hexo-theme-binbin/HEAD/source/font/Inconsolata.otf -------------------------------------------------------------------------------- /source/font/Inconsolata.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junbin123/hexo-theme-binbin/HEAD/source/font/Inconsolata.ttf -------------------------------------------------------------------------------- /source/images/category-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junbin123/hexo-theme-binbin/HEAD/source/images/category-icon.png -------------------------------------------------------------------------------- /source/js/highlight/styles/pojoaque.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junbin123/hexo-theme-binbin/HEAD/source/js/highlight/styles/pojoaque.jpg -------------------------------------------------------------------------------- /source/js/highlight/styles/school-book.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junbin123/hexo-theme-binbin/HEAD/source/js/highlight/styles/school-book.png -------------------------------------------------------------------------------- /source/js/highlight/styles/brown-papersq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junbin123/hexo-theme-binbin/HEAD/source/js/highlight/styles/brown-papersq.png -------------------------------------------------------------------------------- /source/css/font.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'codefont'; 3 | src: url('../font/Inconsolata.otf'); 4 | src: url('../font/Inconsolata.ttf'); 5 | } -------------------------------------------------------------------------------- /source/js/highlight/styles/darkula.css: -------------------------------------------------------------------------------- 1 | /* 2 | Deprecated due to a typo in the name and left here for compatibility purpose only. 3 | Please use darcula.css instead. 4 | */ 5 | 6 | @import url('darcula.css'); 7 | -------------------------------------------------------------------------------- /source/css/footer.css: -------------------------------------------------------------------------------- 1 | /* #################### 页脚 #################### */ 2 | 3 | .footer-info { 4 | color: #666; 5 | line-height: 22px; 6 | padding-top: 38px; 7 | } 8 | 9 | .footer-link { 10 | color: #BF4033; 11 | } 12 | -------------------------------------------------------------------------------- /layout/footer.ejs: -------------------------------------------------------------------------------- 1 |
-------------------------------------------------------------------------------- /source/css/index.css: -------------------------------------------------------------------------------- 1 | /* #################### index.ejs #################### */ 2 | 3 | .section { 4 | padding: 24px; 5 | border-bottom: 1px solid #ececec; 6 | transition: all .3s linear; 7 | margin-right: 24px; 8 | } 9 | 10 | .section:hover { 11 | background: #ececec; 12 | } 13 | 14 | .section__excerpt { 15 | margin-top: 12px; 16 | font-size: 16px; 17 | color: #34495E; 18 | } -------------------------------------------------------------------------------- /layout/_partial/slider.ejs: -------------------------------------------------------------------------------- 1 |当前第 <%- page.current %> 页
14 |共 <%- page.total %> 页
15 |2 |
一个针对中文博客优化的 Hexo 主题
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | > Hexo 是一套应用广泛的博客框架,但官方对中文博客友好的主题一直比较少。
12 | >
13 | > 于是,我自己写了一个主题,针对中文进行优化,欢迎各位[体验](https://junbin123.github.io/)并贡献自己的意见。
14 |
15 | ## 体验
16 |
17 | PC:https://junbin123.github.io/
18 |
19 | 移动端:
20 |
21 | 
22 |
23 | ## 预览
24 |
25 | 
26 |
27 | 
28 |
29 | 
30 |
31 | 
32 |
33 | ## 项目说明
34 |
35 | 我将精力放在了基本功能和设计上,没有开发额外的插件,后续根据反馈和自身需求一一搞起!😜
36 |
37 | 第一版 binbin 主题,根据效果,总结了以下特性:
38 |
39 | #### 简单务实
40 |
41 | 设计上,保持了博客网站的纯粹,专注与写文章。
42 |
43 | #### 微动效
44 |
45 | 避免交互过渡生硬,适当加入微动效;愉悦你,不打扰。
46 |
47 | #### 移动端适配
48 |
49 | 针对移动端进行适配,同时保证了体验上的一致性。
50 |
51 | ## 简单上手
52 |
53 | #### 1. 下载
54 |
55 | ```
56 | git clone https://github.com/junbin123/hexo-theme-binbin.git
57 | ```
58 |
59 | #### 2. 修改站点 _config.yml
60 |
61 | ```yml
62 | # /_config.yml
63 |
64 | url: 填写你的域名
65 |
66 | # Pagination
67 | ## Set per_page to 0 to disable pagination
68 | ## 归档页文章不显示摘要,设置其每页显示 30 条,效果更佳。
69 | per_page: 30
70 | pagination_dir: page
71 |
72 | # Extensions
73 | ## Plugins: https://hexo.io/plugins/
74 | ## Themes: https://hexo.io/themes/
75 | theme: binbin
76 | ```
77 |
78 | #### 3. 修改主题 _config.yml
79 |
80 | ```yaml
81 | # /themes/binbin/_config.yml
82 |
83 | # 你可以根据需要修改此处的外链,效果如图。
84 | links:
85 | GitHub: https://github.com/junbin123
86 | 微博: https://weibo.com/u/6208092799
87 | 公众号: https://docs.qq.com/doc/DVlVBZGF3RVpMVWVW
88 | 微信: https://docs.qq.com/doc/DVkZkdllJU3FUTmZC
89 | ```
90 |
91 | | PC | 移动端 |
92 | | ------------------------------------------------------------ | ------------------------------------------------------------ |
93 | |  |  |
94 |
95 | #### 4. 更换 logo
96 |
97 | 更换 */themes/binbin/source/images* 文件夹下的 *logo.png* 和 *favicon.ico* 文件。
98 |
99 | 他们分别对应网站的这两处地方:
100 |
101 | 
102 |
103 | **建议尺寸:**
104 |
105 | *logo.png*:80px
106 |
107 | *favicon.ico*:40px
108 |
109 | #### 5. 添加「关于我」页面
110 |
111 | binbin 主题提供一个「关于我」页面,需要你添加一个 *index.md* 文件,放于 */source/about/index.md*。
112 |
113 | *index.md* 内容示例,效果如图:
114 |
115 | ```markdown
116 | ---
117 | title: 关于我
118 | ---
119 | 这里是正文
120 | 自我介绍写在这里
121 | ```
122 |
123 | 
124 |
125 | ## 功能列表
126 |
127 | - [x] ~~首页、文章归档页、文章分类页、文章标签页~~
128 | - [x] ~~RSS 订阅、外链(社交媒体)~~
129 | - [x] ~~微动画效果、移动端适配~~
130 | - [x] ~~返回顶部功能~~
131 | - [ ] 文章置顶功能、文章评论功能
132 | - [ ] 最近发表功能、搜索功能
133 |
134 | ## 更新记录
135 |
136 | | 版本 | 发布日期 | 内容 |
137 | | ------ | ---------- | ----------------------- |
138 | | V1.0.0 | 2019-12-19 | Hexo 主题 binbin 诞生了 |
139 | | | | |
140 | | | | |
141 |
142 | ## 唠叨一下
143 |
144 | - Hexo 的文档是出了名的难用,但支持中文、又是开源的,开发过程常常自我安慰,忍忍就过去了。
145 | - 设计主题用到的 sketch 文件(*hexo-theme-binbin-design.sketch*)一并放到[网上](https://c-t.work/s/4ca355b8b7ab40),常常一边写一边重新设计,sketch 文件被我弄得很乱,这真不是谦虚。
146 |
147 | ## 许可协议
148 |
149 |
--------------------------------------------------------------------------------
/source/js/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 | с использованием `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 | Вы можете использовать любые теги разметки вместо ``. Если
54 | используете контейнер, не сохраняющий переводы строк, вам нужно сказать
55 | highlight.js использовать для них тег `
`:
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('/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 |
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/highlightjs/highlight.js/blob/master/LICENSE
142 | [8]: https://github.com/highlightjs/highlight.js/blob/master/AUTHORS.ru.txt
143 |
--------------------------------------------------------------------------------
/source/js/highlight/styles/nord.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2017-present Arctic Ice Studio
3 | * Copyright (c) 2017-present Sven Greb
4 | *
5 | * Project: Nord highlight.js
6 | * Version: 0.1.0
7 | * Repository: https://github.com/arcticicestudio/nord-highlightjs
8 | * License: MIT
9 | * References:
10 | * https://github.com/arcticicestudio/nord
11 | */
12 |
13 | .hljs {
14 | display: block;
15 | overflow-x: auto;
16 | padding: 0.5em;
17 | background: #2E3440;
18 | }
19 |
20 | .hljs,
21 | .hljs-subst {
22 | color: #D8DEE9;
23 | }
24 |
25 | .hljs-selector-tag {
26 | color: #81A1C1;
27 | }
28 |
29 | .hljs-selector-id {
30 | color: #8FBCBB;
31 | font-weight: bold;
32 | }
33 |
34 | .hljs-selector-class {
35 | color: #8FBCBB;
36 | }
37 |
38 | .hljs-selector-attr {
39 | color: #8FBCBB;
40 | }
41 |
42 | .hljs-selector-pseudo {
43 | color: #88C0D0;
44 | }
45 |
46 | .hljs-addition {
47 | background-color: rgba(163, 190, 140, 0.5);
48 | }
49 |
50 | .hljs-deletion {
51 | background-color: rgba(191, 97, 106, 0.5);
52 | }
53 |
54 | .hljs-built_in,
55 | .hljs-type {
56 | color: #8FBCBB;
57 | }
58 |
59 | .hljs-class {
60 | color: #8FBCBB;
61 | }
62 |
63 | .hljs-function {
64 | color: #88C0D0;
65 | }
66 |
67 | .hljs-function > .hljs-title {
68 | color: #88C0D0;
69 | }
70 |
71 | .hljs-keyword,
72 | .hljs-literal,
73 | .hljs-symbol {
74 | color: #81A1C1;
75 | }
76 |
77 | .hljs-number {
78 | color: #B48EAD;
79 | }
80 |
81 | .hljs-regexp {
82 | color: #EBCB8B;
83 | }
84 |
85 | .hljs-string {
86 | color: #A3BE8C;
87 | }
88 |
89 | .hljs-title {
90 | color: #8FBCBB;
91 | }
92 |
93 | .hljs-params {
94 | color: #D8DEE9;
95 | }
96 |
97 | .hljs-bullet {
98 | color: #81A1C1;
99 | }
100 |
101 | .hljs-code {
102 | color: #8FBCBB;
103 | }
104 |
105 | .hljs-emphasis {
106 | font-style: italic;
107 | }
108 |
109 | .hljs-formula {
110 | color: #8FBCBB;
111 | }
112 |
113 | .hljs-strong {
114 | font-weight: bold;
115 | }
116 |
117 | .hljs-link:hover {
118 | text-decoration: underline;
119 | }
120 |
121 | .hljs-quote {
122 | color: #4C566A;
123 | }
124 |
125 | .hljs-comment {
126 | color: #4C566A;
127 | }
128 |
129 | .hljs-doctag {
130 | color: #8FBCBB;
131 | }
132 |
133 | .hljs-meta,
134 | .hljs-meta-keyword {
135 | color: #5E81AC;
136 | }
137 |
138 | .hljs-meta-string {
139 | color: #A3BE8C;
140 | }
141 |
142 | .hljs-attr {
143 | color: #8FBCBB;
144 | }
145 |
146 | .hljs-attribute {
147 | color: #D8DEE9;
148 | }
149 |
150 | .hljs-builtin-name {
151 | color: #81A1C1;
152 | }
153 |
154 | .hljs-name {
155 | color: #81A1C1;
156 | }
157 |
158 | .hljs-section {
159 | color: #88C0D0;
160 | }
161 |
162 | .hljs-tag {
163 | color: #81A1C1;
164 | }
165 |
166 | .hljs-variable {
167 | color: #D8DEE9;
168 | }
169 |
170 | .hljs-template-variable {
171 | color: #D8DEE9;
172 | }
173 |
174 | .hljs-template-tag {
175 | color: #5E81AC;
176 | }
177 |
178 | .abnf .hljs-attribute {
179 | color: #88C0D0;
180 | }
181 |
182 | .abnf .hljs-symbol {
183 | color: #EBCB8B;
184 | }
185 |
186 | .apache .hljs-attribute {
187 | color: #88C0D0;
188 | }
189 |
190 | .apache .hljs-section {
191 | color: #81A1C1;
192 | }
193 |
194 | .arduino .hljs-built_in {
195 | color: #88C0D0;
196 | }
197 |
198 | .aspectj .hljs-meta {
199 | color: #D08770;
200 | }
201 |
202 | .aspectj > .hljs-title {
203 | color: #88C0D0;
204 | }
205 |
206 | .bnf .hljs-attribute {
207 | color: #8FBCBB;
208 | }
209 |
210 | .clojure .hljs-name {
211 | color: #88C0D0;
212 | }
213 |
214 | .clojure .hljs-symbol {
215 | color: #EBCB8B;
216 | }
217 |
218 | .coq .hljs-built_in {
219 | color: #88C0D0;
220 | }
221 |
222 | .cpp .hljs-meta-string {
223 | color: #8FBCBB;
224 | }
225 |
226 | .css .hljs-built_in {
227 | color: #88C0D0;
228 | }
229 |
230 | .css .hljs-keyword {
231 | color: #D08770;
232 | }
233 |
234 | .diff .hljs-meta {
235 | color: #8FBCBB;
236 | }
237 |
238 | .ebnf .hljs-attribute {
239 | color: #8FBCBB;
240 | }
241 |
242 | .glsl .hljs-built_in {
243 | color: #88C0D0;
244 | }
245 |
246 | .groovy .hljs-meta:not(:first-child) {
247 | color: #D08770;
248 | }
249 |
250 | .haxe .hljs-meta {
251 | color: #D08770;
252 | }
253 |
254 | .java .hljs-meta {
255 | color: #D08770;
256 | }
257 |
258 | .ldif .hljs-attribute {
259 | color: #8FBCBB;
260 | }
261 |
262 | .lisp .hljs-name {
263 | color: #88C0D0;
264 | }
265 |
266 | .lua .hljs-built_in {
267 | color: #88C0D0;
268 | }
269 |
270 | .moonscript .hljs-built_in {
271 | color: #88C0D0;
272 | }
273 |
274 | .nginx .hljs-attribute {
275 | color: #88C0D0;
276 | }
277 |
278 | .nginx .hljs-section {
279 | color: #5E81AC;
280 | }
281 |
282 | .pf .hljs-built_in {
283 | color: #88C0D0;
284 | }
285 |
286 | .processing .hljs-built_in {
287 | color: #88C0D0;
288 | }
289 |
290 | .scss .hljs-keyword {
291 | color: #81A1C1;
292 | }
293 |
294 | .stylus .hljs-keyword {
295 | color: #81A1C1;
296 | }
297 |
298 | .swift .hljs-meta {
299 | color: #D08770;
300 | }
301 |
302 | .vim .hljs-built_in {
303 | color: #88C0D0;
304 | font-style: italic;
305 | }
306 |
307 | .yaml .hljs-meta {
308 | color: #D08770;
309 | }
310 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/source/js/highlight/README.md:
--------------------------------------------------------------------------------
1 | # Highlight.js
2 |
3 | [](https://travis-ci.org/highlightjs/highlight.js) [](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 |
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 | Classes may also be prefixed with either `language-` or `lang-`.
31 |
32 | ```html
33 | ...
34 | ```
35 |
36 | ### Plaintext and Disabling Highlighting
37 |
38 | To style arbitrary text like code, but without any highlighting, use the
39 | `plaintext` class:
40 |
41 | ```html
42 | ...
43 | ```
44 |
45 | To disable highlighting of a tag completely, use the `nohighlight` class:
46 |
47 | ```html
48 | ...
49 | ```
50 |
51 | ### Supported Languages
52 |
53 | The table below shows the full list of supported languages (and corresponding classes) that are bundled with the library. Note: Which languages are available may depend on how you've built or included the library in your app. See [Getting the Library](#getting-the-library) below.
54 |
55 |
56 | Reveal the full list of languages...
57 |
58 | | Language | Classes | Package |
59 | | :-----------------------| :--------------------- | :------ |
60 | | 1C | 1c | |
61 | | ABNF | abnf | |
62 | | Access logs | accesslog | |
63 | | Ada | ada | |
64 | | ARM assembler | armasm, arm | |
65 | | AVR assembler | avrasm | |
66 | | ActionScript | actionscript, as | |
67 | | Alan | alan, i | [highlightjs-alan](https://github.com/highlightjs/highlightjs-alan) |
68 | | AngelScript | angelscript, asc | |
69 | | Apache | apache, apacheconf | |
70 | | AppleScript | applescript, osascript | |
71 | | Arcade | arcade | |
72 | | AsciiDoc | asciidoc, adoc | |
73 | | AspectJ | aspectj | |
74 | | AutoHotkey | autohotkey | |
75 | | AutoIt | autoit | |
76 | | Awk | awk, mawk, nawk, gawk | |
77 | | Axapta | axapta | |
78 | | Bash | bash, sh, zsh | |
79 | | Basic | basic | |
80 | | BNF | bnf | |
81 | | Brainfuck | brainfuck, bf | |
82 | | C# | cs, csharp | |
83 | | C++ | cpp, c, cc, h, c++, h++, hpp | |
84 | | C/AL | cal | |
85 | | Cache Object Script | cos, cls | |
86 | | CMake | cmake, cmake.in | |
87 | | Coq | coq | |
88 | | CSP | csp | |
89 | | CSS | css | |
90 | | Cap’n Proto | capnproto, capnp | |
91 | | Clojure | clojure, clj | |
92 | | CoffeeScript | coffeescript, coffee, cson, iced | |
93 | | Crmsh | crmsh, crm, pcmk | |
94 | | Crystal | crystal, cr | |
95 | | Cypher (Neo4j) | cypher | [highlightjs-cypher](https://github.com/highlightjs/highlightjs-cypher) |
96 | | D | d | |
97 | | DNS Zone file | dns, zone, bind | |
98 | | DOS | dos, bat, cmd | |
99 | | Dart | dart | |
100 | | Delphi | delphi, dpr, dfm, pas, pascal, freepascal, lazarus, lpr, lfm | |
101 | | Diff | diff, patch | |
102 | | Django | django, jinja | |
103 | | Dockerfile | dockerfile, docker | |
104 | | dsconfig | dsconfig | |
105 | | DTS (Device Tree) | dts | |
106 | | Dust | dust, dst | |
107 | | Dylan | dylan | [highlight-dylan](https://github.com/highlightjs/highlight-dylan) |
108 | | EBNF | ebnf | |
109 | | Elixir | elixir | |
110 | | Elm | elm | |
111 | | Erlang | erlang, erl | |
112 | | Excel | excel, xls, xlsx | |
113 | | Extempore | extempore, xtlang, xtm | [highlightjs-xtlang](https://github.com/highlightjs/highlightjs-xtlang) |
114 | | F# | fsharp, fs | |
115 | | FIX | fix | |
116 | | Fortran | fortran, f90, f95 | |
117 | | G-Code | gcode, nc | |
118 | | Gams | gams, gms | |
119 | | GAUSS | gauss, gss | |
120 | | GDScript | godot, gdscript | [highlightjs-gdscript](https://github.com/highlightjs/highlightjs-gdscript) |
121 | | Gherkin | gherkin | |
122 | | GN for Ninja | gn, gni | [highlightjs-GN](https://github.com/highlightjs/highlightjs-GN/blob/master/gn.js) |
123 | | Go | go, golang | |
124 | | Golo | golo, gololang | |
125 | | Gradle | gradle | |
126 | | Groovy | groovy | |
127 | | HTML, XML | xml, html, xhtml, rss, atom, xjb, xsd, xsl, plist, svg | |
128 | | HTTP | http, https | |
129 | | Haml | haml | |
130 | | Handlebars | handlebars, hbs, html.hbs, html.handlebars | |
131 | | Haskell | haskell, hs | |
132 | | Haxe | haxe, hx | |
133 | | Hy | hy, hylang | |
134 | | Ini, TOML | ini, toml | |
135 | | Inform7 | inform7, i7 | |
136 | | IRPF90 | irpf90 | |
137 | | JSON | json | |
138 | | Java | java, jsp | |
139 | | JavaScript | javascript, js, jsx | |
140 | | Kotlin | kotlin, kt | |
141 | | Leaf | leaf | |
142 | | Lasso | lasso, ls, lassoscript | |
143 | | Less | less | |
144 | | LDIF | ldif | |
145 | | Lisp | lisp | |
146 | | LiveCode Server | livecodeserver | |
147 | | LiveScript | livescript, ls | |
148 | | Lua | lua | |
149 | | Makefile | makefile, mk, mak | |
150 | | Markdown | markdown, md, mkdown, mkd | |
151 | | Mathematica | mathematica, mma, wl | |
152 | | Matlab | matlab | |
153 | | Maxima | maxima | |
154 | | Maya Embedded Language | mel | |
155 | | Mercury | mercury | |
156 | | mIRC Scripting Language | mirc, mrc | [highlightjs-mirc](https://github.com/highlightjs/highlightjs-mirc) |
157 | | Mizar | mizar | |
158 | | Mojolicious | mojolicious | |
159 | | Monkey | monkey | |
160 | | Moonscript | moonscript, moon | |
161 | | N1QL | n1ql | |
162 | | NSIS | nsis | |
163 | | Nginx | nginx, nginxconf | |
164 | | Nimrod | nimrod, nim | |
165 | | Nix | nix | |
166 | | OCaml | ocaml, ml | |
167 | | Objective C | objectivec, mm, objc, obj-c | |
168 | | OpenGL Shading Language | glsl | |
169 | | OpenSCAD | openscad, scad | |
170 | | Oracle Rules Language | ruleslanguage | |
171 | | Oxygene | oxygene | |
172 | | PF | pf, pf.conf | |
173 | | PHP | php, php3, php4, php5, php6 | |
174 | | Parser3 | parser3 | |
175 | | Perl | perl, pl, pm | |
176 | | Plaintext: no highlight | plaintext | |
177 | | Pony | pony | |
178 | | PostgreSQL & PL/pgSQL | pgsql, postgres, postgresql | |
179 | | PowerShell | powershell, ps, ps1 | |
180 | | Processing | processing | |
181 | | Prolog | prolog | |
182 | | Properties | properties | |
183 | | Protocol Buffers | protobuf | |
184 | | Puppet | puppet, pp | |
185 | | Python | python, py, gyp | |
186 | | Python profiler results | profile | |
187 | | Q | k, kdb | |
188 | | QML | qml | |
189 | | R | r | |
190 | | Razor CSHTML | cshtml, razor, razor-cshtml | [highlightjs-cshtml-razor](https://github.com/highlightjs/highlightjs-cshtml-razor) |
191 | | ReasonML | reasonml, re | |
192 | | RenderMan RIB | rib | |
193 | | RenderMan RSL | rsl | |
194 | | Roboconf | graph, instances | |
195 | | Robot Framework | robot, rf | [highlightjs-robot](https://github.com/highlightjs/highlightjs-robot) |
196 | | RPM spec files | rpm-specfile, rpm, spec, rpm-spec, specfile | [highlightjs-rpm-specfile](https://github.com/highlightjs/highlightjs-rpm-specfile) |
197 | | Ruby | ruby, rb, gemspec, podspec, thor, irb | |
198 | | Rust | rust, rs | |
199 | | SAS | SAS, sas | |
200 | | SCSS | scss | |
201 | | SQL | sql | |
202 | | STEP Part 21 | p21, step, stp | |
203 | | Scala | scala | |
204 | | Scheme | scheme | |
205 | | Scilab | scilab, sci | |
206 | | Shape Expressions | shexc | [highlightjs-shexc](https://github.com/highlightjs/highlightjs-shexc) |
207 | | Shell | shell, console | |
208 | | Smali | smali | |
209 | | Smalltalk | smalltalk, st | |
210 | | Solidity | solidity, sol | [highlightjs-solidity](https://github.com/highlightjs/highlightjs-solidity) |
211 | | Stan | stan | |
212 | | Stata | stata | |
213 | | Structured Text | iecst, scl, stl, structured-text | [highlightjs-structured-text](https://github.com/highlightjs/highlightjs-structured-text) |
214 | | Stylus | stylus, styl | |
215 | | SubUnit | subunit | |
216 | | Supercollider | supercollider, sc | [highlightjs-supercollider](https://github.com/highlightjs/highlightjs-supercollider) |
217 | | Swift | swift | |
218 | | Tcl | tcl, tk | |
219 | | Terraform (HCL) | terraform, tf, hcl | [highlightjs-terraform](https://github.com/highlightjs/highlightjs-terraform) |
220 | | Test Anything Protocol | tap | |
221 | | TeX | tex | |
222 | | Thrift | thrift | |
223 | | TP | tp | |
224 | | Twig | twig, craftcms | |
225 | | TypeScript | typescript, ts | |
226 | | VB.Net | vbnet, vb | |
227 | | VBScript | vbscript, vbs | |
228 | | VHDL | vhdl | |
229 | | Vala | vala | |
230 | | Verilog | verilog, v | |
231 | | Vim Script | vim | |
232 | | x86 Assembly | x86asm | |
233 | | XL | xl, tao | |
234 | | XQuery | xquery, xpath, xq | |
235 | | YAML | yml, yaml | |
236 | | Zephir | zephir, zep | |
237 |
238 | Languages with the specified package name are defined in separate repositories
239 | and not included in `highlight.pack.js`.
240 |
241 |
242 |
243 | ## Custom Initialization
244 |
245 | When you need a bit more control over the initialization of
246 | highlight.js, you can use the [`highlightBlock`][3] and [`configure`][4]
247 | functions. This allows you to control *what* to highlight and *when*.
248 |
249 | Here’s an equivalent way to calling [`initHighlightingOnLoad`][1] using
250 | vanilla JS:
251 |
252 | ```js
253 | document.addEventListener('DOMContentLoaded', (event) => {
254 | document.querySelectorAll('pre code').forEach((block) => {
255 | hljs.highlightBlock(block);
256 | });
257 | });
258 | ```
259 |
260 | You can use any tags instead of `` to mark up your code. If
261 | you don't use a container that preserves line breaks you will need to
262 | configure highlight.js to use the `
` tag:
263 |
264 | ```js
265 | hljs.configure({useBR: true});
266 |
267 | document.querySelectorAll('div.code').forEach((block) => {
268 | hljs.highlightBlock(block);
269 | });
270 | ```
271 |
272 | For other options refer to the documentation for [`configure`][4].
273 |
274 |
275 | ## Web Workers
276 |
277 | You can run highlighting inside a web worker to avoid freezing the browser
278 | window while dealing with very big chunks of code.
279 |
280 | In your main script:
281 |
282 | ```js
283 | addEventListener('load', () => {
284 | const code = document.querySelector('#code');
285 | const worker = new Worker('worker.js');
286 | worker.onmessage = (event) => { code.innerHTML = event.data; }
287 | worker.postMessage(code.textContent);
288 | });
289 | ```
290 |
291 | In worker.js:
292 |
293 | ```js
294 | onmessage = (event) => {
295 | importScripts('/highlight.pack.js');
296 | const result = self.hljs.highlightAuto(event.data);
297 | postMessage(result.value);
298 | };
299 | ```
300 |
301 | ## Node.js
302 |
303 | You can use highlight.js with node to highlight content before sending it to the browser.
304 | Make sure to use the `.value` property to get the formatted html.
305 | For more info about the returned object refer to the api docs https://highlightjs.readthedocs.io/en/latest/api.html
306 |
307 |
308 | ```js
309 | // require the highlight.js library including all languages
310 | const hljs = require('./highlight.js');
311 | const highlightedCode = hljs.highlightAuto('Hello World!').value
312 | ```
313 |
314 | ```js
315 | // require the highlight.js library without languages
316 | const hljs = require("highlight.js/lib/highlight.js");
317 | // separately require languages
318 | hljs.registerLanguage('html', require('highlight.js/lib/languages/html'));
319 | hljs.registerLanguage('sql', require('highlight.js/lib/languages/sql'));
320 | // highlight with providing the language
321 | const highlightedCode = hljs.highlight('html', 'Hello World!').value
322 | ```
323 |
324 | ## Getting the Library
325 |
326 | You can get highlight.js as a hosted, or custom-build, browser script or
327 | as a server module. Right out of the box the browser script supports
328 | both AMD and CommonJS, so if you wish you can use RequireJS or
329 | Browserify without having to build from source. The server module also
330 | works perfectly fine with Browserify, but there is the option to use a
331 | build specific to browsers rather than something meant for a server.
332 | Head over to the [download page][5] for all the options.
333 |
334 | **Don't link to GitHub directly.** The library is not supposed to work straight
335 | from the source, it requires building. If none of the pre-packaged options
336 | work for you refer to the [building documentation][6].
337 |
338 | **The CDN-hosted package doesn't have all the languages.** Otherwise it'd be
339 | too big. If you don't see the language you need in the ["Common" section][5],
340 | it can be added manually:
341 |
342 | ```html
343 |
346 | ```
347 |
348 | **On Almond.** You need to use the optimizer to give the module a name. For
349 | example:
350 |
351 | ```bash
352 | r.js -o name=hljs paths.hljs=/path/to/highlight out=highlight.js
353 | ```
354 |
355 |
356 | ### CommonJS
357 |
358 | You can import Highlight.js as a CommonJS-module:
359 |
360 | ```bash
361 | npm install highlight.js --save
362 | ```
363 |
364 | In your application:
365 |
366 | ```js
367 | import hljs from 'highlight.js';
368 | ```
369 |
370 | The default import imports all languages! Therefore it is likely to be more efficient to import only the library and the languages you need:
371 |
372 | ```js
373 | import hljs from 'highlight.js/lib/highlight';
374 | import javascript from 'highlight.js/lib/languages/javascript';
375 | hljs.registerLanguage('javascript', javascript);
376 | ```
377 |
378 | 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:
379 |
380 | ```js
381 | import hljs from 'highlight.js/lib/highlight';
382 | import 'highlight.js/styles/github.css';
383 | ```
384 |
385 | ## License
386 |
387 | Highlight.js is released under the BSD License. See [LICENSE][7] file
388 | for details.
389 |
390 | ## Links
391 |
392 | The official site for the library is at .
393 |
394 | Further in-depth documentation for the API and other topics is at
395 | .
396 |
397 | Authors and contributors are listed in the [AUTHORS.en.txt][8] file.
398 |
399 | [1]: http://highlightjs.readthedocs.io/en/latest/api.html#inithighlightingonload
400 | [2]: http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html
401 | [3]: http://highlightjs.readthedocs.io/en/latest/api.html#highlightblock-block
402 | [4]: http://highlightjs.readthedocs.io/en/latest/api.html#configure-options
403 | [5]: https://highlightjs.org/download/
404 | [6]: http://highlightjs.readthedocs.io/en/latest/building-testing.html
405 | [7]: https://github.com/highlightjs/highlight.js/blob/master/LICENSE
406 | [8]: https://github.com/highlightjs/highlight.js/blob/master/AUTHORS.en.txt
407 |
--------------------------------------------------------------------------------