Summary: | Single quotes in literal style block scalars break YAML syntax highlighting | ||
---|---|---|---|
Product: | [Frameworks and Libraries] frameworks-syntax-highlighting | Reporter: | 林博仁(Buo-ren, Lin) <Buo.Ren.Lin> |
Component: | syntax | Assignee: | Nibaldo G. <nibgonz> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | bugs.kde.org, nibgonz |
Priority: | NOR | ||
Version First Reported In: | 5.50.0 | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | https://commits.kde.org/syntax-highlighting/c32cf6020931ba47e04f477fd9144230c97c25dc | Version Fixed In: | 5.51.0 |
Sentry Crash Report: | |||
Attachments: |
sample file
sample screenshot |
Description
林博仁(Buo-ren, Lin)
2018-09-06 09:01:17 UTC
Created attachment 114803 [details]
sample screenshot
I tried to fix this bug for KDE Frameworks 5.50, but I could not. I had trouble capturing the exact indentation of the Key, since all lines with the Key's indentation plus a space are considered literal. A quick (and temporary) option, would highlight only the first line after "|" or ">" as literal... I have re-assigned to "frameworks-syntax-highlighting", version 5.50.0 I forgot to mention that this problem also exists in editors such as Atom, Sublime Text and Visual Studio Code. But, they partially solve this problem by highlighting strings and brackets (and other values) only if these are at the beginning of a line (or of a key's value). A similar solution could also be applied in KSyntaxHighlighting. This would solve errors, like the one 林博仁 shows in his code, but there would still be problems, for example, if a quot is at the beginning of a literal line. Improvement is appreciated even if it is not a complete fix, the big range of red text is unbearable. I managed to capture the indentation correctly! Proposed patch: https://phabricator.kde.org/D15780 Git commit c32cf6020931ba47e04f477fd9144230c97c25dc by Nibaldo González. Committed on 28/09/2018 at 03:22. Pushed by ngonzalez into branch 'master'. 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: {F6286907} * 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: {F6286908} * 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 FIXED-IN: 5.51.0 Test Plan: The changes I verified according to: * https://hackage.haskell.org/package/YamlReference * https://github.com/haphan/yaml-validator 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 M +78 -5 autotests/folding/test.yaml.fold M +78 -5 autotests/html/test.yaml.html M +77 -4 autotests/input/test.yaml M +78 -5 autotests/reference/test.yaml.ref M +265 -19 data/syntax/yaml.xml https://commits.kde.org/syntax-highlighting/c32cf6020931ba47e04f477fd9144230c97c25dc |