Fix multiline EJS syntax highlighting
Multiline EJS blocks break syntax highlighting for all subsequent HTML content after the closing %>.
<%
for (let i = 0; i < arr.length; i++) {
const val = arr[i];
%>
<%= val %> <!-- This and everything after was broken -->
<% } %>
</li>
Changes
-
Unified EJS pattern: Merged
tag-ejs-single-lineandtag-ejs-multi-lineinto a singletag-ejspattern - Simplified regex: Removed complex lookahead that required closing tag on same line as begin pattern
-
Standard scope names: Updated to
punctuation.section.embedded.begin/end.ejs
The previous approach had two overlapping patterns with a complex single-line regex that attempted to capture content AND verify the closing tag position in the begin pattern—similar to how the working Atom EJS grammar handles it with simple begin/end pairs.
Original prompt
This section details on the original issue you should resolve
<issue_title>Multiline ejs messes up syntax highlighting</issue_title> <issue_description>```ejs
``` Everything after the first closing tag
%>has messed up syntax highlighting</issue_description>Comments on the Issue (you are @copilot in this section)
@ Anyone come up with any solution to this? My goal is just to be able to have multiple lines between EJS tags, for instance: ``` { var x = p.number + 1; … %> ``` As shown in my screenshot below, this currently breaks syntax highlighting (notice the closing `` and `` tags are black, and the JS in the `
- Fixes Digitalbrainstem/ejs-grammar#61
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.