summaryrefslogtreecommitdiff
path: root/pygments/lexers/text.py
diff options
context:
space:
mode:
authorgbrandl <devnull@localhost>2006-12-14 16:41:37 +0100
committergbrandl <devnull@localhost>2006-12-14 16:41:37 +0100
commitc93caf9dec4ccdf4db2bb749bdc41f94a944b46c (patch)
treebd0aad2e7a5ccdcab1a8c855a96b89dbc98773e7 /pygments/lexers/text.py
parent3dc0ab0d122cdc3b29a714d01611f3d9b4ede311 (diff)
downloadpygments-c93caf9dec4ccdf4db2bb749bdc41f94a944b46c.tar.gz
[svn] Add ApacheConf lexer by Tim Hatch.
Diffstat (limited to 'pygments/lexers/text.py')
-rw-r--r--pygments/lexers/text.py40
1 files changed, 38 insertions, 2 deletions
diff --git a/pygments/lexers/text.py b/pygments/lexers/text.py
index 8e9a2f13..b67a82fd 100644
--- a/pygments/lexers/text.py
+++ b/pygments/lexers/text.py
@@ -18,7 +18,7 @@ from pygments.token import \
__all__ = ['IniLexer', 'MakefileLexer', 'DiffLexer', 'IrcLogsLexer',
- 'TexLexer', 'GroffLexer']
+ 'TexLexer', 'GroffLexer', 'ApacheConfLexer']
class IniLexer(RegexLexer):
@@ -29,7 +29,7 @@ class IniLexer(RegexLexer):
tokens = {
'root': [
(r'\s+', Text),
- (r';.*?$', Comment),
+ (r'[;#].*?$', Comment),
(r'\[.*?\]$', Keyword),
(r'(.*?)(\s*)(=)(\s*)(.*?)$',
bygroups(Name.Attribute, Text, Operator, Text, String))
@@ -257,3 +257,39 @@ class GroffLexer(RegexLexer):
return True
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 = []
+
+ 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'),
+ ],
+ 'value': [
+ include('datatypes'),
+ (r'\n', Text, '#pop'),
+ ],
+ }