Skip to content

Commit f4cb4d1

Browse files
vranamarijnh
authored andcommitted
[soy mode] Ignore comments in {literal}
1 parent 6287b22 commit f4cb4d1

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

mode/soy/soy.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,13 @@
149149
return "string";
150150
}
151151

152-
if (stream.match(/^\/\*/)) {
153-
state.soyState.push("comment");
154-
return "comment";
155-
} else if (stream.match(stream.sol() || (state.soyState.length && last(state.soyState) != "literal") ? /^\s*\/\/.*/ : /^\s+\/\/.*/)) {
156-
return "comment";
152+
if (!state.soyState.length || last(state.soyState) != "literal") {
153+
if (stream.match(/^\/\*/)) {
154+
state.soyState.push("comment");
155+
return "comment";
156+
} else if (stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/)) {
157+
return "comment";
158+
}
157159
}
158160

159161
switch (last(state.soyState)) {

mode/soy/test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,7 @@
111111
MT('single-quote-strings',
112112
'[keyword {][string "foo"] [string \'bar\'][keyword }]',
113113
'');
114+
115+
MT('literal-comments',
116+
'[keyword {literal}]/* comment */ // comment[keyword {/literal}]');
114117
})();

0 commit comments

Comments
 (0)