Sha256: 35bc2227c4f43a0e15c11aaf2624ac20c69159ab7b2891ac2c76ce4654047d2d

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

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-]+$/ig
        }
    },
    // 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);
    }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hyhyhy-1.0.0 lib/hyhyhy/structure/_includes/prism/components/prism-http.js
hyhyhy-0.0.9 lib/hyhyhy/structure/_includes/prism/components/prism-http.js
hyhyhy-0.0.8 lib/hyhyhy/structure/_includes/prism/components/prism-http.js
hyhyhy-0.0.7 lib/hyhyhy/structure/_includes/prism/components/prism-http.js
hyhyhy-0.0.6 lib/hyhyhy/structure/_includes/prism/components/prism-http.js
hyhyhy-0.0.5 lib/hyhyhy/structure/_includes/prism/components/prism-http.js
hyhyhy-0.0.4 lib/hyhyhy/structure/_includes/prism/components/prism-http.js