YAML: add literal & folded block styles

Authored by nibags on Sep 26 2018, 7:44 PM.

Description

YAML: add literal & folded block styles

Summary:
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:

BUG: 398314
FIXED-IN: 5.51.0

Test Plan:
The changes I verified according to:

Reviewers: cullmann, dhaumann, Framework: Syntax Highlighting, turbov

Reviewed By: turbov

Subscribers: turbov, kwrite-devel, kde-frameworks-devel

Tags: Kate, Frameworks

Differential Revision: https://phabricator.kde.org/D15780

Details

Committed
nibagsSep 28 2018, 3:22 AM
Reviewer
turbov
Differential Revision
D15780: YAML: add literal & folded block styles
Parents
R216:5dbf2ec3fe1d: Logcat & SELinux: improvements for the new Solarized schemes
Branches
Unknown
Tags
Unknown