Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c66df17

Browse files
author
Gabriel Corona
committed
HttpLexer: recognize HTTP responses as well
1 parent 5b10273 commit c66df17

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pygments/lexers/textfmts.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,13 @@ def content_callback(self, match):
194194
}
195195

196196
def analyse_text(text):
197-
return re.search(r'^([a-zA-Z][-_a-zA-Z]+)( +)([^ ]+)( +)'
198-
r'(HTTP)(/)(1\.[01]|2(?:\.0)?|3)(\r?\n|\Z)', text) is not None
197+
return any (
198+
re.search(pattern, text) is not None
199+
for pattern in (
200+
r'^([a-zA-Z][-_a-zA-Z]+)( +)([^ ]+)( +)(HTTP)(/)(1\.[01]|2(?:\.0)?|3)(\r?\n|\Z)',
201+
r'^(HTTP)(/)(1\.[01]|2(?:\.0)?|3)( +)(\d{3})(?:( +)([^\r\n]*))?(\r?\n|\Z)',
202+
)
203+
)
199204

200205

201206
class TodotxtLexer(RegexLexer):

0 commit comments

Comments
 (0)