Skip to content

Fix multiline EJS syntax highlighting#106

Draft
Copilot wants to merge 3 commits into
masterfrom
copilot/fix-ejs-syntax-highlighting
Draft

Fix multiline EJS syntax highlighting#106
Copilot wants to merge 3 commits into
masterfrom
copilot/fix-ejs-syntax-highlighting

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 25, 2025

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

  • <% for (let i = 0; i < arr.length; i++) { const val = arr[i]; %> <%= val %> <% } %>
  • ```

    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: ``` <% entries.forEach(p => { 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 `<script>` tag is also affected).

    Atom’s EJS extension language-ejs does not have this problem. I started down the rabbit hole of how to make/edit these extensions in hopes of fixing it, but it’s quite a deep hole…

    FWIW, here is the .tmLanguage file the Atom extension was converted from:
    GitHub > GregoryM > EJS TM > JS Template Syntax

    BA69AAF5-FB2D-45D4-A0C9-25F32E57C9A6

    @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!

    ✨ 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 AI and others added 2 commits November 25, 2025 01:21
    Co-authored-by: Betanu701 <5798012+Betanu701@users.noreply.github.com>
    Co-authored-by: Betanu701 <5798012+Betanu701@users.noreply.github.com>
    Copilot AI changed the title [WIP] Fix multiline EJS syntax highlighting issues Fix multiline EJS syntax highlighting Nov 25, 2025
    Copilot AI requested a review from Betanu701 November 25, 2025 01:32
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    Multiline ejs messes up syntax highlighting

    2 participants