[gtksourceview/gtksourceview-4-2] yaml.lang: improve detection of block scalars



commit fd4a06fb1ba8fa57036976d7785c59b106e308cb
Author: Роман Донченко <dpb corrigendum ru>
Date:   Mon Apr 29 03:24:42 2019 +0300

    yaml.lang: improve detection of block scalars
    
    Allow chomping indicators, indentation indicators, trailing whitespace
    and a trailing comment on the line with the block scalar indicator.
    See the YAML 1.2 spec, section 8.1.1.
    
    Unfortunately, we can't use the indentation indicator to determine which of
    the following lines to include in the scalar, so a block scalar with an
    indentation indicator will still be highlighted incorrectly overall, unless the
    indicator is redundant.

 data/language-specs/yaml.lang | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/data/language-specs/yaml.lang b/data/language-specs/yaml.lang
index 7aca3c99..4f52f8b6 100644
--- a/data/language-specs/yaml.lang
+++ b/data/language-specs/yaml.lang
@@ -48,8 +48,15 @@
     <define-regex id="rschar">[\s\]\},]</define-regex>
 
     <context id="scalar" class-disabled="no-spell-check">
-      <start>(?&lt;=^|\s)[|&gt;]$</start>
+      <start extended="true">
+        (?&lt;= ^ | \s)
+        [|&gt;] # block scalar indicator
+        (?: [-+]?[0-9]? | [0-9]?[-+]?) # optional indentation and chomping indicators
+        (?: \s+ (\#.*)?)? # optional whitespace and comment
+        $
+      </start>
       <include>
+        <context sub-pattern="1" where="start" style-ref="comment"/>
         <context end-parent="true" style-ref="scalar">
           <start>^(?'indent'\s+)</start>
           <end>^(?!\%{indent@start})</end>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]