Hash :
7bfed0f0
Author :
Date :
2013-12-18T22:31:53
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
Prism.languages.http = {
'request-line': {
pattern: /^(POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b\shttps?:\/\/\S+\sHTTP\/[0-9.]+/g,
inside: {
// HTTP Verb
property: /^\b(POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b/g,
// Path or query argument
'attr-name': /:\w+/g
}
},
'response-status': {
pattern: /^HTTP\/1.[01] [0-9]+.*/g,
inside: {
// Status, e.g. 200 OK
property: /[0-9]+[A-Z\s-]+$/g
}
},
// HTTP header name
keyword: /^[\w-]+:(?=.+)/gm
};
// Create a mapping of Content-Type headers to language definitions
var httpLanguages = {
'application/json': Prism.languages.javascript,
'application/xml': Prism.languages.markup,
'text/xml': Prism.languages.markup,
'text/html': Prism.languages.markup
};
// Insert each content type parser that has its associated language
// currently loaded.
for (var contentType in httpLanguages) {
if (httpLanguages[contentType]) {
var options = {};
options[contentType] = {
pattern: new RegExp('(content-type:\\s*' + contentType + '[\\w\\W]*?)\\n\\n[\\w\\W]*', 'gi'),
lookbehind: true,
inside: {
rest: httpLanguages[contentType]
}
};
Prism.languages.insertBefore('http', 'keyword', options);
}
}