l0bsterssg

node.js static responsive blog post generator
Log | Files | Refs | README

apache.js (2190B)


      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 */
      9 
     10 /** @type LanguageFn */
     11 function apache(hljs) {
     12   var NUMBER_REF = {className: 'number', begin: '[\\$%]\\d+'};
     13   var NUMBER = {className: 'number', begin: '\\d+'};
     14   var IP_ADDRESS = {
     15     className: "number",
     16     begin: '\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?'
     17   };
     18   var PORT_NUMBER = {
     19     className: "number",
     20     begin: ":\\d{1,5}"
     21   };
     22   return {
     23     name: 'Apache config',
     24     aliases: ['apacheconf'],
     25     case_insensitive: true,
     26     contains: [
     27       hljs.HASH_COMMENT_MODE,
     28       {className: 'section', begin: '</?', end: '>',
     29       contains: [
     30         IP_ADDRESS,
     31         PORT_NUMBER,
     32         // low relevance prevents us from claming XML/HTML where this rule would
     33         // match strings inside of XML tags
     34         hljs.inherit(hljs.QUOTE_STRING_MODE, { relevance:0 })
     35       ]
     36     },
     37       {
     38         className: 'attribute',
     39         begin: /\w+/,
     40         relevance: 0,
     41         // keywords aren’t needed for highlighting per se, they only boost relevance
     42         // for a very generally defined mode (starts with a word, ends with line-end
     43         keywords: {
     44           nomarkup:
     45             'order deny allow setenv rewriterule rewriteengine rewritecond documentroot ' +
     46             'sethandler errordocument loadmodule options header listen serverroot ' +
     47             'servername'
     48         },
     49         starts: {
     50           end: /$/,
     51           relevance: 0,
     52           keywords: {
     53             literal: 'on off all deny allow'
     54           },
     55           contains: [
     56             {
     57               className: 'meta',
     58               begin: '\\s\\[', end: '\\]$'
     59             },
     60             {
     61               className: 'variable',
     62               begin: '[\\$%]\\{', end: '\\}',
     63               contains: ['self', NUMBER_REF]
     64             },
     65             IP_ADDRESS,
     66             NUMBER,
     67             hljs.QUOTE_STRING_MODE
     68           ]
     69         }
     70       }
     71     ],
     72     illegal: /\S/
     73   };
     74 }
     75 
     76 module.exports = apache;