prismjs_components_prism-yaml.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // node_modules/prismjs/components/prism-yaml.js
  2. (function(Prism2) {
  3. var anchorOrAlias = /[*&][^\s[\]{},]+/;
  4. var tag = /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/;
  5. var properties = "(?:" + tag.source + "(?:[ ]+" + anchorOrAlias.source + ")?|" + anchorOrAlias.source + "(?:[ ]+" + tag.source + ")?)";
  6. var plainKey = /(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(/<PLAIN>/g, function() {
  7. return /[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source;
  8. });
  9. var string = /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;
  10. function createValuePattern(value, flags) {
  11. flags = (flags || "").replace(/m/g, "") + "m";
  12. var pattern = /([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g, function() {
  13. return properties;
  14. }).replace(/<<value>>/g, function() {
  15. return value;
  16. });
  17. return RegExp(pattern, flags);
  18. }
  19. Prism2.languages.yaml = {
  20. "scalar": {
  21. pattern: RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<<prop>>/g, function() {
  22. return properties;
  23. })),
  24. lookbehind: true,
  25. alias: "string"
  26. },
  27. "comment": /#.*/,
  28. "key": {
  29. pattern: RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g, function() {
  30. return properties;
  31. }).replace(/<<key>>/g, function() {
  32. return "(?:" + plainKey + "|" + string + ")";
  33. })),
  34. lookbehind: true,
  35. greedy: true,
  36. alias: "atrule"
  37. },
  38. "directive": {
  39. pattern: /(^[ \t]*)%.+/m,
  40. lookbehind: true,
  41. alias: "important"
  42. },
  43. "datetime": {
  44. pattern: createValuePattern(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),
  45. lookbehind: true,
  46. alias: "number"
  47. },
  48. "boolean": {
  49. pattern: createValuePattern(/false|true/.source, "i"),
  50. lookbehind: true,
  51. alias: "important"
  52. },
  53. "null": {
  54. pattern: createValuePattern(/null|~/.source, "i"),
  55. lookbehind: true,
  56. alias: "important"
  57. },
  58. "string": {
  59. pattern: createValuePattern(string),
  60. lookbehind: true,
  61. greedy: true
  62. },
  63. "number": {
  64. pattern: createValuePattern(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source, "i"),
  65. lookbehind: true
  66. },
  67. "tag": tag,
  68. "important": anchorOrAlias,
  69. "punctuation": /---|[:[\]{}\-,|>?]|\.\.\./
  70. };
  71. Prism2.languages.yml = Prism2.languages.yaml;
  72. })(Prism);
  73. //# sourceMappingURL=prismjs_components_prism-yaml.js.map