Highlight literal blocks after the operators |, |-, |+, >, >- and >+.
To do this correctly, the indentation of the Key or operator is captured (with dynamic rules). Note that in nested block collections, the - and ? characters are considered as part of the indentation (ref. [2] & [3]):
- With Key: Text lines with indentation of the Key plus a space are considered literal. The - and ? operators are considered as part of the indentation:
- If there is no Key present: the literal/folded operator is at the beginning of the line or there is - or ? character before. In the first case, the indentation of the literal/folded operator is captured and, in the second, the indentation of - or ?. In nested blocks or sequences, the indentation of the last operator ? or - is captured:
- But, this implementation has a limitation: it only supports 6 nested operadors (? and -) at most.
This only works with indentations with spaces. If a tab is detected, it is highlighted with "Alert".
The empty lines are also part of the literal block.
Also, some minor improvements are included: the sequences require a dash plus a space.
Source:
YAML 1.2 Specs:
- [1] Chapter 8: Block Styles: http://yaml.org/spec/1.2/spec.html#style/block/
- [2] 6.1. Indentation Spaces: http://yaml.org/spec/1.2/spec.html#id2777534
- [3] 8.2.1. Block Sequences: http://yaml.org/spec/1.2/spec.html#id2797382
BUG: 398314
FIXED-IN: 5.51.0