main
Last change
on this file since e48199a was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
2.3 KB
|
Line | |
---|
1 | /*
|
---|
2 | Language: Apache config
|
---|
3 | Author: Ruslan Keba <rukeba@gmail.com>
|
---|
4 | Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>
|
---|
5 | Website: https://httpd.apache.org
|
---|
6 | Description: language definition for Apache configuration files (httpd.conf & .htaccess)
|
---|
7 | Category: common, config
|
---|
8 | Audit: 2020
|
---|
9 | */
|
---|
10 |
|
---|
11 | /** @type LanguageFn */
|
---|
12 | function apache(hljs) {
|
---|
13 | const NUMBER_REF = {
|
---|
14 | className: 'number',
|
---|
15 | begin: /[$%]\d+/
|
---|
16 | };
|
---|
17 | const NUMBER = {
|
---|
18 | className: 'number',
|
---|
19 | begin: /\d+/
|
---|
20 | };
|
---|
21 | const IP_ADDRESS = {
|
---|
22 | className: "number",
|
---|
23 | begin: /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d{1,5})?/
|
---|
24 | };
|
---|
25 | const PORT_NUMBER = {
|
---|
26 | className: "number",
|
---|
27 | begin: /:\d{1,5}/
|
---|
28 | };
|
---|
29 | return {
|
---|
30 | name: 'Apache config',
|
---|
31 | aliases: [ 'apacheconf' ],
|
---|
32 | case_insensitive: true,
|
---|
33 | contains: [
|
---|
34 | hljs.HASH_COMMENT_MODE,
|
---|
35 | {
|
---|
36 | className: 'section',
|
---|
37 | begin: /<\/?/,
|
---|
38 | end: />/,
|
---|
39 | contains: [
|
---|
40 | IP_ADDRESS,
|
---|
41 | PORT_NUMBER,
|
---|
42 | // low relevance prevents us from claming XML/HTML where this rule would
|
---|
43 | // match strings inside of XML tags
|
---|
44 | hljs.inherit(hljs.QUOTE_STRING_MODE, { relevance: 0 })
|
---|
45 | ]
|
---|
46 | },
|
---|
47 | {
|
---|
48 | className: 'attribute',
|
---|
49 | begin: /\w+/,
|
---|
50 | relevance: 0,
|
---|
51 | // keywords aren’t needed for highlighting per se, they only boost relevance
|
---|
52 | // for a very generally defined mode (starts with a word, ends with line-end
|
---|
53 | keywords: {
|
---|
54 | nomarkup:
|
---|
55 | 'order deny allow setenv rewriterule rewriteengine rewritecond documentroot ' +
|
---|
56 | 'sethandler errordocument loadmodule options header listen serverroot ' +
|
---|
57 | 'servername'
|
---|
58 | },
|
---|
59 | starts: {
|
---|
60 | end: /$/,
|
---|
61 | relevance: 0,
|
---|
62 | keywords: { literal: 'on off all deny allow' },
|
---|
63 | contains: [
|
---|
64 | {
|
---|
65 | className: 'meta',
|
---|
66 | begin: /\s\[/,
|
---|
67 | end: /\]$/
|
---|
68 | },
|
---|
69 | {
|
---|
70 | className: 'variable',
|
---|
71 | begin: /[\$%]\{/,
|
---|
72 | end: /\}/,
|
---|
73 | contains: [
|
---|
74 | 'self',
|
---|
75 | NUMBER_REF
|
---|
76 | ]
|
---|
77 | },
|
---|
78 | IP_ADDRESS,
|
---|
79 | NUMBER,
|
---|
80 | hljs.QUOTE_STRING_MODE
|
---|
81 | ]
|
---|
82 | }
|
---|
83 | }
|
---|
84 | ],
|
---|
85 | illegal: /\S/
|
---|
86 | };
|
---|
87 | }
|
---|
88 |
|
---|
89 | module.exports = apache;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.