<table><tr><td style="">nibags edited the summary of this revision. <a href="https://phabricator.kde.org/transactions/detail/PHID-XACT-DREV-nz5ujwdaml5z3oa/">(Show Details)</a><br />nibags added reviewers: dhaumann, cullmann, Framework: Syntax Highlighting.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D14760">View Revision</a></tr></table><br /><div><strong>CHANGES TO REVISION SUMMARY</strong><div><div style="white-space: pre-wrap; color: #74777D;"><div style="padding: 8px 0;">...</div>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 `:`<br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">{image1}</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">{F6188499}</span><br />
<br />
To fix this, it's necessary to add a space/end-line to the end of a Key `KEY:(?=\s|$)`. <div style="padding: 8px 0;">...</div>On the next line, it is highlighted as a Key: `{b:`<span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);"><br />
{F6188501}</span><br />
<br />
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.<div style="padding: 8px 0;">...</div>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).<br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);"><br />
For this, the context "attribute-pre-inline" is separated in the contexts "list-attribute-pre-inline" and "hash-attribute-pre-inline"; and "attribute-inline" is separated in "list-attribute-inline" and "hash-attribute-inline". The only difference is that one ends with "}" and another with "]".</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">{F6188504}</span><br />
<br />
* Highlight values in Key with multiple lines. That is, when ":" is the first character of a line.<br />
<br />
* 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.<span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);"><br />
{F6188507}</span><br />
<br />
* 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. <br />
<span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">In Keys, the operator "?" now it is highlighted with the "Operator" attribute.</span><span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">{F6188508}</span><br />
<br />
* Add escapes [2]. <span style="padding: 0 2px; color: #333333; background: rgba(251, 175, 175, .7);">Single quote strings admit only one type of escape: `''`. </span>Also, allow escapes in keys quoted. Ex: `"key\"a": value` or 'key''a': value`.<div style="padding: 8px 0;">...</div>NOTE: Booleans, null, integers & floats require specific delimiters to avoid incorrect highlighting (for example, not highlight numbers present in sentences or dates). For that reason I use several RegExpr instead of keywords or other rules.<br />
<br />
<span style="padding: 0 2px; color: #333333; background: rgba(151, 234, 151, .6);">{F6188509}<br />
<br />
Although there are still things to be corrected! Lines with literal/folded style (after "|" or ">") are not highlighted correctly. <br />
Ex:<br />
```<br />
key1: <br />
- key2: |<br />
Literal characters " ' { }<br />
Literal...<br />
- key 3: value<br />
```<br />
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.<br />
</span><br />
**References:**<div style="padding: 8px 0;">...</div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R216 Syntax Highlighting</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D14760">https://phabricator.kde.org/D14760</a></div></div><br /><div><strong>To: </strong>nibags, dhaumann, cullmann, Framework: Syntax Highlighting<br /><strong>Cc: </strong>kwrite-devel, kde-frameworks-devel, michaelh, kevinapavew, ngraham, bruns, demsking, cullmann, sars, dhaumann<br /></div>