Skip to content

Commit 840464b

Browse files
authored
[pascal mode] Add highlighting for comments with curly brackets
See codemirror#5523
1 parent 84a02bc commit 840464b

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

mode/pascal/pascal.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ CodeMirror.defineMode("pascal", function() {
5050
state.tokenize = tokenComment;
5151
return tokenComment(stream, state);
5252
}
53-
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
53+
if (ch == "{") {
54+
state.tokenize = tokenCommentBraces;
55+
return tokenCommentBraces(stream, state);
56+
}
57+
if (/[\[\]\(\),;\:\.]/.test(ch)) {
5458
return null;
5559
}
5660
if (/\d/.test(ch)) {
@@ -98,6 +102,17 @@ CodeMirror.defineMode("pascal", function() {
98102
return "comment";
99103
}
100104

105+
function tokenCommentBraces(stream, state) {
106+
var ch;
107+
while (ch = stream.next()) {
108+
if (ch == "}") {
109+
state.tokenize = null;
110+
break;
111+
}
112+
}
113+
return "comment";
114+
}
115+
101116
// Interface
102117

103118
return {

0 commit comments

Comments
 (0)