Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 14, 2025

The HTML/XML endregion regex incorrectly matched region instead of endregion, breaking snippet extraction for HTML files. The agent instructions requested syncing the entire region matching algorithm with VitePress.

Changes

  • Fixed HTML/XML endregion pattern: Changed /^<!-- #?region[\s\w*-]*-->$/ to /^\s*<!--\s*#?endregion\b\s*(.*?)\s*-->/

  • Replaced regionRegexps array with VitePress markers structure:

    • Organized as objects with explicit start/end properties
    • More flexible whitespace matching (\s* vs strict spacing)
    • Added Pascal comment marker support (* *)
  • Updated findRegion() with counter-based nesting:

    • Handles same-named nested regions correctly
    • Supports empty region names on end markers as fallback
    • Changed return structure from {start, end, regexp} to {re, start, end}
  • Updated region filtering: Now filters using both region.re.start and region.re.end instead of single region.regexp

Example

HTML regions now work correctly:

<!-- #region main -->
<div>Content</div>
<!-- #endregion main -->

Nested regions with same name are properly handled:

// #region test
function outer() {
  // #region test
  function inner() {}
  // #endregion test
}
// #endregion test

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.cypress.io
    • Triggering command: node index.js --exec install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>end region marker for html/xml should be #endregion</issue_title>
<issue_description>
the endregion marker in the regex for html/xml is #region

[/^<!-- #?region ([\w*-]+) -->$/, /^<!-- #?region[\s\w*-]*-->$/],

i think it should be #endregion, at least this is what vscode expects.

</issue_description>

<agent_instructions>Please update the whole region matching algorithm according to the latest https://github.com/vuejs/vitepress/blob/main/src/node/markdown/plugins/snippet.ts. (don't come up with your own!)</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@netlify
Copy link

netlify bot commented Nov 14, 2025

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 609b744
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/691701786103980008197607
😎 Deploy Preview https://deploy-preview-2349--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI and others added 3 commits November 14, 2025 10:03
- Replace old regionRegexps array with new markers array
- Fix HTML/XML endregion bug (now uses #endregion instead of #region)
- Add support for nested regions with counter logic
- Update region filtering to use region.re.start and region.re.end
- Add test fixtures for HTML and nested JS regions

Co-authored-by: kermanx <63178754+kermanx@users.noreply.github.com>
The regex patterns in the markers array are directly from VitePress
and are intentional. Disable the regexp/no-super-linear-backtracking
rule for this section to match the VitePress source.

Co-authored-by: kermanx <63178754+kermanx@users.noreply.github.com>
- Add test for HTML region with #region marker
- Add test for HTML region without # marker
- Add test for nested JavaScript regions
- Manually validated all tests pass correctly

Co-authored-by: kermanx <63178754+kermanx@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix endregion marker for HTML/XML regex Fix HTML/XML endregion marker and sync region matching with VitePress Nov 14, 2025
Copilot AI requested a review from kermanx November 14, 2025 10:09
Copilot finished work on behalf of kermanx November 14, 2025 10:09
@kermanx kermanx changed the title Fix HTML/XML endregion marker and sync region matching with VitePress fix: update region marker patterns Nov 14, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 14, 2025

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/client@2349

create-slidev

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev@2349

create-slidev-theme

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev-theme@2349

@slidev/parser

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/parser@2349

@slidev/cli

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/cli@2349

@slidev/types

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/types@2349

commit: 609b744

@kermanx kermanx marked this pull request as ready for review November 14, 2025 10:16
@antfu antfu merged commit 6a7c10c into main Nov 18, 2025
21 checks passed
@antfu antfu deleted the copilot/fix-endregion-marker-html-xml branch November 18, 2025 04:29
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.

end region marker for html/xml should be #endregion

3 participants