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
+30-4Lines changed: 30 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,6 +164,25 @@ 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 auto-detection](https://highlightjs.readthedocs.io/en/latest/api.html#highlightauto-value-languagesubset) to a subset using the `languageNames` prop. This can improve performance and accuracy.
170
+
171
+
```svelte
172
+
<script>
173
+
import { HighlightAuto } from "svelte-highlight";
174
+
import github from "svelte-highlight/styles/github";
Use the `LineNumbers` component to render the highlighted code with line numbers.
@@ -489,13 +508,20 @@ In the example below, the `HighlightAuto` component and injected styles are dyna
489
508
490
509
#### Props
491
510
492
-
| Name | Type | Default value |
493
-
| :------ | :-------- | :------------- |
494
-
| code |`any`| N/A (required) |
495
-
| langtag |`boolean`|`false`|
511
+
| Name | Type | Default value |
512
+
| :-------- | :--------------- | :------------- |
513
+
| code |`any`| N/A (required) |
514
+
| languages |`LanguageName[]`|`undefined`|
515
+
| langtag |`boolean`|`false`|
496
516
497
517
`$$restProps` are forwarded to the top-level `pre` element.
498
518
519
+
**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