You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-4Lines changed: 32 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,6 +164,27 @@ The `HighlightAuto` component uses the [highlightAuto API](https://highlightjs.r
164
164
<HighlightAuto {code} />
165
165
```
166
166
167
+
### Limiting Language Detection
168
+
169
+
You can restrict language detection to a specific subset using the `languages` prop. This can improve performance and accuracy by limiting the languages considered during auto-detection.
170
+
171
+
See the [highlight.js documentation on language subset restriction](https://highlightjs.readthedocs.io/en/latest/api.html#highlightauto-value-languagesubset) for more details.
172
+
173
+
```svelte
174
+
<script>
175
+
import { HighlightAuto } from "svelte-highlight";
176
+
import github from "svelte-highlight/styles/github";
Use the `LineNumbers` component to render the highlighted code with line numbers.
@@ -489,13 +510,20 @@ In the example below, the `HighlightAuto` component and injected styles are dyna
489
510
490
511
#### Props
491
512
492
-
| Name | Type | Default value |
493
-
| :------ | :-------- | :------------- |
494
-
| code |`any`| N/A (required) |
495
-
| langtag |`boolean`|`false`|
513
+
| Name | Type | Default value |
514
+
| :-------- | :--------------- | :------------- |
515
+
| code |`any`| N/A (required) |
516
+
| languages |`LanguageName[]`|`undefined`|
517
+
| langtag |`boolean`|`false`|
496
518
497
519
`$$restProps` are forwarded to the top-level `pre` element.
498
520
521
+
**Note:**`LanguageName` is a union type of all supported language names, providing autocomplete and type safety. You can import it from `svelte-highlight`:
0 commit comments