GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit a9c777c9 authored by Роман Донченко's avatar Роман Донченко Committed by Christian Hergert

yaml.lang: improve the highlighting of quoted strings

* Allow them to be multiline.

* Add highlighting for escape sequences. This necessitates splitting
  the "string" context into "single-quoted-string" and
  "double-quoted-string", as the escaping rules are different.

* Allow empty quoted strings ("") to be highlighted correctly. The previous
  end regex prevented the closing quote in this case to be recognized
  as such, as it required it to be preceded by at least one character.
parent d53e1abb
......@@ -29,6 +29,8 @@
<style id="scalar" name="Block literal" map-to="def:string"/>
<style id="comment" name="Comment" map-to="def:comment"/>
<style id="string" name="String" map-to="def:string"/>
<style id="escape-sequence"
name="Escape sequence" map-to="def:special-char"/>
<style id="anchor" name="Anchor" map-to="def:identifier"/>
<style id="tag" name="Tag" map-to="def:preprocessor"/>
<style id="alias" name="Alias" map-to="def:type"/>
......@@ -79,9 +81,32 @@
<match>(?&lt;=^|\s)&amp;\%{ischar}+(?=$|\s)</match>
</context>
<context id="string" end-at-line-end="true" style-ref="string" class-disabled="no-spell-check">
<start>(?&lt;=^|\%{lschar})(?'q'["'])</start>
<end>[^\\]\%{q@start}</end>
<context id="double-quoted-string" style-ref="string" class-disabled="no-spell-check">
<start>(?&lt;=^|\%{lschar})"</start>
<end>"</end>
<include>
<context style-ref="escape-sequence">
<match extended="true">
\\ (?:
[0abt\tnvfre "/\\N_LP] |
x [0-9a-fA-F]{2} |
u [0-9a-fA-F]{4} |
U [0-9a-fA-F]{8} |
$
)
</match>
</context>
</include>
</context>
<context id="single-quoted-string" style-ref="string" class-disabled="no-spell-check">
<start>(?&lt;=^|\%{lschar})'</start>
<end>'</end>
<include>
<context style-ref="escape-sequence">
<match>''</match>
</context>
</include>
</context>
<context id="unquoted-string" end-at-line-end="true" style-ref="string" class-disabled="no-spell-check">
......@@ -140,7 +165,8 @@
<context ref="alias"/>
<context ref="tag"/>
<context ref="anchor"/>
<context ref="string"/>
<context ref="single-quoted-string"/>
<context ref="double-quoted-string"/>
<context ref="inline-null"/>
<context ref="inline-bool"/>
<context ref="inline-int"/>
......@@ -162,7 +188,8 @@
<context ref="alias"/>
<context ref="tag"/>
<context ref="anchor"/>
<context ref="string"/>
<context ref="single-quoted-string"/>
<context ref="double-quoted-string"/>
<context ref="inline-null"/>
<context ref="inline-bool"/>
<context ref="inline-int"/>
......@@ -223,7 +250,8 @@
<context ref="alias"/>
<context ref="tag"/>
<context ref="anchor"/>
<context ref="string"/>
<context ref="single-quoted-string"/>
<context ref="double-quoted-string"/>
<context ref="map"/>
<context ref="unquoted-string"/>
</include>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment