fix(md)!: change behavior of regions in snippets#5014
Open
its-miroma wants to merge 4 commits intovuejs:mainfrom
Open
fix(md)!: change behavior of regions in snippets#5014its-miroma wants to merge 4 commits intovuejs:mainfrom
its-miroma wants to merge 4 commits intovuejs:mainfrom
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
commit: |
Contributor
Author
|
I hope this PR can get some reviews. I'd also want to make the following breaking changes, but possibly for another PR:
|
0e2e16a to
c19b76a
Compare
317f38b to
2d0695b
Compare
its-miroma
commented
Feb 12, 2026
its-miroma
added a commit
to its-miroma/fmc
that referenced
this pull request
Mar 16, 2026
its-miroma
added a commit
to its-miroma/fmc
that referenced
this pull request
Mar 16, 2026
its-miroma
added a commit
to its-miroma/fmc
that referenced
this pull request
Mar 16, 2026
its-miroma
added a commit
to its-miroma/fmc
that referenced
this pull request
Mar 16, 2026
its-miroma
added a commit
to its-miroma/fmc
that referenced
this pull request
Mar 22, 2026
its-miroma
added a commit
to its-miroma/fmc
that referenced
this pull request
Mar 22, 2026
its-miroma
added a commit
to its-miroma/fmc
that referenced
this pull request
Mar 22, 2026
its-miroma
added a commit
to its-miroma/fmc
that referenced
this pull request
Mar 22, 2026
its-miroma
added a commit
to its-miroma/fmc
that referenced
this pull request
Mar 22, 2026
its-miroma
added a commit
to its-miroma/fmc
that referenced
this pull request
Mar 23, 2026
* 'migration' (early part): apply some manual fixes the migration script drop mention of transclusions fix: transclusions from FabricMC#415 feat: apply vuejs/vitepress#5014 chore: set minimumReleaseAge to 3 days chore: migrate to pnpm
its-miroma
added a commit
to its-miroma/fmc
that referenced
this pull request
Mar 24, 2026
its-miroma
added a commit
to FabricMC/fabric-docs
that referenced
this pull request
Mar 25, 2026
* chore: migrate to pnpm * chore: set minimumReleaseAge to 3 days * feat: apply vuejs/vitepress#5014 * fix: transclusions from #415
15a0278 to
09af6c7
Compare
its-miroma
commented
Mar 29, 2026
| * Remove all #region markers when including snippets | ||
| * @default false | ||
| */ | ||
| stripMarkersFromSnippets?: boolean |
Contributor
Author
There was a problem hiding this comment.
Maybe I should add a configurable mutateSnippet(regions: string[], context: ...) function, that will be run for every snippet. Some use cases:
- Stripping imports from all snippets
- Replacing comments with translated versions
- Adding
// :::at region cuts - Adding a comment at the top with the full file path
VitePress supports including a part of a file through a VS Code region. However, when multiple regions have the same name, only one is included. The workaround plugin suggested in vuejs#3690 is no longer maintained. [^1] Furthermore, it suffers from a memory leak causing huge RAM usage. [^2] While we at Fabric Docs have forked the plugin [^3] to fix some issues, it still feels fragile. Another problem is having to use two different syntaxes (`<<<` vs `@[]()`) for doing the same thing, causing confusion. Since this feature has been requested by VitePress directly, I don't think there's any point in working on the plugin any further. fix vuejs#3690 [^1]: <fabioaanthony/markdown-it-vuepress-code-snippet-enhanced#7> [^2]: <https://discord.com/channels/507304429255393322/1208846408552030238/1407245292482330695> via <https://discord.fabricmc.net/> [^3]: <https://github.com/IMB11/md-it-enhanced-snippets>
when a region is not in the source file, instead of including the whole file, warn that the #region was not found in it. fix vuejs#4625
if `stripMarkersFromSnippets` is set, `<<<` snippets will strip out all
region markers:
```file.ts
// #region A
// #region B
console.log("Hello, World!");
// #endregion
// #endregion
```
<<< file.ts#A
...would not include "#region B" anymore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Rationale
VitePress supports including a part of a file through a VS Code region. However, when multiple regions have the same name, only one is included.
The workaround plugin suggested in #3690 is no longer maintained. 1 Furthermore, it suffers from a memory leak causing huge RAM usage. 2
While we at Fabric Docs have forked the plugin 3 to fix some issues, it still feels fragile.
Another problem is having to use two different syntaxes (
<<<vs@[]()) for doing the same thing, causing confusion.Since this feature has been requested by VitePress directly, I don't think there's any point in working on the plugin any further.
Linked Issues
fix #3690
fix #4625
Additional Context
Footnotes
https://github.com/fabioaanthony/markdown-it-vuepress-code-snippet-enhanced/issues/7 ↩
https://discord.com/channels/507304429255393322/1208846408552030238/1407245292482330695 via https://discord.fabricmc.net/ ↩
https://github.com/IMB11/md-it-enhanced-snippets ↩