Fix some reported bugs and update the syntax for YAML 1.2:
- Fixes the end of a Key:
BUG: 366586
Any line of text before : is highlighted as Key, which is very general and gives rise to errors. As mentioned in the bug, in a line like the following, everything is considered as a Key, until the last :
To fix this, it's necessary to add a space/end-line to the end of a Key KEY:(?=\s|$).
The YAML documentation mentions: *Mappings use a colon and space (“: ”) to mark each key: value pair* [1].
- Fix delimiter characters in a Key:
BUG: 389636
On the next line, it is highlighted as a Key: {b:
Within hashes and lists, the characters {, [ and , should not be highlighted as Keys, since these are delimiting characters that mark the start/end of an element.
- Allow inline attributes in lists: [key1: value, key2: value, ...]
Previously, when writing a key, the entire line was highlighted as a value, now the value ends with "," or "]" (in the example, 3, 2, !!ddfgdf is Key and sdsd 1, takeoff]} is value).
- Highlight values in Key with multiple lines. That is, when ":" is the first character of a line.
- Highlight references, aliases, strings, etc. in hashes. Before, the hashes only support content of the type key: value. This improves highlighting in keys with many lines.
- Add mapping-key operator: ?. In the current highlight, references, aliases, sequences and dash after "?" are not highlighted, that is corrected. This also applies to lists and hashes.
- Add escapes [2]. Also, allow escapes in keys quoted. Ex: "key\"a": value or 'key''a': value`.
- Add Integers [4] & Floats [5] [3] (the documentation shows the exact regular expressions).
- Add booleans [7] & improves the detection of null (add missing null keywords) [6]. These are highlighted with "dsChar".
Although there are still things to be corrected! Lines with literal/folded style (after "|" or ">") are not highlighted correctly.
Ex:
key1: - key2: | Literal characters " ' { } Literal... - key 3: value
To do that you have to capture the exact indentation of the Key. I tried to do it with dynamic rules, but it does not capture the spaces at the start of a line! I will try to fix this in a future diff. I added a comment mentioning this.
References:
- [1] YAML Specs, Collections: http://yaml.org/spec/1.2/spec.html#id2759963
- [2] YAML Specs, Escaped Characters: http://yaml.org/spec/1.2/spec.html#id2776092
- [3] YAML Specs, Integer & Float: http://yaml.org/spec/1.2/spec.html#id2803828
- [4] Integer Language-Independent Type for YAML™ Version 1.1: http://yaml.org/type/int.html
- [5] Floating-Point Language-Independent Type for YAML™ Version 1.1: http://yaml.org/type/float.html
- [6] Null Language-Independent Type for YAML™ Version 1.1: http://yaml.org/type/null.html
- [7] Boolean Language-Independent Type for YAML™ Version 1.1: http://yaml.org/type/bool.html