diff options
author | gbrandl <devnull@localhost> | 2006-12-14 16:41:37 +0100 |
---|---|---|
committer | gbrandl <devnull@localhost> | 2006-12-14 16:41:37 +0100 |
commit | c93caf9dec4ccdf4db2bb749bdc41f94a944b46c (patch) | |
tree | bd0aad2e7a5ccdcab1a8c855a96b89dbc98773e7 | |
parent | 3dc0ab0d122cdc3b29a714d01611f3d9b4ede311 (diff) | |
download | pygments-c93caf9dec4ccdf4db2bb749bdc41f94a944b46c.tar.gz |
[svn] Add ApacheConf lexer by Tim Hatch.
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | docs/src/lexers.txt | 18 | ||||
-rw-r--r-- | pygments/lexers/_mapping.py | 1 | ||||
-rw-r--r-- | pygments/lexers/text.py | 40 |
4 files changed, 59 insertions, 2 deletions
@@ -5,6 +5,8 @@ Version 0.6 ----------- (released Dec XX, 2006) +- Added Apache configuration lexer (thanks to Tim Hatch). + - Improved guessing methods for various lexers. - Added `@media` support to CSS lexer (thanks to Tim Hatch). diff --git a/docs/src/lexers.txt b/docs/src/lexers.txt index ebc061cc..eb2edc4a 100644 --- a/docs/src/lexers.txt +++ b/docs/src/lexers.txt @@ -629,6 +629,24 @@ Text lexers :Filename patterns: ``*.tex``, ``*.aux``, ``*.toc`` +`GroffLexer` + + Lexer for the (g)roff typesetting language, supporting groff + extensions. Mainly useful for highlighting manpage sources. + + :Aliases: ``groff``, ``nroff``, ``man`` + :Filename patterns: ``*.[1234567]``, ``*.man`` + + +`ApacheConfLexer` + + Lexer for configuration files following the Apache config file + format. + + :Aliases: ``apacheconf``, ``aconf`` + :Filename patterns: None + + Iterating over all lexers ========================= diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index 86bb3976..a81ea0c8 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -14,6 +14,7 @@ """ LEXERS = { + 'ApacheConfLexer': ('pygments.lexers.text', 'ApacheConf', ('apacheconf', 'aconf'), (), ()), 'BooLexer': ('pygments.lexers.dotnet', 'Boo', ('boo',), ('*.boo',), ('text/x-boo',)), 'BrainfuckLexer': ('pygments.lexers.other', 'Brainfuck', ('brainfuck', 'bf'), ('*.bf', '*.b'), ()), 'CLexer': ('pygments.lexers.compiled', 'C', ('c',), ('*.c', '*.h'), ('text/x-chdr', 'text/x-csrc')), 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'), + ], + } |