Skip to content

Unescaped code blocks syntax highlight doesn't work #4300

@salazarr-js

Description

@salazarr-js

Describe the bug

When using Unescaped code blocks with the content coming from a string variable or a data loader, the code blocks aren't highlighted

```ts-vue
{{ scriptString }}
```

```ts-vue
{{ scriptData }}
```

<script setup lang="ts">
import { data } from './examples.data'

const scriptData = data

const scriptString = `
/** Generate a greet message with a provided text */
function greet(text) {
  return \`Hello, \${text}\`;
}

console.log(greet('world'));
`
</script>

Reproduction

https://stackblitz.com/edit/vite-ucyboc?file=docs%2Fexamples%2Ftest-example.md

Expected behavior

image

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
    Memory: 16.46 GB / 31.91 GB
  Binaries:
    Node: 20.17.0 - ~\AppData\Local\fnm_multishells\29352_1729538469442\node.EXE
    npm: 10.8.2 - ~\AppData\Local\fnm_multishells\29352_1729538469442\npm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.86)
    Internet Explorer: 11.0.22621.3527


### Additional context

_No response_

### Validations

- [X] Check if you're on the [latest VitePress version](https://github.com/vuejs/vitepress/releases/latest).
- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)
- [X] Read the [docs](https://vitepress.dev).
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions