From 14d194fcdd43466e41cebceec764ad928d31ab3d Mon Sep 17 00:00:00 2001 From: blackbird Date: Wed, 20 Dec 2006 15:40:27 +0100 Subject: [svn] added examplefile for apache lexer and improved it --- pygments/lexers/_mapping.py | 2 +- pygments/lexers/text.py | 45 +++++++++++++++++++++------------------------ 2 files changed, 22 insertions(+), 25 deletions(-) (limited to 'pygments/lexers') 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*)(', 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) + ] } -- cgit v1.2.1