Skip to content

Conversation

@its-miroma
Copy link
Contributor

@its-miroma its-miroma commented Nov 3, 2025

Description

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 including files, which caused confusion.

Since this feature has been requested by VitePress directly, I don't think there's any point in trying to fix the plugin any further.

Linked Issues

fix #3690

Additional Context

Footnotes

  1. https://github.com/fabioaanthony/markdown-it-vuepress-code-snippet-enhanced/issues/7

  2. https://discord.com/channels/507304429255393322/1208846408552030238/1407245292482330695 via https://discord.gg/v6v4pMv

  3. https://github.com/IMB11/md-it-enhanced-snippets

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 including files, which caused confusion.

Since this feature has been requested by VitePress directly, I don't
think there's any point in trying to fix 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.gg/v6v4pMv>
[^3]: <https://github.com/IMB11/md-it-enhanced-snippets>
@its-miroma
Copy link
Contributor Author

/publish

@its-miroma
Copy link
Contributor Author

its-miroma commented Nov 5, 2025

Sorry for the mention @brc-dd.

  • I do not know what's happening with the publish command; I tried to get a preview out for testing but that does not seem to work
  • I'd also be interested in tackling Including non-existent regions includes entire file content #4625, if you could confirm that the behavior described there is what you'd expect (I would)
  • Is there anything else you'd like me to do before this gets any further?

I could also take a look at #1051, by making sure @[]() work either like <<< OR like @include

Outdated
  • personally, I think the @[]() syntax should behave like <<< EXCEPT with Markdown files
  • to import a Markdown file as a code block, you can just put the @[]() inside a code block
  • VitePress 2.0 would be a great time for such a breaking change

Actually, reviewing the original plugin a little, I think it's better to keep the current syntax <<<:

  • all of @[]()'s options are supported by <<< except:
  • the @[]() is more verbose anyway

So I'd suggest the following, but possibly for another PR:

  • deprecate @include, replaced with <<< which does not create a code block for Markdown files
    • to import a Markdown file in a code block, put <<< in a code block
  • add support for multiple line ranges in the <<< syntax, without conflicting with highlighting
  • there is not enough demand for transcludeTag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi region snippet support

2 participants