1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
| module.exports = function(hljs) {
| var LITERALS = 'true false yes no null';
|
| // Define keys as starting with a word character
| // ...containing word chars, spaces, colons, forward-slashes, hyphens and periods
| // ...and ending with a colon followed immediately by a space, tab or newline.
| // The YAML spec allows for much more than this, but this covers most use-cases.
| var KEY = {
| className: 'attr',
| variants: [
| { begin: '\\w[\\w :\\/.-]*:(?=[ \t]|$)' },
| { begin: '"\\w[\\w :\\/.-]*":(?=[ \t]|$)' }, //double quoted keys
| { begin: '\'\\w[\\w :\\/.-]*\':(?=[ \t]|$)' } //single quoted keys
| ]
| };
|
| var TEMPLATE_VARIABLES = {
| className: 'template-variable',
| variants: [
| { begin: '\{\{', end: '\}\}' }, // jinja templates Ansible
| { begin: '%\{', end: '\}' } // Ruby i18n
| ]
| };
| var STRING = {
| className: 'string',
| relevance: 0,
| variants: [
| {begin: /'/, end: /'/},
| {begin: /"/, end: /"/},
| {begin: /\S+/}
| ],
| contains: [
| hljs.BACKSLASH_ESCAPE,
| TEMPLATE_VARIABLES
| ]
| };
|
| return {
| case_insensitive: true,
| aliases: ['yml', 'YAML', 'yaml'],
| contains: [
| KEY,
| {
| className: 'meta',
| begin: '^---\s*$',
| relevance: 10
| },
| { // multi line string
| // Blocks start with a | or > followed by a newline
| //
| // Indentation of subsequent lines must be the same to
| // be considered part of the block
| className: 'string',
| begin: '[\\|>]([0-9]?[+-])?[ ]*\\n( *)[\\S ]+\\n(\\2[\\S ]+\\n?)*',
| },
| { // Ruby/Rails erb
| begin: '<%[%=-]?', end: '[%-]?%>',
| subLanguage: 'ruby',
| excludeBegin: true,
| excludeEnd: true,
| relevance: 0
| },
| { // local tags
| className: 'type',
| begin: '!' + hljs.UNDERSCORE_IDENT_RE,
| },
| { // data type
| className: 'type',
| begin: '!!' + hljs.UNDERSCORE_IDENT_RE,
| },
| { // fragment id &ref
| className: 'meta',
| begin: '&' + hljs.UNDERSCORE_IDENT_RE + '$',
| },
| { // fragment reference *ref
| className: 'meta',
| begin: '\\*' + hljs.UNDERSCORE_IDENT_RE + '$'
| },
| { // array listing
| className: 'bullet',
| // TODO: remove |$ hack when we have proper look-ahead support
| begin: '\\-(?=[ ]|$)',
| relevance: 0
| },
| hljs.HASH_COMMENT_MODE,
| {
| beginKeywords: LITERALS,
| keywords: {literal: LITERALS}
| },
| // numbers are any valid C-style number that
| // sit isolated from other words
| {
| className: 'number',
| begin: hljs.C_NUMBER_RE + '\\b'
| },
| STRING
| ]
| };
| };
|
|