]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/yaml.js
1 /*! `yaml` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar
= (function () {
7 Description: Yet Another Markdown Language
8 Author: Stefan Wienert <stwienert@gmail.com>
9 Contributors: Carl Baxter <carl@cbax.tech>
11 Website: https://yaml.org
12 Category: common, config
15 const LITERALS
= 'true false yes no null';
17 // YAML spec allows non-reserved URI characters in tags.
18 const URI_CHARACTERS
= '[\\w#;/?:@&=+$,.~*\'()[\\]]+';
20 // Define keys as starting with a word character
21 // ...containing word chars, spaces, colons, forward-slashes, hyphens and periods
22 // ...and ending with a colon followed immediately by a space, tab or newline.
23 // The YAML spec allows for much more than this, but this covers most use-cases.
27 // added brackets support and special char support
28 { begin: /[\w
*@][\w
*@ :()\./-]*:(?=[ \t]|$)/ },
29 { // double quoted keys - with brackets and special char support
30 begin: /"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/ },
31 { // single quoted keys - with brackets and special char support
32 begin: /'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/ },
36 const TEMPLATE_VARIABLES
= {
37 className: 'template-variable',
39 { // jinja templates Ansible
50 const SINGLE_QUOTE_STRING
= {
75 hljs
.BACKSLASH_ESCAPE
,
80 // Strings inside of value containers (objects) can't contain braces,
81 // brackets, or commas
82 const CONTAINER_STRING
= hljs
.inherit(STRING
, { variants: [
97 { begin: /[^\s,{}[\]]+/ }
100 const DATE_RE
= '[0-9]{4}(-[0-9][0-9]){0,2}';
101 const TIME_RE
= '([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?';
102 const FRACTION_RE
= '(\\.[0-9]*)?';
103 const ZONE_RE
= '([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?';
106 begin: '\\b' + DATE_RE
+ TIME_RE
+ FRACTION_RE
+ ZONE_RE
+ '\\b'
109 const VALUE_CONTAINER
= {
111 endsWithParent: true,
119 contains: [ VALUE_CONTAINER
],
126 contains: [ VALUE_CONTAINER
],
138 { // multi line string
139 // Blocks start with a | or > followed by a newline
141 // Indentation of subsequent lines must be the same to
142 // be considered part of the block
144 begin: '[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*'
156 begin: '!\\w+!' + URI_CHARACTERS
158 // https://yaml.org/spec/1.2/spec.html#id2784064
161 begin: '!<' + URI_CHARACTERS
+ ">"
165 begin: '!' + URI_CHARACTERS
169 begin: '!!' + URI_CHARACTERS
171 { // fragment id &ref
173 begin: '&' + hljs
.UNDERSCORE_IDENT_RE
+ '$'
175 { // fragment reference *ref
177 begin: '\\*' + hljs
.UNDERSCORE_IDENT_RE
+ '$'
181 // TODO: remove |$ hack when we have proper look-ahead support
185 hljs
.HASH_COMMENT_MODE
,
187 beginKeywords: LITERALS
,
188 keywords: { literal: LITERALS
}
191 // numbers are any valid C-style number that
192 // sit isolated from other words
195 begin: hljs
.C_NUMBER_RE
+ '\\b',
204 const VALUE_MODES
= [ ...MODES
];
206 VALUE_MODES
.push(CONTAINER_STRING
);
207 VALUE_CONTAINER
.contains
= VALUE_MODES
;
211 case_insensitive: true,
221 export default hljsGrammar
;