mirror of
https://github.com/httpie/cli.git
synced 2024-12-29 09:49:10 +01:00
Merge pull request #260 from brakhane/master
Fallback to JSON highlighting if subtype contains json
This commit is contained in:
commit
43f7b84a1e
@ -31,3 +31,4 @@ Patches and ideas
|
||||
* `Justin Bonnar <https://github.com/jargonjustin>`_
|
||||
* `Nathan LaFreniere <https://github.com/nlf>`_
|
||||
* `Matthias Lehmann <https://github.com/matleh>`_
|
||||
* `Dennis Brakhane <https://github.com/brakhane>`_
|
||||
|
@ -76,6 +76,10 @@ def get_lexer(mime):
|
||||
'%s/%s' % (type_, subtype_name),
|
||||
'%s/%s' % (type_, subtype_suffix)
|
||||
])
|
||||
# as a last resort, if no lexer feels responsible, and
|
||||
# the subtype contains 'json', take the JSON lexer
|
||||
if 'json' in subtype:
|
||||
lexer_names.append('json')
|
||||
lexer = None
|
||||
for mime_type in mime_types:
|
||||
try:
|
||||
|
@ -32,9 +32,13 @@ class TestColors:
|
||||
'application/json',
|
||||
'application/json+foo',
|
||||
'application/foo+json',
|
||||
'application/json-foo',
|
||||
'application/x-json',
|
||||
'foo/json',
|
||||
'foo/json+bar',
|
||||
'foo/bar+json',
|
||||
'foo/json-foo',
|
||||
'foo/x-json',
|
||||
])
|
||||
def test_get_lexer(self, mime):
|
||||
lexer = get_lexer(mime)
|
||||
|
Loading…
Reference in New Issue
Block a user