From e0d73d246ce9a1712c8acec2c0592282fb3ffca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sun, 1 Aug 2021 23:26:09 +0300 Subject: [PATCH 1/2] Recognize JSON and XML by media type suffixes --- http-request-response.sublime-syntax | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/http-request-response.sublime-syntax b/http-request-response.sublime-syntax index aefc4d0..c446962 100644 --- a/http-request-response.sublime-syntax +++ b/http-request-response.sublime-syntax @@ -113,12 +113,12 @@ contexts: content-type: - meta_content_scope: meta.headers.http-request-response - - match: (application/json|text/json){{content_type_sep}} + - match: (application/json|text/json|[\w.-]+/[\w.-]+\+json){{content_type_sep}} set: [content-type-json, header-value] - - match: (application/xml|text/xml){{content_type_sep}} - set: [content-type-xml, header-value] - match: (application/xhtml\+xml|text/html){{content_type_sep}} set: [content-type-html, header-value] + - match: (application/xml|text/xml|[\w.-]+/[\w.-]+\+xml){{content_type_sep}} + set: [content-type-xml, header-value] - match: (application/x-www-form-urlencoded){{content_type_sep}} set: [content-type-querystring, header-value] - match: (multipart/form-data){{content_type_sep}} From 64427bf942a751d2f904972d954c916561e9463d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Tue, 3 Aug 2021 00:16:30 +0300 Subject: [PATCH 2/2] Extract media type suffix prefix into a variable --- http-request-response.sublime-syntax | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/http-request-response.sublime-syntax b/http-request-response.sublime-syntax index c446962..e50f3e6 100644 --- a/http-request-response.sublime-syntax +++ b/http-request-response.sublime-syntax @@ -20,6 +20,7 @@ variables: http_version: (?:\bHTTP/\d(?:\.\d)?\b) end_of_body: (?=^{{http_version}}[ ]\d{3}) end_of_headers: (?:^$\n) + media_type_suffix_prefix: (?:[\w.-]+/[\w.-]+) contexts: prototype: - match: '^##' @@ -113,11 +114,11 @@ contexts: content-type: - meta_content_scope: meta.headers.http-request-response - - match: (application/json|text/json|[\w.-]+/[\w.-]+\+json){{content_type_sep}} + - match: (application/json|text/json|{{media_type_suffix_prefix}}\+json){{content_type_sep}} set: [content-type-json, header-value] - match: (application/xhtml\+xml|text/html){{content_type_sep}} set: [content-type-html, header-value] - - match: (application/xml|text/xml|[\w.-]+/[\w.-]+\+xml){{content_type_sep}} + - match: (application/xml|text/xml|{{media_type_suffix_prefix}}\+xml){{content_type_sep}} set: [content-type-xml, header-value] - match: (application/x-www-form-urlencoded){{content_type_sep}} set: [content-type-querystring, header-value]