Skip to content

Commit

Permalink
Support nested comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaz1502 committed Feb 5, 2025
1 parent 96511fe commit 22b7540
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions mode/lean/lean.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,19 @@
token: function(stream, state) {
if (stream.eatSpace()) return null;

if (state.inComment) {
if (stream.match(/.*?-\//)) {
state.inComment = false;
if (state.commentLevel > 0) {
if (stream.match(/.*?\/-/)) {
state.commentLevel += 1;
} else if (stream.match(/.*?-\//)) {
state.commentLevel -= 1;
} else {
stream.skipToEnd();
}
return "comment";
}


if (state.inComment) {
if (stream.match(/-\//)) {
state.inComment = false;
}
return "comment";
}

if (stream.match(/\/-/)) {
state.inComment = true;
state.commentLevel += 1;
return "comment";
}

Expand Down Expand Up @@ -99,7 +93,7 @@
return null;
},
startState: function() {
return { inDefinition: false, inComment: false };
return { inDefinition: false, commentLevel: 0 };
}
};
});
Expand Down

0 comments on commit 22b7540

Please sign in to comment.