source: node_modules/highlight.js/lib/languages/apache.js@ d24f17c

main
Last change on this file since d24f17c 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/*
2Language: Apache config
3Author: Ruslan Keba <rukeba@gmail.com>
4Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>
5Website: https://httpd.apache.org
6Description: language definition for Apache configuration files (httpd.conf & .htaccess)
7Category: common, config
8Audit: 2020
9*/
10
11/** @type LanguageFn */
12function 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
89module.exports = apache;
Note: See TracBrowser for help on using the repository browser.