text/js/ruby-BxWrfYu-.chunk.mjs.map

1 строка
14 KiB
Plaintext

{"version":3,"file":"ruby-BxWrfYu-.chunk.mjs","sources":["../node_modules/highlight.js/lib/languages/ruby.js"],"sourcesContent":["/*\nLanguage: Ruby\nDescription: Ruby is a dynamic, open source programming language with a focus on simplicity and productivity.\nWebsite: https://www.ruby-lang.org/\nAuthor: Anton Kovalyov <anton@kovalyov.net>\nContributors: Peter Leonov <gojpeg@yandex.ru>, Vasily Polovnyov <vast@whiteants.net>, Loren Segal <lsegal@soen.ca>, Pascal Hurni <phi@ruby-reactive.org>, Cedric Sohrauer <sohrauer@googlemail.com>\nCategory: common, scripting\n*/\n\nfunction ruby(hljs) {\n const regex = hljs.regex;\n const RUBY_METHOD_RE = '([a-zA-Z_]\\\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\\\*\\\\*|[-/+%^&*~`|]|\\\\[\\\\]=?)';\n // TODO: move concepts like CAMEL_CASE into `modes.js`\n const CLASS_NAME_RE = regex.either(\n /\\b([A-Z]+[a-z0-9]+)+/,\n // ends in caps\n /\\b([A-Z]+[a-z0-9]+)+[A-Z]+/,\n )\n ;\n const CLASS_NAME_WITH_NAMESPACE_RE = regex.concat(CLASS_NAME_RE, /(::\\w+)*/);\n // very popular ruby built-ins that one might even assume\n // are actual keywords (despite that not being the case)\n const PSEUDO_KWS = [\n \"include\",\n \"extend\",\n \"prepend\",\n \"public\",\n \"private\",\n \"protected\",\n \"raise\",\n \"throw\"\n ];\n const RUBY_KEYWORDS = {\n \"variable.constant\": [\n \"__FILE__\",\n \"__LINE__\",\n \"__ENCODING__\"\n ],\n \"variable.language\": [\n \"self\",\n \"super\",\n ],\n keyword: [\n \"alias\",\n \"and\",\n \"begin\",\n \"BEGIN\",\n \"break\",\n \"case\",\n \"class\",\n \"defined\",\n \"do\",\n \"else\",\n \"elsif\",\n \"end\",\n \"END\",\n \"ensure\",\n \"for\",\n \"if\",\n \"in\",\n \"module\",\n \"next\",\n \"not\",\n \"or\",\n \"redo\",\n \"require\",\n \"rescue\",\n \"retry\",\n \"return\",\n \"then\",\n \"undef\",\n \"unless\",\n \"until\",\n \"when\",\n \"while\",\n \"yield\",\n ...PSEUDO_KWS\n ],\n built_in: [\n \"proc\",\n \"lambda\",\n \"attr_accessor\",\n \"attr_reader\",\n \"attr_writer\",\n \"define_method\",\n \"private_constant\",\n \"module_function\"\n ],\n literal: [\n \"true\",\n \"false\",\n \"nil\"\n ]\n };\n const YARDOCTAG = {\n className: 'doctag',\n begin: '@[A-Za-z]+'\n };\n const IRB_OBJECT = {\n begin: '#<',\n end: '>'\n };\n const COMMENT_MODES = [\n hljs.COMMENT(\n '#',\n '$',\n { contains: [ YARDOCTAG ] }\n ),\n hljs.COMMENT(\n '^=begin',\n '^=end',\n {\n contains: [ YARDOCTAG ],\n relevance: 10\n }\n ),\n hljs.COMMENT('^__END__', hljs.MATCH_NOTHING_RE)\n ];\n const SUBST = {\n className: 'subst',\n begin: /#\\{/,\n end: /\\}/,\n keywords: RUBY_KEYWORDS\n };\n const STRING = {\n className: 'string',\n contains: [\n hljs.BACKSLASH_ESCAPE,\n SUBST\n ],\n variants: [\n {\n begin: /'/,\n end: /'/\n },\n {\n begin: /\"/,\n end: /\"/\n },\n {\n begin: /`/,\n end: /`/\n },\n {\n begin: /%[qQwWx]?\\(/,\n end: /\\)/\n },\n {\n begin: /%[qQwWx]?\\[/,\n end: /\\]/\n },\n {\n begin: /%[qQwWx]?\\{/,\n end: /\\}/\n },\n {\n begin: /%[qQwWx]?</,\n end: />/\n },\n {\n begin: /%[qQwWx]?\\//,\n end: /\\//\n },\n {\n begin: /%[qQwWx]?%/,\n end: /%/\n },\n {\n begin: /%[qQwWx]?-/,\n end: /-/\n },\n {\n begin: /%[qQwWx]?\\|/,\n end: /\\|/\n },\n // in the following expressions, \\B in the beginning suppresses recognition of ?-sequences\n // where ? is the last character of a preceding identifier, as in: `func?4`\n { begin: /\\B\\?(\\\\\\d{1,3})/ },\n { begin: /\\B\\?(\\\\x[A-Fa-f0-9]{1,2})/ },\n { begin: /\\B\\?(\\\\u\\{?[A-Fa-f0-9]{1,6}\\}?)/ },\n { begin: /\\B\\?(\\\\M-\\\\C-|\\\\M-\\\\c|\\\\c\\\\M-|\\\\M-|\\\\C-\\\\M-)[\\x20-\\x7e]/ },\n { begin: /\\B\\?\\\\(c|C-)[\\x20-\\x7e]/ },\n { begin: /\\B\\?\\\\?\\S/ },\n // heredocs\n {\n // this guard makes sure that we have an entire heredoc and not a false\n // positive (auto-detect, etc.)\n begin: regex.concat(\n /<<[-~]?'?/,\n regex.lookahead(/(\\w+)(?=\\W)[^\\n]*\\n(?:[^\\n]*\\n)*?\\s*\\1\\b/)\n ),\n contains: [\n hljs.END_SAME_AS_BEGIN({\n begin: /(\\w+)/,\n end: /(\\w+)/,\n contains: [\n hljs.BACKSLASH_ESCAPE,\n SUBST\n ]\n })\n ]\n }\n ]\n };\n\n // Ruby syntax is underdocumented, but this grammar seems to be accurate\n // as of version 2.7.2 (confirmed with (irb and `Ripper.sexp(...)`)\n // https://docs.ruby-lang.org/en/2.7.0/doc/syntax/literals_rdoc.html#label-Numbers\n const decimal = '[1-9](_?[0-9])*|0';\n const digits = '[0-9](_?[0-9])*';\n const NUMBER = {\n className: 'number',\n relevance: 0,\n variants: [\n // decimal integer/float, optionally exponential or rational, optionally imaginary\n { begin: `\\\\b(${decimal})(\\\\.(${digits}))?([eE][+-]?(${digits})|r)?i?\\\\b` },\n\n // explicit decimal/binary/octal/hexadecimal integer,\n // optionally rational and/or imaginary\n { begin: \"\\\\b0[dD][0-9](_?[0-9])*r?i?\\\\b\" },\n { begin: \"\\\\b0[bB][0-1](_?[0-1])*r?i?\\\\b\" },\n { begin: \"\\\\b0[oO][0-7](_?[0-7])*r?i?\\\\b\" },\n { begin: \"\\\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\\\b\" },\n\n // 0-prefixed implicit octal integer, optionally rational and/or imaginary\n { begin: \"\\\\b0(_?[0-7])+r?i?\\\\b\" }\n ]\n };\n\n const PARAMS = {\n variants: [\n {\n match: /\\(\\)/,\n },\n {\n className: 'params',\n begin: /\\(/,\n end: /(?=\\))/,\n excludeBegin: true,\n endsParent: true,\n keywords: RUBY_KEYWORDS,\n }\n ]\n };\n\n const INCLUDE_EXTEND = {\n match: [\n /(include|extend)\\s+/,\n CLASS_NAME_WITH_NAMESPACE_RE\n ],\n scope: {\n 2: \"title.class\"\n },\n keywords: RUBY_KEYWORDS\n };\n\n const CLASS_DEFINITION = {\n variants: [\n {\n match: [\n /class\\s+/,\n CLASS_NAME_WITH_NAMESPACE_RE,\n /\\s+<\\s+/,\n CLASS_NAME_WITH_NAMESPACE_RE\n ]\n },\n {\n match: [\n /\\b(class|module)\\s+/,\n CLASS_NAME_WITH_NAMESPACE_RE\n ]\n }\n ],\n scope: {\n 2: \"title.class\",\n 4: \"title.class.inherited\"\n },\n keywords: RUBY_KEYWORDS\n };\n\n const UPPER_CASE_CONSTANT = {\n relevance: 0,\n match: /\\b[A-Z][A-Z_0-9]+\\b/,\n className: \"variable.constant\"\n };\n\n const METHOD_DEFINITION = {\n match: [\n /def/, /\\s+/,\n RUBY_METHOD_RE\n ],\n scope: {\n 1: \"keyword\",\n 3: \"title.function\"\n },\n contains: [\n PARAMS\n ]\n };\n\n const OBJECT_CREATION = {\n relevance: 0,\n match: [\n CLASS_NAME_WITH_NAMESPACE_RE,\n /\\.new[. (]/\n ],\n scope: {\n 1: \"title.class\"\n }\n };\n\n // CamelCase\n const CLASS_REFERENCE = {\n relevance: 0,\n match: CLASS_NAME_RE,\n scope: \"title.class\"\n };\n\n const RUBY_DEFAULT_CONTAINS = [\n STRING,\n CLASS_DEFINITION,\n INCLUDE_EXTEND,\n OBJECT_CREATION,\n UPPER_CASE_CONSTANT,\n CLASS_REFERENCE,\n METHOD_DEFINITION,\n {\n // swallow namespace qualifiers before symbols\n begin: hljs.IDENT_RE + '::' },\n {\n className: 'symbol',\n begin: hljs.UNDERSCORE_IDENT_RE + '(!|\\\\?)?:',\n relevance: 0\n },\n {\n className: 'symbol',\n begin: ':(?!\\\\s)',\n contains: [\n STRING,\n { begin: RUBY_METHOD_RE }\n ],\n relevance: 0\n },\n NUMBER,\n {\n // negative-look forward attempts to prevent false matches like:\n // @ident@ or $ident$ that might indicate this is not ruby at all\n className: \"variable\",\n begin: '(\\\\$\\\\W)|((\\\\$|@@?)(\\\\w+))(?=[^@$?])' + `(?![A-Za-z])(?![@$?'])`\n },\n {\n className: 'params',\n begin: /\\|/,\n end: /\\|/,\n excludeBegin: true,\n excludeEnd: true,\n relevance: 0, // this could be a lot of things (in other languages) other than params\n keywords: RUBY_KEYWORDS\n },\n { // regexp container\n begin: '(' + hljs.RE_STARTERS_RE + '|unless)\\\\s*',\n keywords: 'unless',\n contains: [\n {\n className: 'regexp',\n contains: [\n hljs.BACKSLASH_ESCAPE,\n SUBST\n ],\n illegal: /\\n/,\n variants: [\n {\n begin: '/',\n end: '/[a-z]*'\n },\n {\n begin: /%r\\{/,\n end: /\\}[a-z]*/\n },\n {\n begin: '%r\\\\(',\n end: '\\\\)[a-z]*'\n },\n {\n begin: '%r!',\n end: '![a-z]*'\n },\n {\n begin: '%r\\\\[',\n end: '\\\\][a-z]*'\n }\n ]\n }\n ].concat(IRB_OBJECT, COMMENT_MODES),\n relevance: 0\n }\n ].concat(IRB_OBJECT, COMMENT_MODES);\n\n SUBST.contains = RUBY_DEFAULT_CONTAINS;\n PARAMS.contains = RUBY_DEFAULT_CONTAINS;\n\n // >>\n // ?>\n const SIMPLE_PROMPT = \"[>?]>\";\n // irb(main):001:0>\n const DEFAULT_PROMPT = \"[\\\\w#]+\\\\(\\\\w+\\\\):\\\\d+:\\\\d+[>*]\";\n const RVM_PROMPT = \"(\\\\w+-)?\\\\d+\\\\.\\\\d+\\\\.\\\\d+(p\\\\d+)?[^\\\\d][^>]+>\";\n\n const IRB_DEFAULT = [\n {\n begin: /^\\s*=>/,\n starts: {\n end: '$',\n contains: RUBY_DEFAULT_CONTAINS\n }\n },\n {\n className: 'meta.prompt',\n begin: '^(' + SIMPLE_PROMPT + \"|\" + DEFAULT_PROMPT + '|' + RVM_PROMPT + ')(?=[ ])',\n starts: {\n end: '$',\n keywords: RUBY_KEYWORDS,\n contains: RUBY_DEFAULT_CONTAINS\n }\n }\n ];\n\n COMMENT_MODES.unshift(IRB_OBJECT);\n\n return {\n name: 'Ruby',\n aliases: [\n 'rb',\n 'gemspec',\n 'podspec',\n 'thor',\n 'irb'\n ],\n keywords: RUBY_KEYWORDS,\n illegal: /\\/\\*/,\n contains: [ hljs.SHEBANG({ binary: \"ruby\" }) ]\n .concat(IRB_DEFAULT)\n .concat(COMMENT_MODES)\n .concat(RUBY_DEFAULT_CONTAINS)\n };\n}\n\nmodule.exports = ruby;\n"],"names":["ruby","hljs","regex","RUBY_METHOD_RE","CLASS_NAME_RE","CLASS_NAME_WITH_NAMESPACE_RE","RUBY_KEYWORDS","YARDOCTAG","IRB_OBJECT","COMMENT_MODES","SUBST","STRING","decimal","digits","NUMBER","PARAMS","RUBY_DEFAULT_CONTAINS","IRB_DEFAULT","ruby_1"],"mappings":";4YASA,SAASA,EAAKC,EAAM,CAClB,MAAMC,EAAQD,EAAK,MACbE,EAAiB,qFAEjBC,EAAgBF,EAAM,OAC1B,uBAEA,4BACD,EAEKG,EAA+BH,EAAM,OAAOE,EAAe,UAAU,EAarEE,EAAgB,CACpB,oBAAqB,CACnB,WACA,WACA,cACD,EACD,oBAAqB,CACnB,OACA,OACD,EACD,QAAS,CACP,QACA,MACA,QACA,QACA,QACA,OACA,QACA,UACA,KACA,OACA,QACA,MACA,MACA,SACA,MACA,KACA,KACA,SACA,OACA,MACA,KACA,OACA,UACA,SACA,QACA,SACA,OACA,QACA,SACA,QACA,OACA,QACA,QApDF,UACA,SACA,UACA,SACA,UACA,YACA,QACA,OA+CC,EACD,SAAU,CACR,OACA,SACA,gBACA,cACA,cACA,gBACA,mBACA,iBACD,EACD,QAAS,CACP,OACA,QACA,KACD,CACL,EACQC,EAAY,CAChB,UAAW,SACX,MAAO,YACX,EACQC,EAAa,CACjB,MAAO,KACP,IAAK,GACT,EACQC,EAAgB,CACpBR,EAAK,QACH,IACA,IACA,CAAE,SAAU,CAAEM,EAAa,CAC5B,EACDN,EAAK,QACH,UACA,QACA,CACE,SAAU,CAAEM,CAAW,EACvB,UAAW,EACZ,CACF,EACDN,EAAK,QAAQ,WAAYA,EAAK,gBAAgB,CAClD,EACQS,EAAQ,CACZ,UAAW,QACX,MAAO,MACP,IAAK,KACL,SAAUJ,CACd,EACQK,EAAS,CACb,UAAW,SACX,SAAU,CACRV,EAAK,iBACLS,CACD,EACD,SAAU,CACR,CACE,MAAO,IACP,IAAK,GACN,EACD,CACE,MAAO,IACP,IAAK,GACN,EACD,CACE,MAAO,IACP,IAAK,GACN,EACD,CACE,MAAO,cACP,IAAK,IACN,EACD,CACE,MAAO,cACP,IAAK,IACN,EACD,CACE,MAAO,cACP,IAAK,IACN,EACD,CACE,MAAO,aACP,IAAK,GACN,EACD,CACE,MAAO,cACP,IAAK,IACN,EACD,CACE,MAAO,aACP,IAAK,GACN,EACD,CACE,MAAO,aACP,IAAK,GACN,EACD,CACE,MAAO,cACP,IAAK,IACN,EAGD,CAAE,MAAO,iBAAmB,EAC5B,CAAE,MAAO,2BAA6B,EACtC,CAAE,MAAO,iCAAmC,EAC5C,CAAE,MAAO,yDAA2D,EACpE,CAAE,MAAO,yBAA2B,EACpC,CAAE,MAAO,WAAa,EAEtB,CAGE,MAAOR,EAAM,OACX,YACAA,EAAM,UAAU,0CAA0C,CAC3D,EACD,SAAU,CACRD,EAAK,kBAAkB,CACrB,MAAO,QACP,IAAK,QACL,SAAU,CACRA,EAAK,iBACLS,CACD,CACb,CAAW,CACF,CACF,CACF,CACL,EAKQE,EAAU,oBACVC,EAAS,kBACTC,EAAS,CACb,UAAW,SACX,UAAW,EACX,SAAU,CAER,CAAE,MAAO,OAAOF,OAAAA,EAAO,UA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SAAU,SACV,SAAU,CACR,CACE,UAAW,SACX,SAAU,CACRA,EAAK,iBACLS,CACD,EACD,QAAS,KACT,SAAU,CACR,CACE,MAAO,IACP,IAAK,SACN,EACD,CACE,MAAO,OACP,IAAK,UACN,EACD,CACE,MAAO,QACP,IAAK,WACN,EACD,CACE,MAAO,MACP,IAAK,SACN,EACD,CACE,MAAO,QACP,IAAK,WACN,CACF,CACF,CACT,EAAQ,OAAOF,EAAYC,CAAa,EAClC,UAAW,CACZ,CACL,EAAI,OAAOD,EAAYC,CAAa,EAElCC,EAAM,SAAWM,EACjBD,EAAO,SAAWC,EASlB,MAAMC,EAAc,CAClB,CACE,MAAO,SACP,OAAQ,CACN,IAAK,IACL,SAAUD,CACX,CACF,EACD,CACE,UAAW,cACX,MAAO,iGACP,OAAQ,CACN,IAAK,IACL,SAAUV,EACV,SAAUU,CACX,CACF,CACL,EAEE,OAAAP,EAAc,QAAQD,CAAU,EAEzB,CACL,KAAM,OACN,QAAS,CACP,KACA,UACA,UACA,OACA,KACD,EACD,SAAUF,EACV,QAAS,OACT,SAAU,CAAEL,EAAK,QAAQ,CAAE,OAAQ,MAAM,CAAE,CAAG,EAC3C,OAAOgB,CAAW,EAClB,OAAOR,CAAa,EACpB,OAAOO,CAAqB,CACnC,CACA,CAEA,IAAAE,EAAiBlB","x_google_ignoreList":[0]}