]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/apache.js
Initial commit.
[flow-web.git] / static / highlight / languages / apache.js
1 /*! `apache` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: Apache config
8 Author: Ruslan Keba <rukeba@gmail.com>
9 Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>
10 Website: https://httpd.apache.org
11 Description: language definition for Apache configuration files (httpd.conf & .htaccess)
12 Category: config, web
13 Audit: 2020
14 */
15
16 /** @type LanguageFn */
17 function apache(hljs) {
18 const NUMBER_REF = {
19 className: 'number',
20 begin: /[$%]\d+/
21 };
22 const NUMBER = {
23 className: 'number',
24 begin: /\b\d+/
25 };
26 const IP_ADDRESS = {
27 className: "number",
28 begin: /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d{1,5})?/
29 };
30 const PORT_NUMBER = {
31 className: "number",
32 begin: /:\d{1,5}/
33 };
34 return {
35 name: 'Apache config',
36 aliases: [ 'apacheconf' ],
37 case_insensitive: true,
38 contains: [
39 hljs.HASH_COMMENT_MODE,
40 {
41 className: 'section',
42 begin: /<\/?/,
43 end: />/,
44 contains: [
45 IP_ADDRESS,
46 PORT_NUMBER,
47 // low relevance prevents us from claming XML/HTML where this rule would
48 // match strings inside of XML tags
49 hljs.inherit(hljs.QUOTE_STRING_MODE, { relevance: 0 })
50 ]
51 },
52 {
53 className: 'attribute',
54 begin: /\w+/,
55 relevance: 0,
56 // keywords aren’t needed for highlighting per se, they only boost relevance
57 // for a very generally defined mode (starts with a word, ends with line-end
58 keywords: { _: [
59 "order",
60 "deny",
61 "allow",
62 "setenv",
63 "rewriterule",
64 "rewriteengine",
65 "rewritecond",
66 "documentroot",
67 "sethandler",
68 "errordocument",
69 "loadmodule",
70 "options",
71 "header",
72 "listen",
73 "serverroot",
74 "servername"
75 ] },
76 starts: {
77 end: /$/,
78 relevance: 0,
79 keywords: { literal: 'on off all deny allow' },
80 contains: [
81 {
82 scope: "punctuation",
83 match: /\\\n/
84 },
85 {
86 className: 'meta',
87 begin: /\s\[/,
88 end: /\]$/
89 },
90 {
91 className: 'variable',
92 begin: /[\$%]\{/,
93 end: /\}/,
94 contains: [
95 'self',
96 NUMBER_REF
97 ]
98 },
99 IP_ADDRESS,
100 NUMBER,
101 hljs.QUOTE_STRING_MODE
102 ]
103 }
104 }
105 ],
106 illegal: /\S/
107 };
108 }
109
110 return apache;
111
112 })();
113
114 hljs.registerLanguage('apache', hljsGrammar);
115 })();