Skip to content

Commit 1dfc827

Browse files
HTTP: Fixed body not being highlighted (#2734)
1 parent ccc73ab commit 1dfc827

File tree

5 files changed

+311
-2
lines changed

5 files changed

+311
-2
lines changed

components/prism-http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090

9191
var pattern = suffixTypes[contentType] ? getSuffixPattern(contentType) : contentType;
9292
options[contentType.replace(/\//g, '-')] = {
93-
pattern: RegExp('(content-type:\\s*' + pattern + '.*)(?:\\r?\\n|\\r){2}[\\s\\S]*', 'i'),
93+
pattern: RegExp('(content-type:\\s*' + pattern + '(?:(?:\\r\\n?|\\n).+)*)(?:\\r?\\n|\\r){2}[\\s\\S]*', 'i'),
9494
lookbehind: true,
9595
inside: httpLanguages[contentType]
9696
};

components/prism-http.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
HTTP/1.1 200 OK
2+
connection: keep-alive
3+
content-type: application/json
4+
date: Sat, 23 Jan 2021 20:36:14 GMT
5+
keep-alive: timeout=60
6+
transfer-encoding: chunked
7+
8+
{
9+
"id": 1,
10+
"name": "John Doe",
11+
"userName": "jdoe",
12+
"email": "whatever@something.zzz",
13+
"phone": "1234567890",
14+
"birthDate": "1878-05-06",
15+
"address": {
16+
"street": "Fake St",
17+
"street2": "Apt. 556",
18+
"city": "Gwenborough",
19+
"state": "ZZ",
20+
"zip": "12345"
21+
}
22+
}
23+
24+
----------------------------------------------------
25+
26+
[
27+
["response-status", [
28+
["http-version", "HTTP/1.1"],
29+
["status-code", "200"],
30+
["reason-phrase", "OK"]
31+
]],
32+
33+
["header-name", "connection:"],
34+
" keep-alive\r\n",
35+
36+
["header-name", "content-type:"],
37+
" application/json\r\n",
38+
39+
["header-name", "date:"],
40+
" Sat, 23 Jan 2021 20:36:14 GMT\r\n",
41+
42+
["header-name", "keep-alive:"],
43+
" timeout=60\r\n",
44+
45+
["header-name", "transfer-encoding:"],
46+
" chunked",
47+
["application-json", [
48+
["punctuation", "{"],
49+
50+
["string", "\"id\""],
51+
["operator", ":"],
52+
["number", "1"],
53+
["punctuation", ","],
54+
55+
["string", "\"name\""],
56+
["operator", ":"],
57+
["string", "\"John Doe\""],
58+
["punctuation", ","],
59+
60+
["string", "\"userName\""],
61+
["operator", ":"],
62+
["string", "\"jdoe\""],
63+
["punctuation", ","],
64+
65+
["string", "\"email\""],
66+
["operator", ":"],
67+
["string", "\"whatever@something.zzz\""],
68+
["punctuation", ","],
69+
70+
["string", "\"phone\""],
71+
["operator", ":"],
72+
["string", "\"1234567890\""],
73+
["punctuation", ","],
74+
75+
["string", "\"birthDate\""],
76+
["operator", ":"],
77+
["string", "\"1878-05-06\""],
78+
["punctuation", ","],
79+
80+
["string", "\"address\""],
81+
["operator", ":"],
82+
["punctuation", "{"],
83+
84+
["string", "\"street\""],
85+
["operator", ":"],
86+
["string", "\"Fake St\""],
87+
["punctuation", ","],
88+
89+
["string", "\"street2\""],
90+
["operator", ":"],
91+
["string", "\"Apt. 556\""],
92+
["punctuation", ","],
93+
94+
["string", "\"city\""],
95+
["operator", ":"],
96+
["string", "\"Gwenborough\""],
97+
["punctuation", ","],
98+
99+
["string", "\"state\""],
100+
["operator", ":"],
101+
["string", "\"ZZ\""],
102+
["punctuation", ","],
103+
104+
["string", "\"zip\""],
105+
["operator", ":"],
106+
["string", "\"12345\""],
107+
108+
["punctuation", "}"],
109+
110+
["punctuation", "}"]
111+
]]
112+
]
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
HTTP/1.1 200 OK
2+
connection: keep-alive
3+
content-type: application/json
4+
date: Sat, 23 Jan 2021 20:36:14 GMT
5+
keep-alive: timeout=60
6+
transfer-encoding: chunked
7+
8+
{
9+
"id": 1,
10+
"name": "John Doe",
11+
"userName": "jdoe",
12+
"email": "whatever@something.zzz",
13+
"phone": "1234567890",
14+
"birthDate": "1878-05-06",
15+
"address": {
16+
"street": "Fake St",
17+
"street2": "Apt. 556",
18+
"city": "Gwenborough",
19+
"state": "ZZ",
20+
"zip": "12345"
21+
}
22+
}
23+
24+
----------------------------------------------------
25+
26+
[
27+
["response-status", [
28+
["http-version", "HTTP/1.1"],
29+
["status-code", "200"],
30+
["reason-phrase", "OK"]
31+
]],
32+
33+
["header-name", "connection:"],
34+
" keep-alive\r\n",
35+
36+
["header-name", "content-type:"],
37+
" application/json\r\n",
38+
39+
["header-name", "date:"],
40+
" Sat, 23 Jan 2021 20:36:14 GMT\r\n",
41+
42+
["header-name", "keep-alive:"],
43+
" timeout=60\r\n",
44+
45+
["header-name", "transfer-encoding:"],
46+
" chunked",
47+
["application-json", [
48+
["punctuation", "{"],
49+
50+
["property", "\"id\""],
51+
["operator", ":"],
52+
["number", "1"],
53+
["punctuation", ","],
54+
55+
["property", "\"name\""],
56+
["operator", ":"],
57+
["string", "\"John Doe\""],
58+
["punctuation", ","],
59+
60+
["property", "\"userName\""],
61+
["operator", ":"],
62+
["string", "\"jdoe\""],
63+
["punctuation", ","],
64+
65+
["property", "\"email\""],
66+
["operator", ":"],
67+
["string", "\"whatever@something.zzz\""],
68+
["punctuation", ","],
69+
70+
["property", "\"phone\""],
71+
["operator", ":"],
72+
["string", "\"1234567890\""],
73+
["punctuation", ","],
74+
75+
["property", "\"birthDate\""],
76+
["operator", ":"],
77+
["string", "\"1878-05-06\""],
78+
["punctuation", ","],
79+
80+
["property", "\"address\""],
81+
["operator", ":"],
82+
["punctuation", "{"],
83+
84+
["property", "\"street\""],
85+
["operator", ":"],
86+
["string", "\"Fake St\""],
87+
["punctuation", ","],
88+
89+
["property", "\"street2\""],
90+
["operator", ":"],
91+
["string", "\"Apt. 556\""],
92+
["punctuation", ","],
93+
94+
["property", "\"city\""],
95+
["operator", ":"],
96+
["string", "\"Gwenborough\""],
97+
["punctuation", ","],
98+
99+
["property", "\"state\""],
100+
["operator", ":"],
101+
["string", "\"ZZ\""],
102+
["punctuation", ","],
103+
104+
["property", "\"zip\""],
105+
["operator", ":"],
106+
["string", "\"12345\""],
107+
108+
["punctuation", "}"],
109+
110+
["punctuation", "}"]
111+
]]
112+
]
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
HTTP/1.1 200 OK
2+
connection: keep-alive
3+
content-type: application/xml
4+
date: Sat, 23 Jan 2021 20:36:14 GMT
5+
keep-alive: timeout=60
6+
transfer-encoding: chunked
7+
8+
<xml>
9+
<one>Data</one>
10+
<two>More Data</two>
11+
</xml>
12+
13+
----------------------------------------------------
14+
15+
[
16+
["response-status", [
17+
["http-version", "HTTP/1.1"],
18+
["status-code", "200"],
19+
["reason-phrase", "OK"]
20+
]],
21+
22+
["header-name", "connection:"],
23+
" keep-alive\r\n",
24+
25+
["header-name", "content-type:"],
26+
" application/xml\r\n",
27+
28+
["header-name", "date:"],
29+
" Sat, 23 Jan 2021 20:36:14 GMT\r\n",
30+
31+
["header-name", "keep-alive:"],
32+
" timeout=60\r\n",
33+
34+
["header-name", "transfer-encoding:"],
35+
" chunked",
36+
["application-xml", [
37+
["tag", [
38+
["tag", [
39+
["punctuation", "<"],
40+
"xml"
41+
]],
42+
["punctuation", ">"]
43+
]],
44+
45+
["tag", [
46+
["tag", [
47+
["punctuation", "<"],
48+
"one"
49+
]],
50+
["punctuation", ">"]
51+
]],
52+
"Data",
53+
["tag", [
54+
["tag", [
55+
["punctuation", "</"],
56+
"one"
57+
]],
58+
["punctuation", ">"]
59+
]],
60+
61+
["tag", [
62+
["tag", [
63+
["punctuation", "<"],
64+
"two"
65+
]],
66+
["punctuation", ">"]
67+
]],
68+
"More Data",
69+
["tag", [
70+
["tag", [
71+
["punctuation", "</"],
72+
"two"
73+
]],
74+
["punctuation", ">"]
75+
]],
76+
77+
["tag", [
78+
["tag", [
79+
["punctuation", "</"],
80+
"xml"
81+
]],
82+
["punctuation", ">"]
83+
]]
84+
]]
85+
]

0 commit comments

Comments
 (0)