Permalink
Browse files

[yaml mode] More precise parsing of mapping keys

Issue #1735
  • Loading branch information...
1 parent 0455491 commit 6d5a70140a5f27d58370f7913e8df726bb55b45b @marijnh marijnh committed Aug 19, 2013
Showing with 8 additions and 8 deletions.
  1. +8 −8 mode/yaml/yaml.js
View
@@ -26,14 +26,6 @@ CodeMirror.defineMode("yaml", function() {
/* array list item */
if (stream.match(/\s*-\s+/)) { return 'meta'; }
}
- /* pairs (associative arrays) -> key */
- if (!state.pair && stream.match(/^\s*([a-z0-9\._-])+(?=\s*:)/i)) {
- state.pair = true;
- state.keyCol = stream.indentation();
- return "atom";
- }
- if (state.pair && stream.match(/^:\s*/)) { state.pairStart = true; return 'meta'; }
-
/* inline pairs/lists */
if (stream.match(/^(\{|\}|\[|\])/)) {
if (ch == '{')
@@ -74,6 +66,14 @@ CodeMirror.defineMode("yaml", function() {
if (stream.match(keywordRegex)) { return 'keyword'; }
}
+ /* pairs (associative arrays) -> key */
+ if (!state.pair && stream.match(/^\s*\S+(?=\s*:($|\s))/i)) {
+ state.pair = true;
+ state.keyCol = stream.indentation();
+ return "atom";
+ }
+ if (state.pair && stream.match(/^:\s*/)) { state.pairStart = true; return 'meta'; }
+
/* nothing found, continue */
state.pairStart = false;
state.escaped = (ch == '\\');

0 comments on commit 6d5a701

Please sign in to comment.