basant307/AI_Governance_Project
048
1/*2Language: HTTP3Description: HTTP request and response headers with automatic body highlighting4Author: Ivan Sagalaev <maniac@softwaremaniacs.org>5Category: protocols, web6Website: https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview7*/8 9function http(hljs) {10 const regex = hljs.regex;11 const VERSION = 'HTTP/([32]|1\\.[01])';12 const HEADER_NAME = /[A-Za-z][A-Za-z0-9-]*/;13 const HEADER = {14 className: 'attribute',15 begin: regex.concat('^', HEADER_NAME, '(?=\\:\\s)'),16 starts: { contains: [17 {18 className: "punctuation",19 begin: /: /,20 relevance: 0,21 starts: {22 end: '$',23 relevance: 024 }25 }26 ] }27 };28 const HEADERS_AND_BODY = [29 HEADER,30 {31 begin: '\\n\\n',32 starts: {33 subLanguage: [],34 endsWithParent: true35 }36 }37 ];38 39 return {40 name: 'HTTP',41 aliases: [ 'https' ],42 illegal: /\S/,43 contains: [44 // response45 {46 begin: '^(?=' + VERSION + " \\d{3})",47 end: /$/,48 contains: [49 {50 className: "meta",51 begin: VERSION52 },53 {54 className: 'number',55 begin: '\\b\\d{3}\\b'56 }57 ],58 starts: {59 end: /\b\B/,60 illegal: /\S/,61 contains: HEADERS_AND_BODY62 }63 },64 // request65 {66 begin: '(?=^[A-Z]+ (.*?) ' + VERSION + '$)',67 end: /$/,68 contains: [69 {70 className: 'string',71 begin: ' ',72 end: ' ',73 excludeBegin: true,74 excludeEnd: true75 },76 {77 className: "meta",78 begin: VERSION79 },80 {81 className: 'keyword',82 begin: '[A-Z]+'83 }84 ],85 starts: {86 end: /\b\B/,87 illegal: /\S/,88 contains: HEADERS_AND_BODY89 }90 },91 // to allow headers to work even without a preamble92 hljs.inherit(HEADER, { relevance: 0 })93 ]94 };95}96 97export { http as default };98 