summaryrefslogtreecommitdiff
path: root/pygments/lexers
diff options
context:
space:
mode:
authorblackbird <devnull@localhost>2006-12-20 15:40:27 +0100
committerblackbird <devnull@localhost>2006-12-20 15:40:27 +0100
commit14d194fcdd43466e41cebceec764ad928d31ab3d (patch)
tree9cdaaeb9f0a1656a807a2fafeb77e9794ea0d03f /pygments/lexers
parentbbed4bdf100fc75e5ac31fa10976bff23e84bd7c (diff)
downloadpygments-14d194fcdd43466e41cebceec764ad928d31ab3d.tar.gz
[svn] added examplefile for apache lexer and improved it
Diffstat (limited to 'pygments/lexers')
-rw-r--r--pygments/lexers/_mapping.py2
-rw-r--r--pygments/lexers/text.py45
2 files changed, 22 insertions, 25 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py
index fb944275..0688ef11 100644
--- a/pygments/lexers/_mapping.py
+++ b/pygments/lexers/_mapping.py
@@ -14,7 +14,7 @@
"""
LEXERS = {
- 'ApacheConfLexer': ('pygments.lexers.text', 'ApacheConf', ('apacheconf', 'aconf'), ('.htaccess', 'apache.conf'), ()),
+ 'ApacheConfLexer': ('pygments.lexers.text', 'ApacheConf', ('apacheconf', 'aconf', 'apache'), ('.htaccess', 'apache.conf', 'apache2.conf'), ()),
'BBCodeLexer': ('pygments.lexers.text', 'BBCode', ('bbcode',), (), ()),
'BashLexer': ('pygments.lexers.other', 'Bash', ('bash', 'sh'), ('*.sh',), ('application/x-sh', 'application/x-shellscript')),
'BooLexer': ('pygments.lexers.dotnet', 'Boo', ('boo',), ('*.boo',), ('text/x-boo',)),
diff --git a/pygments/lexers/text.py b/pygments/lexers/text.py
index 6d39bdfe..b8388dc4 100644
--- a/pygments/lexers/text.py
+++ b/pygments/lexers/text.py
@@ -274,38 +274,35 @@ class GroffLexer(RegexLexer):
if text[1:3].isalnum() and text[3].isspace():
return 0.9
+
class ApacheConfLexer(RegexLexer):
"""
Lex Apache configuration like files.
"""
name = 'ApacheConf'
- aliases = ['apacheconf', 'aconf']
- filenames = ['.htaccess', 'apache.conf']
+ aliases = ['apacheconf', 'aconf', 'apache']
+ filenames = ['.htaccess', 'apache.conf', 'apache2.conf']
+ flags = re.MULTILINE | re.IGNORECASE
tokens = {
'root': [
- (r'(\s*)(#.*)',
- bygroups(Text, Comment)),
- (r'^(\s*)(</?\w+)',
- bygroups(Text, Name.Tag), 'section'),
- (r'^(\s*)(\w+)(\s+)',
- bygroups(Text, Name.Attribute, Text),
- 'value'),
- (r'[^<\n]+', Text),
- ],
- 'datatypes': [
- (r'\d+\b', Number),
- (r'"(\\\\|\\"|[^"\n])*"', String.Double),
- (r'\S+\b', String.Symbol),
- (r'[ \t]+', Text),
- (r'[^\n]+', String),
- ],
- 'section': [
- (r'>', Name.Tag, '#pop'),
- include('datatypes'),
+ (r'^(\s*)(#.*?)$', bygroups(Text, Comment)),
+ (r'\s+', Text),
+ (r'(<[^\s>]+)(?:(\s+)(.*?))?(>)',
+ bygroups(Name.Tag, Text, String, Name.Tag)),
+ (r'([a-zA-Z][a-zA-Z0-9]*)(\s+)',
+ bygroups(Name.Builtin, Text), 'value')
],
'value': [
- include('datatypes'),
- (r'\n', Text, '#pop'),
- ],
+ (r'$', Text, '#pop'),
+ (r'\s', Text), # XXX: \s+ does not work with examplefile
+ (r'\d+', Number),
+ (r'/([a-zA-Z0-9][a-zA-Z0-9_./-]+)', String.Other),
+ (r'(on|off|none|any|all|double|email|dns|min|minimal|'
+ r'os|productonly|full|emerg|alert|crit|error|warn|'
+ r'notice|info|debug|registry|script|inetd|standalone|'
+ r'user|group)\b', Keyword),
+ (r'"([^"\\]*(?:\\.[^"\\]*)*)"', String.Double),
+ (r'[^\s"]+', Text)
+ ]
}