Blame view

bower_components/prism/components/prism-http.js 1.33 KB
73bcce88   luigser   COMPONENTS
1
  Prism.languages.http = {
eb240478   Luigi Serra   public room cards...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  	'request-line': {
  		pattern: /^(POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b\shttps?:\/\/\S+\sHTTP\/[0-9.]+/m,
  		inside: {
  			// HTTP Verb
  			property: /^(POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b/,
  			// Path or query argument
  			'attr-name': /:\w+/
  		}
  	},
  	'response-status': {
  		pattern: /^HTTP\/1.[01] [0-9]+.*/m,
  		inside: {
  			// Status, e.g. 200 OK
  			property: {
                  pattern: /(^HTTP\/1.[01] )[0-9]+.*/i,
                  lookbehind: true
              }
  		}
  	},
  	// HTTP header name
  	'header-name': {
          pattern: /^[\w-]+:(?=.)/m,
          alias: 'keyword'
      }
73bcce88   luigser   COMPONENTS
26
27
28
29
  };
  
  // Create a mapping of Content-Type headers to language definitions
  var httpLanguages = {
eb240478   Luigi Serra   public room cards...
30
31
32
33
  	'application/json': Prism.languages.javascript,
  	'application/xml': Prism.languages.markup,
  	'text/xml': Prism.languages.markup,
  	'text/html': Prism.languages.markup
73bcce88   luigser   COMPONENTS
34
35
36
37
38
  };
  
  // Insert each content type parser that has its associated language
  // currently loaded.
  for (var contentType in httpLanguages) {
eb240478   Luigi Serra   public room cards...
39
40
41
42
43
44
45
46
47
48
49
  	if (httpLanguages[contentType]) {
  		var options = {};
  		options[contentType] = {
  			pattern: new RegExp('(content-type:\\s*' + contentType + '[\\w\\W]*?)(?:\\r?\\n|\\r){2}[\\w\\W]*', 'i'),
  			lookbehind: true,
  			inside: {
  				rest: httpLanguages[contentType]
  			}
  		};
  		Prism.languages.insertBefore('http', 'header-name', options);
  	}
73bcce88   luigser   COMPONENTS
50
  }