aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/default.css262
-rw-r--r--source/default.js21
-rw-r--r--source/languages/prism-bash.js84
-rw-r--r--source/languages/prism-c.js33
-rw-r--r--source/languages/prism-css.js52
-rw-r--r--source/languages/prism-go.js12
-rw-r--r--source/languages/prism-javascript.js56
-rw-r--r--source/languages/prism-json.js14
-rw-r--r--source/languages/prism-nginx.js11
-rw-r--r--source/languages/prism-pascal.js55
-rw-r--r--source/languages/prism-python.js29
-rw-r--r--source/prism.css167
-rw-r--r--source/prism.js1071
13 files changed, 1867 insertions, 0 deletions
diff --git a/source/default.css b/source/default.css
new file mode 100644
index 0000000..a7dff38
--- /dev/null
+++ b/source/default.css
@@ -0,0 +1,262 @@
1@charset "utf-8";
2
3@import url('https://fonts.googleapis.com/css?family=Heebo:100,300,400,500,700,800,900" rel="stylesheet">');
4@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600,700,900" rel="stylesheet">');
5
6* {
7 box-sizing: border-box;
8 -moz-osx-font-smoothing: grayscale !important;
9 text-rendering: optimizeLegibility !important;
10 -webkit-font-smoothing: antialiased !important;
11}
12
13body {
14 font-family: 'Heebo', sans-serif;
15 font-size: 18px;
16 line-height: 170%;
17}
18
19a {
20 color: inherit;
21 text-decoration: underline;
22 text-decoration-color: fuchsia;
23 text-decoration-style: wavy;
24 border: 2px dotted transparent;
25 display: inline-block;
26}
27
28a:active {
29 border-color: black;
30}
31
32ol a {
33 text-decoration: none;
34}
35
36ol a:hover {
37 text-decoration: underline;
38}
39
40h1 {
41 line-height: 140%;
42 font-weight: 900;
43 font-size: 250%;
44}
45
46h2,h3,h4,h5 {
47 margin-top: 50px;
48}
49
50img {
51 max-width: 100%;
52 margin: 0 auto;
53 display: block;
54}
55
56.wrapper {
57 max-width: 750px;
58 margin: 0 auto;
59}
60
61blockquote {
62 margin: 50px 0 50px 50px;
63}
64
65.pubdate {
66 font-size: 80%;
67 color: #666;
68}
69
70/********************************************************** CODE HIGHLIGHTING */
71
72pre, code {
73 font-family: 'Source Code Pro', monospace !important;
74 font-weight: 500;
75}
76
77pre {
78 font-size: 80%;
79 margin: 20px;
80 background: #eee;
81}
82
83p > code {
84 background: rgb(48, 46, 46);
85 padding: 1px 0.95rem 2px;
86 border-radius: 1em;
87 font-size: 70%;
88 font-weight: 600;
89 color: #fff;
90 display: inline;
91 -webkit-box-decoration-break: clone;
92 cursor:crosshair;
93}
94
95p > code:hover {
96 background: fuchsia;
97}
98
99/***************************************************************** OL COUNTER */
100
101ol {
102 list-style: none;
103 counter-reset: li;
104}
105
106ol li {
107 counter-increment: li;
108}
109
110ol li::before {
111 content: counter(li) ".";
112 color: #ccc;
113 font-weight: 500;
114 display: inline-block;
115 width: 1em;
116 margin-left: -1.5em;
117 margin-right: 0.9em;
118 text-align: right;
119}
120
121ol li a {
122 text-decoration: none;
123}
124
125/********************************************************************* TABLES */
126
127table {
128 width: 100%;
129 border-collapse: collapse;
130 border-spacing: 0;
131 font-size: 90%;
132 text-align: left;
133 margin-top: 50px;
134 margin-bottom: 50px;
135}
136
137th,td {
138 border-bottom: 2px solid #888;
139 padding: 10px;
140}
141
142th {
143 font-size: 130%;
144}
145
146tr:last-child td {
147 border-width: 0;
148}
149
150/****************************************************************** FOOTNOTES */
151
152.footnotes p {
153 padding: 0;
154 display: inline-block;
155 margin: 0;
156}
157
158.footnotes-sep {
159 border: 0;
160}
161
162/************************************************* BGCOLOR WHEN TEXT SELECTED */
163
164::selection {
165 background: #ff0;
166 color: #000;
167}
168
169::-moz-selection {
170 background: #ff0;
171 color: #000;
172}
173
174/********************************************************** CUSTOM SCROLLBARS */
175
176pre::-webkit-scrollbar {
177 width: 5px;
178 height: 8px;
179 background-color: transparent;
180}
181
182pre::-webkit-scrollbar-thumb {
183 background: #ddd;
184}
185
186/*************************************************************** HEADER + NAV */
187
188menu {
189 display: grid;
190 grid-template-columns: 1fr 1fr;
191 font-size: 80%;
192 padding: 0;
193 padding-top: 10px;
194
195}
196
197menu a.logo {
198 background: black;
199 color: white;
200 font-weight: 800;
201 text-decoration: none;
202 padding: 3px 15px;
203}
204
205menu a.logo:hover {
206 background: fuchsia;
207 color: white;
208}
209
210menu nav {
211 text-align: right;
212 margin-top: 3px;
213}
214
215menu nav a {
216 padding-top: 8px;
217 margin-left: 25px;
218}
219
220menu nav a svg {
221 width: 20px;
222 height: 20px;
223}
224
225/********************************************************************* FOOTER */
226
227footer {
228 padding-top: 50px;
229 padding-bottom: 50px;
230 font-weight: 500;
231 font-size: 80%;
232}
233
234footer > * {
235 text-decoration: none;
236 margin-right: 20px;
237 color: #333;
238}
239
240/***************************************************************** RESPONSIVE */
241
242@media only screen and (max-width:800px) {
243 body {
244 font-size: 16px;
245 }
246
247 .wrapper {
248 padding: 10px 20px !important;
249 }
250
251 h1 {
252 font-size: 200%;
253 }
254}
255
256.article-list a {
257 text-decoration: none;
258}
259
260.article-list a h2 {
261 margin-bottom: 5px;
262}
diff --git a/source/default.js b/source/default.js
new file mode 100644
index 0000000..2df34f0
--- /dev/null
+++ b/source/default.js
@@ -0,0 +1,21 @@
1//Responsive tables
2document.querySelectorAll('table').forEach(function (element) {
3 if (!element.classList.contains('rouge-table')) {
4 let parent = element.parentNode;
5 let wrapper = document.createElement('div');
6 wrapper.classList.add('responsive-table');
7 parent.replaceChild(wrapper, element);
8 wrapper.appendChild(element);
9 }
10});
11
12
13// Open external links in new tab
14let links = document.links;
15for (let i = 0, linksLength = links.length; i < linksLength; i++) {
16 if (links[i].hostname != window.location.hostname) {
17 links[i].target = '_blank';
18 links[i].setAttribute('rel', 'noopener nofollow');
19 }
20}
21
diff --git a/source/languages/prism-bash.js b/source/languages/prism-bash.js
new file mode 100644
index 0000000..5093ffd
--- /dev/null
+++ b/source/languages/prism-bash.js
@@ -0,0 +1,84 @@
1(function(Prism) {
2 var insideString = {
3 variable: [
4 // Arithmetic Environment
5 {
6 pattern: /\$?\(\([\s\S]+?\)\)/,
7 inside: {
8 // If there is a $ sign at the beginning highlight $(( and )) as variable
9 variable: [{
10 pattern: /(^\$\(\([\s\S]+)\)\)/,
11 lookbehind: true
12 },
13 /^\$\(\(/
14 ],
15 number: /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?/,
16 // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
17 operator: /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
18 // If there is no $ sign at the beginning highlight (( and )) as punctuation
19 punctuation: /\(\(?|\)\)?|,|;/
20 }
21 },
22 // Command Substitution
23 {
24 pattern: /\$\([^)]+\)|`[^`]+`/,
25 greedy: true,
26 inside: {
27 variable: /^\$\(|^`|\)$|`$/
28 }
29 },
30 /\$(?:[\w#?*!@]+|\{[^}]+\})/i
31 ]
32 };
33
34 Prism.languages.bash = {
35 'shebang': {
36 pattern: /^#!\s*\/bin\/bash|^#!\s*\/bin\/sh/,
37 alias: 'important'
38 },
39 'comment': {
40 pattern: /(^|[^"{\\])#.*/,
41 lookbehind: true
42 },
43 'string': [
44 //Support for Here-Documents https://en.wikipedia.org/wiki/Here_document
45 {
46 pattern: /((?:^|[^<])<<\s*)["']?(\w+?)["']?\s*\r?\n(?:[\s\S])*?\r?\n\2/,
47 lookbehind: true,
48 greedy: true,
49 inside: insideString
50 },
51 {
52 pattern: /(["'])(?:\\[\s\S]|\$\([^)]+\)|`[^`]+`|(?!\1)[^\\])*\1/,
53 greedy: true,
54 inside: insideString
55 }
56 ],
57 'variable': insideString.variable,
58 // Originally based on http://ss64.com/bash/
59 'function': {
60 pattern: /(^|[\s;|&])(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|npm|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)(?=$|[\s;|&])/,
61 lookbehind: true
62 },
63 'keyword': {
64 pattern: /(^|[\s;|&])(?:let|:|\.|if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)(?=$|[\s;|&])/,
65 lookbehind: true
66 },
67 'boolean': {
68 pattern: /(^|[\s;|&])(?:true|false)(?=$|[\s;|&])/,
69 lookbehind: true
70 },
71 'operator': /&&?|\|\|?|==?|!=?|<<<?|>>|<=?|>=?|=~/,
72 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];]/
73 };
74
75 var inside = insideString.variable[1].inside;
76 inside.string = Prism.languages.bash.string;
77 inside['function'] = Prism.languages.bash['function'];
78 inside.keyword = Prism.languages.bash.keyword;
79 inside['boolean'] = Prism.languages.bash['boolean'];
80 inside.operator = Prism.languages.bash.operator;
81 inside.punctuation = Prism.languages.bash.punctuation;
82
83 Prism.languages.shell = Prism.languages.bash;
84})(Prism);
diff --git a/source/languages/prism-c.js b/source/languages/prism-c.js
new file mode 100644
index 0000000..86ffac0
--- /dev/null
+++ b/source/languages/prism-c.js
@@ -0,0 +1,33 @@
1Prism.languages.c = Prism.languages.extend('clike', {
2 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,
3 'operator': /-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/]/,
4 'number': /(?:\b0x[\da-f]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*/i
5});
6
7Prism.languages.insertBefore('c', 'string', {
8 'macro': {
9 // allow for multiline macro definitions
10 // spaces after the # character compile fine with gcc
11 pattern: /(^\s*)#\s*[a-z]+(?:[^\r\n\\]|\\(?:\r\n|[\s\S]))*/im,
12 lookbehind: true,
13 alias: 'property',
14 inside: {
15 // highlight the path of the include statement as a string
16 'string': {
17 pattern: /(#\s*include\s*)(?:<.+?>|("|')(?:\\?.)+?\2)/,
18 lookbehind: true
19 },
20 // highlight macro directives as keywords
21 'directive': {
22 pattern: /(#\s*)\b(?:define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using)\b/,
23 lookbehind: true,
24 alias: 'keyword'
25 }
26 }
27 },
28 // highlight predefined macros as constants
29 'constant': /\b(?:__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr)\b/
30});
31
32delete Prism.languages.c['class-name'];
33delete Prism.languages.c['boolean'];
diff --git a/source/languages/prism-css.js b/source/languages/prism-css.js
new file mode 100644
index 0000000..e6fdf6f
--- /dev/null
+++ b/source/languages/prism-css.js
@@ -0,0 +1,52 @@
1Prism.languages.css = {
2 'comment': /\/\*[\s\S]*?\*\//,
3 'atrule': {
4 pattern: /@[\w-]+?.*?(?:;|(?=\s*\{))/i,
5 inside: {
6 'rule': /@[\w-]+/
7 // See rest below
8 }
9 },
10 'url': /url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
11 'selector': /[^{}\s][^{};]*?(?=\s*\{)/,
12 'string': {
13 pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
14 greedy: true
15 },
16 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
17 'important': /\B!important\b/i,
18 'function': /[-a-z0-9]+(?=\()/i,
19 'punctuation': /[(){};:]/
20};
21
22Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
23
24if (Prism.languages.markup) {
25 Prism.languages.insertBefore('markup', 'tag', {
26 'style': {
27 pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i,
28 lookbehind: true,
29 inside: Prism.languages.css,
30 alias: 'language-css',
31 greedy: true
32 }
33 });
34
35 Prism.languages.insertBefore('inside', 'attr-value', {
36 'style-attr': {
37 pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
38 inside: {
39 'attr-name': {
40 pattern: /^\s*style/i,
41 inside: Prism.languages.markup.tag.inside
42 },
43 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
44 'attr-value': {
45 pattern: /.+/i,
46 inside: Prism.languages.css
47 }
48 },
49 alias: 'language-css'
50 }
51 }, Prism.languages.markup.tag);
52} \ No newline at end of file
diff --git a/source/languages/prism-go.js b/source/languages/prism-go.js
new file mode 100644
index 0000000..cc792a0
--- /dev/null
+++ b/source/languages/prism-go.js
@@ -0,0 +1,12 @@
1Prism.languages.go = Prism.languages.extend('clike', {
2 'keyword': /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
3 'builtin': /\b(?:bool|byte|complex(?:64|128)|error|float(?:32|64)|rune|string|u?int(?:8|16|32|64)?|uintptr|append|cap|close|complex|copy|delete|imag|len|make|new|panic|print(?:ln)?|real|recover)\b/,
4 'boolean': /\b(?:_|iota|nil|true|false)\b/,
5 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
6 'number': /(?:\b0x[a-f\d]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[-+]?\d+)?)i?/i,
7 'string': {
8 pattern: /(["'`])(\\[\s\S]|(?!\1)[^\\])*\1/,
9 greedy: true
10 }
11});
12delete Prism.languages.go['class-name'];
diff --git a/source/languages/prism-javascript.js b/source/languages/prism-javascript.js
new file mode 100644
index 0000000..7800a7d
--- /dev/null
+++ b/source/languages/prism-javascript.js
@@ -0,0 +1,56 @@
1Prism.languages.javascript = Prism.languages.extend('clike', {
2 'keyword': /\b(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,
3 'number': /\b(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,
4 // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
5 'function': /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\()/i,
6 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
7});
8
9Prism.languages.insertBefore('javascript', 'keyword', {
10 'regex': {
11 pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/,
12 lookbehind: true,
13 greedy: true
14 },
15 // This must be declared before keyword because we use "function" inside the look-forward
16 'function-variable': {
17 pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i,
18 alias: 'function'
19 },
20 'constant': /\b[A-Z][A-Z\d_]*\b/
21});
22
23Prism.languages.insertBefore('javascript', 'string', {
24 'template-string': {
25 pattern: /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/,
26 greedy: true,
27 inside: {
28 'interpolation': {
29 pattern: /\${[^}]+}/,
30 inside: {
31 'interpolation-punctuation': {
32 pattern: /^\${|}$/,
33 alias: 'punctuation'
34 },
35 rest: null // See below
36 }
37 },
38 'string': /[\s\S]+/
39 }
40 }
41});
42Prism.languages.javascript['template-string'].inside['interpolation'].inside.rest = Prism.languages.javascript;
43
44if (Prism.languages.markup) {
45 Prism.languages.insertBefore('markup', 'tag', {
46 'script': {
47 pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,
48 lookbehind: true,
49 inside: Prism.languages.javascript,
50 alias: 'language-javascript',
51 greedy: true
52 }
53 });
54}
55
56Prism.languages.js = Prism.languages.javascript;
diff --git a/source/languages/prism-json.js b/source/languages/prism-json.js
new file mode 100644
index 0000000..06e847e
--- /dev/null
+++ b/source/languages/prism-json.js
@@ -0,0 +1,14 @@
1Prism.languages.json = {
2 'property': /"(?:\\.|[^\\"\r\n])*"(?=\s*:)/i,
3 'string': {
4 pattern: /"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
5 greedy: true
6 },
7 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,
8 'punctuation': /[{}[\]);,]/,
9 'operator': /:/g,
10 'boolean': /\b(?:true|false)\b/i,
11 'null': /\bnull\b/i
12};
13
14Prism.languages.jsonp = Prism.languages.json;
diff --git a/source/languages/prism-nginx.js b/source/languages/prism-nginx.js
new file mode 100644
index 0000000..c3fea0c
--- /dev/null
+++ b/source/languages/prism-nginx.js
@@ -0,0 +1,11 @@
1Prism.languages.nginx = Prism.languages.extend('clike', {
2 'comment': {
3 pattern: /(^|[^"{\\])#.*/,
4 lookbehind: true
5 },
6 'keyword': /\b(?:CONTENT_|DOCUMENT_|GATEWAY_|HTTP_|HTTPS|if_not_empty|PATH_|QUERY_|REDIRECT_|REMOTE_|REQUEST_|SCGI|SCRIPT_|SERVER_|http|events|accept_mutex|accept_mutex_delay|access_log|add_after_body|add_before_body|add_header|addition_types|aio|alias|allow|ancient_browser|ancient_browser_value|auth|auth_basic|auth_basic_user_file|auth_http|auth_http_header|auth_http_timeout|autoindex|autoindex_exact_size|autoindex_localtime|break|charset|charset_map|charset_types|chunked_transfer_encoding|client_body_buffer_size|client_body_in_file_only|client_body_in_single_buffer|client_body_temp_path|client_body_timeout|client_header_buffer_size|client_header_timeout|client_max_body_size|connection_pool_size|create_full_put_path|daemon|dav_access|dav_methods|debug_connection|debug_points|default_type|deny|devpoll_changes|devpoll_events|directio|directio_alignment|disable_symlinks|empty_gif|env|epoll_events|error_log|error_page|expires|fastcgi_buffer_size|fastcgi_buffers|fastcgi_busy_buffers_size|fastcgi_cache|fastcgi_cache_bypass|fastcgi_cache_key|fastcgi_cache_lock|fastcgi_cache_lock_timeout|fastcgi_cache_methods|fastcgi_cache_min_uses|fastcgi_cache_path|fastcgi_cache_purge|fastcgi_cache_use_stale|fastcgi_cache_valid|fastcgi_connect_timeout|fastcgi_hide_header|fastcgi_ignore_client_abort|fastcgi_ignore_headers|fastcgi_index|fastcgi_intercept_errors|fastcgi_keep_conn|fastcgi_max_temp_file_size|fastcgi_next_upstream|fastcgi_no_cache|fastcgi_param|fastcgi_pass|fastcgi_pass_header|fastcgi_read_timeout|fastcgi_redirect_errors|fastcgi_send_timeout|fastcgi_split_path_info|fastcgi_store|fastcgi_store_access|fastcgi_temp_file_write_size|fastcgi_temp_path|flv|geo|geoip_city|geoip_country|google_perftools_profiles|gzip|gzip_buffers|gzip_comp_level|gzip_disable|gzip_http_version|gzip_min_length|gzip_proxied|gzip_static|gzip_types|gzip_vary|if|if_modified_since|ignore_invalid_headers|image_filter|image_filter_buffer|image_filter_jpeg_quality|image_filter_sharpen|image_filter_transparency|imap_capabilities|imap_client_buffer|include|index|internal|ip_hash|keepalive|keepalive_disable|keepalive_requests|keepalive_timeout|kqueue_changes|kqueue_events|large_client_header_buffers|limit_conn|limit_conn_log_level|limit_conn_zone|limit_except|limit_rate|limit_rate_after|limit_req|limit_req_log_level|limit_req_zone|limit_zone|lingering_close|lingering_time|lingering_timeout|listen|location|lock_file|log_format|log_format_combined|log_not_found|log_subrequest|map|map_hash_bucket_size|map_hash_max_size|master_process|max_ranges|memcached_buffer_size|memcached_connect_timeout|memcached_next_upstream|memcached_pass|memcached_read_timeout|memcached_send_timeout|merge_slashes|min_delete_depth|modern_browser|modern_browser_value|mp4|mp4_buffer_size|mp4_max_buffer_size|msie_padding|msie_refresh|multi_accept|open_file_cache|open_file_cache_errors|open_file_cache_min_uses|open_file_cache_valid|open_log_file_cache|optimize_server_names|override_charset|pcre_jit|perl|perl_modules|perl_require|perl_set|pid|pop3_auth|pop3_capabilities|port_in_redirect|post_action|postpone_output|protocol|proxy|proxy_buffer|proxy_buffer_size|proxy_buffering|proxy_buffers|proxy_busy_buffers_size|proxy_cache|proxy_cache_bypass|proxy_cache_key|proxy_cache_lock|proxy_cache_lock_timeout|proxy_cache_methods|proxy_cache_min_uses|proxy_cache_path|proxy_cache_use_stale|proxy_cache_valid|proxy_connect_timeout|proxy_cookie_domain|proxy_cookie_path|proxy_headers_hash_bucket_size|proxy_headers_hash_max_size|proxy_hide_header|proxy_http_version|proxy_ignore_client_abort|proxy_ignore_headers|proxy_intercept_errors|proxy_max_temp_file_size|proxy_method|proxy_next_upstream|proxy_no_cache|proxy_pass|proxy_pass_error_message|proxy_pass_header|proxy_pass_request_body|proxy_pass_request_headers|proxy_read_timeout|proxy_redirect|proxy_redirect_errors|proxy_send_lowat|proxy_send_timeout|proxy_set_body|proxy_set_header|proxy_ssl_session_reuse|proxy_store|proxy_store_access|proxy_temp_file_write_size|proxy_temp_path|proxy_timeout|proxy_upstream_fail_timeout|proxy_upstream_max_fails|random_index|read_ahead|real_ip_header|recursive_error_pages|request_pool_size|reset_timedout_connection|resolver|resolver_timeout|return|rewrite|root|rtsig_overflow_events|rtsig_overflow_test|rtsig_overflow_threshold|rtsig_signo|satisfy|satisfy_any|secure_link_secret|send_lowat|send_timeout|sendfile|sendfile_max_chunk|server|server_name|server_name_in_redirect|server_names_hash_bucket_size|server_names_hash_max_size|server_tokens|set|set_real_ip_from|smtp_auth|smtp_capabilities|so_keepalive|source_charset|split_clients|ssi|ssi_silent_errors|ssi_types|ssi_value_length|ssl|ssl_certificate|ssl_certificate_key|ssl_ciphers|ssl_client_certificate|ssl_crl|ssl_dhparam|ssl_engine|ssl_prefer_server_ciphers|ssl_protocols|ssl_session_cache|ssl_session_timeout|ssl_verify_client|ssl_verify_depth|starttls|stub_status|sub_filter|sub_filter_once|sub_filter_types|tcp_nodelay|tcp_nopush|timeout|timer_resolution|try_files|types|types_hash_bucket_size|types_hash_max_size|underscores_in_headers|uninitialized_variable_warn|upstream|use|user|userid|userid_domain|userid_expires|userid_name|userid_p3p|userid_path|userid_service|valid_referers|variables_hash_bucket_size|variables_hash_max_size|worker_connections|worker_cpu_affinity|worker_priority|worker_processes|worker_rlimit_core|worker_rlimit_nofile|worker_rlimit_sigpending|working_directory|xclient|xml_entities|xslt_entities|xslt_stylesheet|xslt_types)\b/i
7});
8
9Prism.languages.insertBefore('nginx', 'keyword', {
10 'variable': /\$[a-z_]+/i
11}); \ No newline at end of file
diff --git a/source/languages/prism-pascal.js b/source/languages/prism-pascal.js
new file mode 100644
index 0000000..bc7a283
--- /dev/null
+++ b/source/languages/prism-pascal.js
@@ -0,0 +1,55 @@
1// Based on Free Pascal
2
3/* TODO
4 Support inline asm ?
5*/
6
7Prism.languages.pascal = {
8 'comment': [
9 /\(\*[\s\S]+?\*\)/,
10 /\{[\s\S]+?\}/,
11 /\/\/.*/
12 ],
13 'string': {
14 pattern: /(?:'(?:''|[^'\r\n])*'|#[&$%]?[a-f\d]+)+|\^[a-z]/i,
15 greedy: true
16 },
17 'keyword': [
18 {
19 // Turbo Pascal
20 pattern: /(^|[^&])\b(?:absolute|array|asm|begin|case|const|constructor|destructor|do|downto|else|end|file|for|function|goto|if|implementation|inherited|inline|interface|label|nil|object|of|operator|packed|procedure|program|record|reintroduce|repeat|self|set|string|then|to|type|unit|until|uses|var|while|with)\b/i,
21 lookbehind: true
22 },
23 {
24 // Free Pascal
25 pattern: /(^|[^&])\b(?:dispose|exit|false|new|true)\b/i,
26 lookbehind: true
27 },
28 {
29 // Object Pascal
30 pattern: /(^|[^&])\b(?:class|dispinterface|except|exports|finalization|finally|initialization|inline|library|on|out|packed|property|raise|resourcestring|threadvar|try)\b/i,
31 lookbehind: true
32 },
33 {
34 // Modifiers
35 pattern: /(^|[^&])\b(?:absolute|abstract|alias|assembler|bitpacked|break|cdecl|continue|cppdecl|cvar|default|deprecated|dynamic|enumerator|experimental|export|external|far|far16|forward|generic|helper|implements|index|interrupt|iochecks|local|message|name|near|nodefault|noreturn|nostackframe|oldfpccall|otherwise|overload|override|pascal|platform|private|protected|public|published|read|register|reintroduce|result|safecall|saveregisters|softfloat|specialize|static|stdcall|stored|strict|unaligned|unimplemented|varargs|virtual|write)\b/i,
36 lookbehind: true
37 }
38 ],
39 'number': [
40 // Hexadecimal, octal and binary
41 /(?:[&%]\d+|\$[a-f\d]+)/i,
42 // Decimal
43 /\b\d+(?:\.\d+)?(?:e[+-]?\d+)?/i
44 ],
45 'operator': [
46 /\.\.|\*\*|:=|<[<=>]?|>[>=]?|[+\-*\/]=?|[@^=]/i,
47 {
48 pattern: /(^|[^&])\b(?:and|as|div|exclude|in|include|is|mod|not|or|shl|shr|xor)\b/,
49 lookbehind: true
50 }
51 ],
52 'punctuation': /\(\.|\.\)|[()\[\]:;,.]/
53};
54
55Prism.languages.objectpascal = Prism.languages.pascal; \ No newline at end of file
diff --git a/source/languages/prism-python.js b/source/languages/prism-python.js
new file mode 100644
index 0000000..ecad408
--- /dev/null
+++ b/source/languages/prism-python.js
@@ -0,0 +1,29 @@
1Prism.languages.python = {
2 'comment': {
3 pattern: /(^|[^\\])#.*/,
4 lookbehind: true
5 },
6 'triple-quoted-string': {
7 pattern: /("""|''')[\s\S]+?\1/,
8 greedy: true,
9 alias: 'string'
10 },
11 'string': {
12 pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
13 greedy: true
14 },
15 'function': {
16 pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
17 lookbehind: true
18 },
19 'class-name': {
20 pattern: /(\bclass\s+)\w+/i,
21 lookbehind: true
22 },
23 'keyword': /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|pass|print|raise|return|try|while|with|yield)\b/,
24 'builtin':/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
25 'boolean': /\b(?:True|False|None)\b/,
26 'number': /(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
27 'operator': /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
28 'punctuation': /[{}[\];(),.:]/
29};
diff --git a/source/prism.css b/source/prism.css
new file mode 100644
index 0000000..21c8aa8
--- /dev/null
+++ b/source/prism.css
@@ -0,0 +1,167 @@
1/**
2 * prism.js default theme for JavaScript, CSS and HTML
3 * Based on dabblet (http://dabblet.com)
4 * @author Lea Verou
5 */
6
7 code[class*="language-"],
8 pre[class*="language-"] {
9 color: black;
10 font-family: monospace;
11 text-align: left;
12 white-space: pre;
13 word-spacing: normal;
14 word-break: normal;
15 word-wrap: normal;
16 line-height: 1.5;
17
18 -moz-tab-size: 4;
19 -o-tab-size: 4;
20 tab-size: 4;
21
22 -webkit-hyphens: none;
23 -moz-hyphens: none;
24 -ms-hyphens: none;
25 hyphens: none;
26 }
27
28 pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
29 code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
30 text-shadow: none;
31 }
32
33 pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
34 code[class*="language-"]::selection, code[class*="language-"] ::selection {
35 text-shadow: none;
36 }
37
38 @media print {
39 code[class*="language-"],
40 pre[class*="language-"] {
41 text-shadow: none;
42 }
43 }
44
45 /* Code blocks */
46 pre[class*="language-"] {
47 padding: 1em;
48 margin: .5em 0;
49 overflow: auto;
50 }
51
52 :not(pre) > code[class*="language-"],
53 pre[class*="language-"] {
54 }
55
56 /* Inline code */
57 :not(pre) > code[class*="language-"] {
58 padding: .1em;
59 border-radius: .3em;
60 white-space: normal;
61 }
62
63 .token.comment,
64 .token.prolog,
65 .token.doctype,
66 .token.cdata {
67 color: slategray;
68 }
69
70 .token.punctuation {
71 color: #999;
72 }
73
74 .namespace {
75 opacity: .7;
76 }
77
78 .token.property,
79 .token.tag,
80 .token.boolean,
81 .token.number,
82 .token.constant,
83 .token.symbol,
84 .token.deleted {
85 color: #905;
86 }
87
88 .token.selector,
89 .token.attr-name,
90 .token.string,
91 .token.char,
92 .token.builtin,
93 .token.inserted {
94 color: #690;
95 }
96
97 .token.operator,
98 .token.entity,
99 .token.url,
100 .language-css .token.string,
101 .style .token.string {
102 color: #9a6e3a;
103 /*background: hsla(0, 0%, 100%, .5);*/
104 }
105
106 .token.atrule,
107 .token.attr-value,
108 .token.keyword {
109 color: #07a;
110 }
111
112 .token.function,
113 .token.class-name {
114 color: #DD4A68;
115 }
116
117 .token.regex,
118 .token.important,
119 .token.variable {
120 color: #e90;
121 }
122
123 .token.important,
124 .token.bold {
125 font-weight: bold;
126 }
127 .token.italic {
128 font-style: italic;
129 }
130
131 .token.entity {
132 cursor: help;
133 }
134
135 pre[class*="language-"].line-numbers {
136 position: relative;
137 padding-left: 3.8em;
138 counter-reset: linenumber;
139}
140
141pre[class*="language-"].line-numbers > code {
142 position: relative;
143 white-space: inherit;
144}
145
146.line-numbers .line-numbers-rows {
147 position: absolute;
148 pointer-events: none;
149 top: 0;
150 font-size: 100%;
151 left: -3.8em;
152 width: 3em; /* works for line-numbers below 1000 lines */
153 letter-spacing: -1px;
154 border-right: 1px solid #999;
155
156 -webkit-user-select: none;
157 -moz-user-select: none;
158 -ms-user-select: none;
159 user-select: none;
160
161}
162
163 .line-numbers-rows > span {
164 pointer-events: none;
165 display: block;
166 counter-increment: linenumber;
167 }
diff --git a/source/prism.js b/source/prism.js
new file mode 100644
index 0000000..304be1e
--- /dev/null
+++ b/source/prism.js
@@ -0,0 +1,1071 @@
1
2/* **********************************************
3 Begin prism-core.js
4********************************************** */
5
6var _self = (typeof window !== 'undefined')
7 ? window // if in browser
8 : (
9 (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
10 ? self // if in worker
11 : {} // if in node js
12 );
13
14/**
15 * Prism: Lightweight, robust, elegant syntax highlighting
16 * MIT license http://www.opensource.org/licenses/mit-license.php/
17 * @author Lea Verou http://lea.verou.me
18 */
19
20var Prism = (function () {
21
22 // Private helper vars
23 var lang = /\blang(?:uage)?-([\w-]+)\b/i;
24 var uniqueId = 0;
25
26 var _ = _self.Prism = {
27 manual: _self.Prism && _self.Prism.manual,
28 disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
29 util: {
30 encode: function (tokens) {
31 if (tokens instanceof Token) {
32 return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
33 } else if (_.util.type(tokens) === 'Array') {
34 return tokens.map(_.util.encode);
35 } else {
36 return tokens.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\u00a0/g, ' ');
37 }
38 },
39
40 type: function (o) {
41 return Object.prototype.toString.call(o).slice(8, -1);
42 },
43
44 objId: function (obj) {
45 if (!obj['__id']) {
46 Object.defineProperty(obj, '__id', { value: ++uniqueId });
47 }
48 return obj['__id'];
49 },
50
51 // Deep clone a language definition (e.g. to extend it)
52 clone: function (o, visited) {
53 var type = _.util.type(o);
54 visited = visited || {};
55
56 switch (type) {
57 case 'Object':
58 if (visited[_.util.objId(o)]) {
59 return visited[_.util.objId(o)];
60 }
61 var clone = {};
62 visited[_.util.objId(o)] = clone;
63
64 for (var key in o) {
65 if (o.hasOwnProperty(key)) {
66 clone[key] = _.util.clone(o[key], visited);
67 }
68 }
69
70 return clone;
71
72 case 'Array':
73 if (visited[_.util.objId(o)]) {
74 return visited[_.util.objId(o)];
75 }
76 var clone = [];
77 visited[_.util.objId(o)] = clone;
78
79 o.forEach(function (v, i) {
80 clone[i] = _.util.clone(v, visited);
81 });
82
83 return clone;
84 }
85
86 return o;
87 }
88 },
89
90 languages: {
91 extend: function (id, redef) {
92 var lang = _.util.clone(_.languages[id]);
93
94 for (var key in redef) {
95 lang[key] = redef[key];
96 }
97
98 return lang;
99 },
100
101 /**
102 * Insert a token before another token in a language literal
103 * As this needs to recreate the object (we cannot actually insert before keys in object literals),
104 * we cannot just provide an object, we need an object and a key.
105 * @param inside The key (or language id) of the parent
106 * @param before The key to insert before.
107 * @param insert Object with the key/value pairs to insert
108 * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
109 */
110 insertBefore: function (inside, before, insert, root) {
111 root = root || _.languages;
112 var grammar = root[inside];
113 var ret = {};
114
115 for (var token in grammar) {
116 if (grammar.hasOwnProperty(token)) {
117
118 if (token == before) {
119 for (var newToken in insert) {
120 if (insert.hasOwnProperty(newToken)) {
121 ret[newToken] = insert[newToken];
122 }
123 }
124 }
125
126 // Do not insert token which also occur in insert. See #1525
127 if (!insert.hasOwnProperty(token)) {
128 ret[token] = grammar[token];
129 }
130 }
131 }
132
133 var old = root[inside];
134 root[inside] = ret;
135
136 // Update references in other language definitions
137 _.languages.DFS(_.languages, function (key, value) {
138 if (value === old && key != inside) {
139 this[key] = ret;
140 }
141 });
142
143 return ret;
144 },
145
146 // Traverse a language definition with Depth First Search
147 DFS: function (o, callback, type, visited) {
148 visited = visited || {};
149 for (var i in o) {
150 if (o.hasOwnProperty(i)) {
151 callback.call(o, i, o[i], type || i);
152
153 if (_.util.type(o[i]) === 'Object' && !visited[_.util.objId(o[i])]) {
154 visited[_.util.objId(o[i])] = true;
155 _.languages.DFS(o[i], callback, null, visited);
156 }
157 else if (_.util.type(o[i]) === 'Array' && !visited[_.util.objId(o[i])]) {
158 visited[_.util.objId(o[i])] = true;
159 _.languages.DFS(o[i], callback, i, visited);
160 }
161 }
162 }
163 }
164 },
165 plugins: {},
166
167 highlightAll: function (async, callback) {
168 _.highlightAllUnder(document, async, callback);
169 },
170
171 highlightAllUnder: function (container, async, callback) {
172 var env = {
173 callback: callback,
174 selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
175 };
176
177 _.hooks.run("before-highlightall", env);
178
179 var elements = env.elements || container.querySelectorAll(env.selector);
180
181 for (var i = 0, element; element = elements[i++];) {
182 _.highlightElement(element, async === true, env.callback);
183 }
184 },
185
186 highlightElement: function (element, async, callback) {
187 // Find language
188 var language, grammar, parent = element;
189
190 while (parent && !lang.test(parent.className)) {
191 parent = parent.parentNode;
192 }
193
194 if (parent) {
195 language = (parent.className.match(lang) || [, ''])[1].toLowerCase();
196 grammar = _.languages[language];
197 }
198
199 // Set language on the element, if not present
200 element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
201
202 if (element.parentNode) {
203 // Set language on the parent, for styling
204 parent = element.parentNode;
205
206 if (/pre/i.test(parent.nodeName)) {
207 parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
208 }
209 }
210
211 var code = element.textContent;
212
213 var env = {
214 element: element,
215 language: language,
216 grammar: grammar,
217 code: code
218 };
219
220 var insertHighlightedCode = function (highlightedCode) {
221 env.highlightedCode = highlightedCode;
222
223 _.hooks.run('before-insert', env);
224
225 env.element.innerHTML = env.highlightedCode;
226
227 _.hooks.run('after-highlight', env);
228 _.hooks.run('complete', env);
229 callback && callback.call(env.element);
230 }
231
232 _.hooks.run('before-sanity-check', env);
233
234 if (!env.code) {
235 _.hooks.run('complete', env);
236 return;
237 }
238
239 _.hooks.run('before-highlight', env);
240
241 if (!env.grammar) {
242 insertHighlightedCode(_.util.encode(env.code));
243 return;
244 }
245
246 if (async && _self.Worker) {
247 var worker = new Worker(_.filename);
248
249 worker.onmessage = function (evt) {
250 insertHighlightedCode(evt.data);
251 };
252
253 worker.postMessage(JSON.stringify({
254 language: env.language,
255 code: env.code,
256 immediateClose: true
257 }));
258 }
259 else {
260 insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
261 }
262 },
263
264 highlight: function (text, grammar, language) {
265 var env = {
266 code: text,
267 grammar: grammar,
268 language: language
269 };
270 _.hooks.run('before-tokenize', env);
271 env.tokens = _.tokenize(env.code, env.grammar);
272 _.hooks.run('after-tokenize', env);
273 return Token.stringify(_.util.encode(env.tokens), env.language);
274 },
275
276 matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) {
277 var Token = _.Token;
278
279 for (var token in grammar) {
280 if (!grammar.hasOwnProperty(token) || !grammar[token]) {
281 continue;
282 }
283
284 if (token == target) {
285 return;
286 }
287
288 var patterns = grammar[token];
289 patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
290
291 for (var j = 0; j < patterns.length; ++j) {
292 var pattern = patterns[j],
293 inside = pattern.inside,
294 lookbehind = !!pattern.lookbehind,
295 greedy = !!pattern.greedy,
296 lookbehindLength = 0,
297 alias = pattern.alias;
298
299 if (greedy && !pattern.pattern.global) {
300 // Without the global flag, lastIndex won't work
301 var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
302 pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
303 }
304
305 pattern = pattern.pattern || pattern;
306
307 // Don’t cache length as it changes during the loop
308 for (var i = index, pos = startPos; i < strarr.length; pos += strarr[i].length, ++i) {
309
310 var str = strarr[i];
311
312 if (strarr.length > text.length) {
313 // Something went terribly wrong, ABORT, ABORT!
314 return;
315 }
316
317 if (str instanceof Token) {
318 continue;
319 }
320
321 if (greedy && i != strarr.length - 1) {
322 pattern.lastIndex = pos;
323 var match = pattern.exec(text);
324 if (!match) {
325 break;
326 }
327
328 var from = match.index + (lookbehind ? match[1].length : 0),
329 to = match.index + match[0].length,
330 k = i,
331 p = pos;
332
333 for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) {
334 p += strarr[k].length;
335 // Move the index i to the element in strarr that is closest to from
336 if (from >= p) {
337 ++i;
338 pos = p;
339 }
340 }
341
342 // If strarr[i] is a Token, then the match starts inside another Token, which is invalid
343 if (strarr[i] instanceof Token) {
344 continue;
345 }
346
347 // Number of tokens to delete and replace with the new match
348 delNum = k - i;
349 str = text.slice(pos, p);
350 match.index -= pos;
351 } else {
352 pattern.lastIndex = 0;
353
354 var match = pattern.exec(str),
355 delNum = 1;
356 }
357
358 if (!match) {
359 if (oneshot) {
360 break;
361 }
362
363 continue;
364 }
365
366 if (lookbehind) {
367 lookbehindLength = match[1] ? match[1].length : 0;
368 }
369
370 var from = match.index + lookbehindLength,
371 match = match[0].slice(lookbehindLength),
372 to = from + match.length,
373 before = str.slice(0, from),
374 after = str.slice(to);
375
376 var args = [i, delNum];
377
378 if (before) {
379 ++i;
380 pos += before.length;
381 args.push(before);
382 }
383
384 var wrapped = new Token(token, inside ? _.tokenize(match, inside) : match, alias, match, greedy);
385
386 args.push(wrapped);
387
388 if (after) {
389 args.push(after);
390 }
391
392 Array.prototype.splice.apply(strarr, args);
393
394 if (delNum != 1)
395 _.matchGrammar(text, strarr, grammar, i, pos, true, token);
396
397 if (oneshot)
398 break;
399 }
400 }
401 }
402 },
403
404 tokenize: function (text, grammar) {
405 var strarr = [text];
406
407 var rest = grammar.rest;
408
409 if (rest) {
410 for (var token in rest) {
411 grammar[token] = rest[token];
412 }
413
414 delete grammar.rest;
415 }
416
417 _.matchGrammar(text, strarr, grammar, 0, 0, false);
418
419 return strarr;
420 },
421
422 hooks: {
423 all: {},
424
425 add: function (name, callback) {
426 var hooks = _.hooks.all;
427
428 hooks[name] = hooks[name] || [];
429
430 hooks[name].push(callback);
431 },
432
433 run: function (name, env) {
434 var callbacks = _.hooks.all[name];
435
436 if (!callbacks || !callbacks.length) {
437 return;
438 }
439
440 for (var i = 0, callback; callback = callbacks[i++];) {
441 callback(env);
442 }
443 }
444 }
445 };
446
447 var Token = _.Token = function (type, content, alias, matchedStr, greedy) {
448 this.type = type;
449 this.content = content;
450 this.alias = alias;
451 // Copy of the full string this token was created from
452 this.length = (matchedStr || "").length | 0;
453 this.greedy = !!greedy;
454 };
455
456 Token.stringify = function (o, language, parent) {
457 if (typeof o == 'string') {
458 return o;
459 }
460
461 if (_.util.type(o) === 'Array') {
462 return o.map(function (element) {
463 return Token.stringify(element, language, o);
464 }).join('');
465 }
466
467 var env = {
468 type: o.type,
469 content: Token.stringify(o.content, language, parent),
470 tag: 'span',
471 classes: ['token', o.type],
472 attributes: {},
473 language: language,
474 parent: parent
475 };
476
477 if (o.alias) {
478 var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
479 Array.prototype.push.apply(env.classes, aliases);
480 }
481
482 _.hooks.run('wrap', env);
483
484 var attributes = Object.keys(env.attributes).map(function (name) {
485 return name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
486 }).join(' ');
487
488 return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
489
490 };
491
492 if (!_self.document) {
493 if (!_self.addEventListener) {
494 // in Node.js
495 return _self.Prism;
496 }
497
498 if (!_.disableWorkerMessageHandler) {
499 // In worker
500 _self.addEventListener('message', function (evt) {
501 var message = JSON.parse(evt.data),
502 lang = message.language,
503 code = message.code,
504 immediateClose = message.immediateClose;
505
506 _self.postMessage(_.highlight(code, _.languages[lang], lang));
507 if (immediateClose) {
508 _self.close();
509 }
510 }, false);
511 }
512
513 return _self.Prism;
514 }
515
516 //Get current script and highlight
517 var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
518
519 if (script) {
520 _.filename = script.src;
521
522 if (!_.manual && !script.hasAttribute('data-manual')) {
523 if (document.readyState !== "loading") {
524 if (window.requestAnimationFrame) {
525 window.requestAnimationFrame(_.highlightAll);
526 } else {
527 window.setTimeout(_.highlightAll, 16);
528 }
529 }
530 else {
531 document.addEventListener('DOMContentLoaded', _.highlightAll);
532 }
533 }
534 }
535
536 return _self.Prism;
537
538})();
539
540if (typeof module !== 'undefined' && module.exports) {
541 module.exports = Prism;
542}
543
544// hack for components to work correctly in node.js
545if (typeof global !== 'undefined') {
546 global.Prism = Prism;
547}
548
549
550/* **********************************************
551 Begin prism-markup.js
552********************************************** */
553
554Prism.languages.markup = {
555 'comment': /<!--[\s\S]*?-->/,
556 'prolog': /<\?[\s\S]+?\?>/,
557 'doctype': /<!DOCTYPE[\s\S]+?>/i,
558 'cdata': /<!\[CDATA\[[\s\S]*?]]>/i,
559 'tag': {
560 pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i,
561 greedy: true,
562 inside: {
563 'tag': {
564 pattern: /^<\/?[^\s>\/]+/i,
565 inside: {
566 'punctuation': /^<\/?/,
567 'namespace': /^[^\s>\/:]+:/
568 }
569 },
570 'attr-value': {
571 pattern: /=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/i,
572 inside: {
573 'punctuation': [
574 /^=/,
575 {
576 pattern: /(^|[^\\])["']/,
577 lookbehind: true
578 }
579 ]
580 }
581 },
582 'punctuation': /\/?>/,
583 'attr-name': {
584 pattern: /[^\s>\/]+/,
585 inside: {
586 'namespace': /^[^\s>\/:]+:/
587 }
588 }
589
590 }
591 },
592 'entity': /&#?[\da-z]{1,8};/i
593};
594
595Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
596 Prism.languages.markup['entity'];
597
598// Plugin to make entity title show the real entity, idea by Roman Komarov
599Prism.hooks.add('wrap', function (env) {
600
601 if (env.type === 'entity') {
602 env.attributes['title'] = env.content.replace(/&amp;/, '&');
603 }
604});
605
606Prism.languages.xml = Prism.languages.extend('markup', {});
607Prism.languages.html = Prism.languages.markup;
608Prism.languages.mathml = Prism.languages.markup;
609Prism.languages.svg = Prism.languages.markup;
610
611
612/* **********************************************
613 Begin prism-css.js
614********************************************** */
615
616Prism.languages.css = {
617 'comment': /\/\*[\s\S]*?\*\//,
618 'atrule': {
619 pattern: /@[\w-]+?[\s\S]*?(?:;|(?=\s*\{))/i,
620 inside: {
621 'rule': /@[\w-]+/
622 // See rest below
623 }
624 },
625 'url': /url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
626 'selector': /[^{}\s][^{};]*?(?=\s*\{)/,
627 'string': {
628 pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
629 greedy: true
630 },
631 'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i,
632 'important': /!important\b/i,
633 'function': /[-a-z0-9]+(?=\()/i,
634 'punctuation': /[(){};:,]/
635};
636
637Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
638
639if (Prism.languages.markup) {
640 Prism.languages.insertBefore('markup', 'tag', {
641 'style': {
642 pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i,
643 lookbehind: true,
644 inside: Prism.languages.css,
645 alias: 'language-css',
646 greedy: true
647 }
648 });
649
650 Prism.languages.insertBefore('inside', 'attr-value', {
651 'style-attr': {
652 pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i,
653 inside: {
654 'attr-name': {
655 pattern: /^\s*style/i,
656 inside: Prism.languages.markup.tag.inside
657 },
658 'punctuation': /^\s*=\s*['"]|['"]\s*$/,
659 'attr-value': {
660 pattern: /.+/i,
661 inside: Prism.languages.css
662 }
663 },
664 alias: 'language-css'
665 }
666 }, Prism.languages.markup.tag);
667}
668
669
670/* **********************************************
671 Begin prism-clike.js
672********************************************** */
673
674Prism.languages.clike = {
675 'comment': [
676 {
677 pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
678 lookbehind: true
679 },
680 {
681 pattern: /(^|[^\\:])\/\/.*/,
682 lookbehind: true,
683 greedy: true
684 }
685 ],
686 'string': {
687 pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
688 greedy: true
689 },
690 'class-name': {
691 pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i,
692 lookbehind: true,
693 inside: {
694 punctuation: /[.\\]/
695 }
696 },
697 'keyword': /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
698 'boolean': /\b(?:true|false)\b/,
699 'function': /\w+(?=\()/,
700 'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i,
701 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
702 'punctuation': /[{}[\];(),.:]/
703};
704
705
706/* **********************************************
707 Begin prism-javascript.js
708********************************************** */
709
710Prism.languages.javascript = Prism.languages.extend('clike', {
711 'class-name': [
712 Prism.languages.clike['class-name'],
713 {
714 pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/,
715 lookbehind: true
716 }
717 ],
718 'keyword': [
719 {
720 pattern: /((?:^|})\s*)(?:catch|finally)\b/,
721 lookbehind: true
722 },
723 /\b(?:as|async|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/
724 ],
725 'number': /\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/,
726 // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
727 'function': /[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\(|\.(?:apply|bind|call)\()/,
728 'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/
729});
730
731Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/
732
733Prism.languages.insertBefore('javascript', 'keyword', {
734 'regex': {
735 pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/,
736 lookbehind: true,
737 greedy: true
738 },
739 // This must be declared before keyword because we use "function" inside the look-forward
740 'function-variable': {
741 pattern: /[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/,
742 alias: 'function'
743 },
744 'parameter': [
745 {
746 pattern: /(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/,
747 lookbehind: true,
748 inside: Prism.languages.javascript
749 },
750 {
751 pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i,
752 inside: Prism.languages.javascript
753 },
754 {
755 pattern: /(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/,
756 lookbehind: true,
757 inside: Prism.languages.javascript
758 },
759 {
760 pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/,
761 lookbehind: true,
762 inside: Prism.languages.javascript
763 }
764 ],
765 'constant': /\b[A-Z][A-Z\d_]*\b/
766});
767
768Prism.languages.insertBefore('javascript', 'string', {
769 'template-string': {
770 pattern: /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/,
771 greedy: true,
772 inside: {
773 'interpolation': {
774 pattern: /\${[^}]+}/,
775 inside: {
776 'interpolation-punctuation': {
777 pattern: /^\${|}$/,
778 alias: 'punctuation'
779 },
780 rest: Prism.languages.javascript
781 }
782 },
783 'string': /[\s\S]+/
784 }
785 }
786});
787
788if (Prism.languages.markup) {
789 Prism.languages.insertBefore('markup', 'tag', {
790 'script': {
791 pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i,
792 lookbehind: true,
793 inside: Prism.languages.javascript,
794 alias: 'language-javascript',
795 greedy: true
796 }
797 });
798}
799
800Prism.languages.js = Prism.languages.javascript;
801
802
803/* **********************************************
804 Begin prism-file-highlight.js
805********************************************** */
806
807(function () {
808 if (typeof self === 'undefined' || !self.Prism || !self.document || !document.querySelector) {
809 return;
810 }
811
812 /**
813 * @param {Element} [container=document]
814 */
815 self.Prism.fileHighlight = function (container) {
816 container = container || document;
817
818 var Extensions = {
819 'js': 'javascript',
820 'py': 'python',
821 'rb': 'ruby',
822 'ps1': 'powershell',
823 'psm1': 'powershell',
824 'sh': 'bash',
825 'bat': 'batch',
826 'h': 'c',
827 'tex': 'latex'
828 };
829
830 Array.prototype.slice.call(container.querySelectorAll('pre[data-src]')).forEach(function (pre) {
831 // ignore if already loaded
832 if (pre.hasAttribute('data-src-loaded')) {
833 return;
834 }
835
836 // load current
837 var src = pre.getAttribute('data-src');
838
839 var language, parent = pre;
840 var lang = /\blang(?:uage)?-([\w-]+)\b/i;
841 while (parent && !lang.test(parent.className)) {
842 parent = parent.parentNode;
843 }
844
845 if (parent) {
846 language = (pre.className.match(lang) || [, ''])[1];
847 }
848
849 if (!language) {
850 var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
851 language = Extensions[extension] || extension;
852 }
853
854 var code = document.createElement('code');
855 code.className = 'language-' + language;
856
857 pre.textContent = '';
858
859 code.textContent = 'Loading…';
860
861 pre.appendChild(code);
862
863 var xhr = new XMLHttpRequest();
864
865 xhr.open('GET', src, true);
866
867 xhr.onreadystatechange = function () {
868 if (xhr.readyState == 4) {
869
870 if (xhr.status < 400 && xhr.responseText) {
871 code.textContent = xhr.responseText;
872
873 Prism.highlightElement(code);
874 // mark as loaded
875 pre.setAttribute('data-src-loaded', '');
876 }
877 else if (xhr.status >= 400) {
878 code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
879 }
880 else {
881 code.textContent = '✖ Error: File does not exist or is empty';
882 }
883 }
884 };
885
886 xhr.send(null);
887 });
888
889 if (Prism.plugins.toolbar) {
890 Prism.plugins.toolbar.registerButton('download-file', function (env) {
891 var pre = env.element.parentNode;
892 if (!pre || !/pre/i.test(pre.nodeName) || !pre.hasAttribute('data-src') || !pre.hasAttribute('data-download-link')) {
893 return;
894 }
895 var src = pre.getAttribute('data-src');
896 var a = document.createElement('a');
897 a.textContent = pre.getAttribute('data-download-link-label') || 'Download';
898 a.setAttribute('download', '');
899 a.href = src;
900 return a;
901 });
902 }
903
904 };
905
906 document.addEventListener('DOMContentLoaded', function () {
907 // execute inside handler, for dropping Event as argumnet
908 self.Prism.fileHighlight();
909 });
910
911})();
912
913(function () {
914
915 if (typeof self === 'undefined' || !self.Prism || !self.document) {
916 return;
917 }
918
919 /**
920 * Plugin name which is used as a class name for <pre> which is activating the plugin
921 * @type {String}
922 */
923 var PLUGIN_NAME = 'line-numbers';
924
925 /**
926 * Regular expression used for determining line breaks
927 * @type {RegExp}
928 */
929 var NEW_LINE_EXP = /\n(?!$)/g;
930
931 /**
932 * Resizes line numbers spans according to height of line of code
933 * @param {Element} element <pre> element
934 */
935 var _resizeElement = function (element) {
936 var codeStyles = getStyles(element);
937 var whiteSpace = codeStyles['white-space'];
938
939 if (whiteSpace === 'pre-wrap' || whiteSpace === 'pre-line') {
940 var codeElement = element.querySelector('code');
941 var lineNumbersWrapper = element.querySelector('.line-numbers-rows');
942 var lineNumberSizer = element.querySelector('.line-numbers-sizer');
943 var codeLines = codeElement.textContent.split(NEW_LINE_EXP);
944
945 if (!lineNumberSizer) {
946 lineNumberSizer = document.createElement('span');
947 lineNumberSizer.className = 'line-numbers-sizer';
948
949 codeElement.appendChild(lineNumberSizer);
950 }
951
952 lineNumberSizer.style.display = 'block';
953
954 codeLines.forEach(function (line, lineNumber) {
955 lineNumberSizer.textContent = line || '\n';
956 var lineSize = lineNumberSizer.getBoundingClientRect().height;
957 lineNumbersWrapper.children[lineNumber].style.height = lineSize + 'px';
958 });
959
960 lineNumberSizer.textContent = '';
961 lineNumberSizer.style.display = 'none';
962 }
963 };
964
965 /**
966 * Returns style declarations for the element
967 * @param {Element} element
968 */
969 var getStyles = function (element) {
970 if (!element) {
971 return null;
972 }
973
974 return window.getComputedStyle ? getComputedStyle(element) : (element.currentStyle || null);
975 };
976
977 window.addEventListener('resize', function () {
978 Array.prototype.forEach.call(document.querySelectorAll('pre.' + PLUGIN_NAME), _resizeElement);
979 });
980
981 Prism.hooks.add('complete', function (env) {
982 if (!env.code) {
983 return;
984 }
985
986 // works only for <code> wrapped inside <pre> (not inline)
987 var pre = env.element.parentNode;
988 var clsReg = /\s*\bline-numbers\b\s*/;
989 if (
990 !pre || !/pre/i.test(pre.nodeName) ||
991 // Abort only if nor the <pre> nor the <code> have the class
992 (!clsReg.test(pre.className) && !clsReg.test(env.element.className))
993 ) {
994 return;
995 }
996
997 if (env.element.querySelector('.line-numbers-rows')) {
998 // Abort if line numbers already exists
999 return;
1000 }
1001
1002 if (clsReg.test(env.element.className)) {
1003 // Remove the class 'line-numbers' from the <code>
1004 env.element.className = env.element.className.replace(clsReg, ' ');
1005 }
1006 if (!clsReg.test(pre.className)) {
1007 // Add the class 'line-numbers' to the <pre>
1008 pre.className += ' line-numbers';
1009 }
1010
1011 var match = env.code.match(NEW_LINE_EXP);
1012 var linesNum = match ? match.length + 1 : 1;
1013 var lineNumbersWrapper;
1014
1015 var lines = new Array(linesNum + 1);
1016 lines = lines.join('<span></span>');
1017
1018 lineNumbersWrapper = document.createElement('span');
1019 lineNumbersWrapper.setAttribute('aria-hidden', 'true');
1020 lineNumbersWrapper.className = 'line-numbers-rows';
1021 lineNumbersWrapper.innerHTML = lines;
1022
1023 if (pre.hasAttribute('data-start')) {
1024 pre.style.counterReset = 'linenumber ' + (parseInt(pre.getAttribute('data-start'), 10) - 1);
1025 }
1026
1027 env.element.appendChild(lineNumbersWrapper);
1028
1029 _resizeElement(pre);
1030
1031 Prism.hooks.run('line-numbers', env);
1032 });
1033
1034 Prism.hooks.add('line-numbers', function (env) {
1035 env.plugins = env.plugins || {};
1036 env.plugins.lineNumbers = true;
1037 });
1038
1039 /**
1040 * Global exports
1041 */
1042 Prism.plugins.lineNumbers = {
1043 /**
1044 * Get node for provided line number
1045 * @param {Element} element pre element
1046 * @param {Number} number line number
1047 * @return {Element|undefined}
1048 */
1049 getLine: function (element, number) {
1050 if (element.tagName !== 'PRE' || !element.classList.contains(PLUGIN_NAME)) {
1051 return;
1052 }
1053
1054 var lineNumberRows = element.querySelector('.line-numbers-rows');
1055 var lineNumberStart = parseInt(element.getAttribute('data-start'), 10) || 1;
1056 var lineNumberEnd = lineNumberStart + (lineNumberRows.children.length - 1);
1057
1058 if (number < lineNumberStart) {
1059 number = lineNumberStart;
1060 }
1061 if (number > lineNumberEnd) {
1062 number = lineNumberEnd;
1063 }
1064
1065 var lineIndex = number - lineNumberStart;
1066
1067 return lineNumberRows.children[lineIndex];
1068 }
1069 };
1070
1071}());