# Injected language tags that sorounds base code

**URL:** <https://platform.jetbrains.com/t/injected-language-tags-that-sorounds-base-code/490>\
**Category:** IntelliJ Platform\
**Tags:** language-injection\
**Created:** [February 13, 2025, 1:37pm UTC](https://platform.jetbrains.com/t/injected-language-tags-that-sorounds-base-code/490 "2025-02-13T13:37:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![johan.t.martinson](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/johan.t.martinson/32/302_2.png) [@johan.t.martinson](https://platform.jetbrains.com/u/johan.t.martinson)\
**Post date:** [February 13, 2025, 1:37pm UTC](https://platform.jetbrains.com/t/injected-language-tags-that-sorounds-base-code/490/1 "2025-02-13T13:37:19Z")

</div>

Hi,  
I am trying to inject a language in comments that have matching start and end tags like similar to xml.

Example:

```auto
// &begin[*name*]
some code 
// &end[*name*]

```

Where begin and end matches if the name is the same and otherwise do not. Is it possible to do such a thing with injection?

---

<div class="post-metadata">

**Author:** ![karol.lewandowski](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/karol.lewandowski/32/66_2.png) [@karol.lewandowski](https://platform.jetbrains.com/u/karol.lewandowski)\
**Post date:** [February 13, 2025, 1:57pm UTC](https://platform.jetbrains.com/t/injected-language-tags-that-sorounds-base-code/490/3 "2025-02-13T13:57:44Z")

</div>

Hi Johan,  
Depending on your PSI, you can use one of the APIs described on [IntelliJ Platform Plugin SDK Documentation: Language Injection](https://plugins.jetbrains.com/docs/intellij/language-injection.html).  
If the comment content has a separate representation in PSI, then [`LanguageInjectionContributor`](https://github.com/JetBrains/intellij-community/tree/idea/243.24978.46/platform/core-api/src/com/intellij/lang/injection/general/LanguageInjectionContributor.java) should be enough.  
If not, try [`LanguageInjectionPerformer`](https://github.com/JetBrains/intellij-community/tree/idea/243.24978.46/platform/core-api/src/com/intellij/lang/injection/general/LanguageInjectionPerformer.java).

---

<div class="post-metadata">

**Author:** ![johan.t.martinson](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/johan.t.martinson/32/302_2.png) [@johan.t.martinson](https://platform.jetbrains.com/u/johan.t.martinson)\
**Post date:** [February 13, 2025, 2:01pm UTC](https://platform.jetbrains.com/t/injected-language-tags-that-sorounds-base-code/490/5 "2025-02-13T14:01:59Z")

</div>

Thanks! we will try that! saw that the documentation on language injection had been updated a bit since I last looked as well 🙂
