diff --git a/AUTHORS.rst b/AUTHORS.rst index 9d445427..a066f5a4 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -31,3 +31,4 @@ Patches and ideas * `Justin Bonnar `_ * `Nathan LaFreniere `_ * `Matthias Lehmann `_ +* `Dennis Brakhane `_ diff --git a/httpie/output/formatters/colors.py b/httpie/output/formatters/colors.py index d9276d6f..667ae91a 100644 --- a/httpie/output/formatters/colors.py +++ b/httpie/output/formatters/colors.py @@ -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: diff --git a/tests/test_output.py b/tests/test_output.py index ad2dec04..b4e2db3d 100644 --- a/tests/test_output.py +++ b/tests/test_output.py @@ -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)