You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
/*
Language: Apache config
Author: Ruslan Keba <rukeba@gmail.com>
Contributors: Ivan Sagalaev <maniac@softwaremaniacs.org>
Website: https://httpd.apache.org
Description: language definition for Apache configuration files (httpd.conf & .htaccess)
Category: common, config
Audit: 2020
*/
/** @type LanguageFn */
function apache ( hljs ) {
const NUMBER _REF = {
className : 'number' ,
begin : /[$%]\d+/
} ;
const NUMBER = {
className : 'number' ,
begin : /\d+/
} ;
const IP _ADDRESS = {
className : "number" ,
begin : /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d{1,5})?/
} ;
const PORT _NUMBER = {
className : "number" ,
begin : /:\d{1,5}/
} ;
return {
name : 'Apache config' ,
aliases : [ 'apacheconf' ] ,
case _insensitive : true ,
contains : [
hljs . HASH _COMMENT _MODE ,
{
className : 'section' ,
begin : /<\/?/ ,
end : />/ ,
contains : [
IP _ADDRESS ,
PORT _NUMBER ,
// low relevance prevents us from claming XML/HTML where this rule would
// match strings inside of XML tags
hljs . inherit ( hljs . QUOTE _STRING _MODE , { relevance : 0 } )
]
} ,
{
className : 'attribute' ,
begin : /\w+/ ,
relevance : 0 ,
// keywords aren’ t needed for highlighting per se, they only boost relevance
// for a very generally defined mode (starts with a word, ends with line-end
keywords : {
nomarkup :
'order deny allow setenv rewriterule rewriteengine rewritecond documentroot ' +
'sethandler errordocument loadmodule options header listen serverroot ' +
'servername'
} ,
starts : {
end : /$/ ,
relevance : 0 ,
keywords : { literal : 'on off all deny allow' } ,
contains : [
{
className : 'meta' ,
begin : /\s\[/ ,
end : /\]$/
} ,
{
className : 'variable' ,
begin : /[\$%]\{/ ,
end : /\}/ ,
contains : [
'self' ,
NUMBER _REF
]
} ,
IP _ADDRESS ,
NUMBER ,
hljs . QUOTE _STRING _MODE
]
}
}
] ,
illegal : /\S/
} ;
}
module . exports = apache ;