Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: lib/src/prism/components/prism-http.js

Issue 1418513006: update elements and fix some bugs (Closed) Base URL: git@github.com:dart-lang/polymer_elements.git@master
Patch Set: code review updates Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 Prism.languages.http = { 1 Prism.languages.http = {
2 'request-line': { 2 » 'request-line': {
3 pattern: /^(POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b\shttps?:\ /\/\S+\sHTTP\/[0-9.]+/, 3 » » pattern: /^(POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b\s https?:\/\/\S+\sHTTP\/[0-9.]+/m,
4 inside: { 4 » » inside: {
5 // HTTP Verb 5 » » » // HTTP Verb
6 property: /^\b(POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CONNECT)\b/, 6 » » » property: /^(POST|GET|PUT|DELETE|OPTIONS|PATCH|TRACE|CON NECT)\b/,
7 // Path or query argument 7 » » » // Path or query argument
8 'attr-name': /:\w+/ 8 » » » 'attr-name': /:\w+/
9 } 9 » » }
10 }, 10 » },
11 'response-status': { 11 » 'response-status': {
12 pattern: /^HTTP\/1.[01] [0-9]+.*/, 12 » » pattern: /^HTTP\/1.[01] [0-9]+.*/m,
13 inside: { 13 » » inside: {
14 // Status, e.g. 200 OK 14 » » » // Status, e.g. 200 OK
15 property: /[0-9]+[A-Z\s-]+$/i 15 » » » property: {
16 } 16 pattern: /(^HTTP\/1.[01] )[0-9]+.*/i,
17 }, 17 lookbehind: true
18 // HTTP header name 18 }
19 keyword: /^[\w-]+:(?=.+)/m 19 » » }
20 » },
21 » // HTTP header name
22 » 'header-name': {
23 pattern: /^[\w-]+:(?=.)/m,
24 alias: 'keyword'
25 }
20 }; 26 };
21 27
22 // Create a mapping of Content-Type headers to language definitions 28 // Create a mapping of Content-Type headers to language definitions
23 var httpLanguages = { 29 var httpLanguages = {
24 'application/json': Prism.languages.javascript, 30 » 'application/json': Prism.languages.javascript,
25 'application/xml': Prism.languages.markup, 31 » 'application/xml': Prism.languages.markup,
26 'text/xml': Prism.languages.markup, 32 » 'text/xml': Prism.languages.markup,
27 'text/html': Prism.languages.markup 33 » 'text/html': Prism.languages.markup
28 }; 34 };
29 35
30 // Insert each content type parser that has its associated language 36 // Insert each content type parser that has its associated language
31 // currently loaded. 37 // currently loaded.
32 for (var contentType in httpLanguages) { 38 for (var contentType in httpLanguages) {
33 if (httpLanguages[contentType]) { 39 » if (httpLanguages[contentType]) {
34 var options = {}; 40 » » var options = {};
35 options[contentType] = { 41 » » options[contentType] = {
36 pattern: new RegExp('(content-type:\\s*' + contentType + '[\\w\\W]*? )\\n\\n[\\w\\W]*', 'i'), 42 » » » pattern: new RegExp('(content-type:\\s*' + contentType + '[\\w\\W]*?)(?:\\r?\\n|\\r){2}[\\w\\W]*', 'i'),
37 lookbehind: true, 43 » » » lookbehind: true,
38 inside: { 44 » » » inside: {
39 rest: httpLanguages[contentType] 45 » » » » rest: httpLanguages[contentType]
40 } 46 » » » }
41 }; 47 » » };
42 Prism.languages.insertBefore('http', 'keyword', options); 48 » » Prism.languages.insertBefore('http', 'header-name', options);
43 } 49 » }
44 } 50 }
OLDNEW
« no previous file with comments | « lib/src/prism/components/prism-haskell.min.js ('k') | lib/src/prism/components/prism-http.min.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698