Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #48 from atom/wl-directives
Browse files Browse the repository at this point in the history
Tokenize ---
  • Loading branch information
Wliu authored Jun 24, 2016
2 parents 9f55beb + 669b2df commit 1f5bd16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion grammars/yaml.cson
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'sublime-syntax'
'Boxfile'
]
'firstLineMatch': '^#cloud-config'
'firstLineMatch': '^(#cloud-config|---)'
'patterns': [
{
'include': '#erb'
Expand All @@ -20,6 +20,10 @@
'match': '\\t+'
'name': 'invalid.illegal.whitespace.yaml'
}
{
'match': '^---'
'name': 'punctuation.definition.directives.end.yaml'
}
{
'begin': '^(\\s*)(?!-\\s*)(\\S+\\s*(:))\\s*(\\||>)'
'beginCaptures':
Expand Down
8 changes: 8 additions & 0 deletions spec/yaml-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,14 @@ describe "YAML grammar", ->
{tokens} = grammar.tokenizeLine "true: something"
expect(tokens[0]).toEqual value: "true", scopes: ["source.yaml", "string.unquoted.yaml", "entity.name.tag.yaml"]

describe "directives", ->
it "tokenizes directives end markers", ->
{tokens} = grammar.tokenizeLine "---"
expect(tokens[0]).toEqual value: "---", scopes: ["source.yaml", "punctuation.definition.directives.end.yaml"]

{tokens} = grammar.tokenizeLine " ---"
expect(tokens[1]).not.toEqual value: "---", scopes: ["source.yaml", "punctuation.definition.directives.end.yaml"]

describe "tabs", ->
it "marks them as invalid", ->
{tokens} = grammar.tokenizeLine "\t\ttabs:"
Expand Down

0 comments on commit 1f5bd16

Please sign in to comment.