ejs-grammar icon indicating copy to clipboard operation
ejs-grammar copied to clipboard

Fix multiline EJS syntax highlighting

Open Copilot opened this issue 3 months ago • 0 comments

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-line and tag-ejs-multi-line into a single tag-ejs pattern
  • 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 `
    @Betanu701 I don't use ejs much anymore. But if you/or someone does provide a pull request, I would be happy to pull it in!
    • 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.

    Copilot avatar Nov 25 '25 01:11 Copilot