Skip to content

Commit 9dbb49b

Browse files
committed
docs: update documentation
1 parent 28e902f commit 9dbb49b

32 files changed

+115
-1581
lines changed

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ This component exports `highlight.js` themes in JavaScript. Import the theme fro
6262
```svelte
6363
<script>
6464
import Highlight from "svelte-highlight";
65-
import typescript from "svelte-highlight/src/languages/typescript";
66-
import github from "svelte-highlight/src/styles/github";
65+
import typescript from "svelte-highlight/languages/typescript";
66+
import github from "svelte-highlight/styles/github";
6767
6868
const code = "const add = (a: number, b: number) => a + b;";
6969
</script>
@@ -82,8 +82,8 @@ Depending on your set-up, importing a CSS StyleSheet in Svelte may require a CSS
8282
```svelte
8383
<script>
8484
import { Highlight } from "svelte-highlight";
85-
import typescript from "svelte-highlight/src/languages/typescript";
86-
import "svelte-highlight/src/styles/github.css";
85+
import typescript from "svelte-highlight/languages/typescript";
86+
import "svelte-highlight/styles/github.css";
8787
8888
const code = "const add = (a: number, b: number) => a + b;";
8989
</script>
@@ -98,9 +98,9 @@ Use the `HighlightSvelte` component for Svelte syntax highlighting.
9898
```svelte
9999
<script>
100100
import { HighlightSvelte } from "svelte-highlight";
101-
import github from "svelte-highlight/src/styles/github";
101+
import github from "svelte-highlight/styles/github";
102102
103-
$: code = "<button on:click={() => (count += 1)}>Increment {count}</button>";
103+
$: code = `<button on:click={() => { console.log(0); }}>Increment {count}</button>`;
104104
</script>
105105
106106
<svelte:head>
@@ -114,10 +114,14 @@ Use the `HighlightSvelte` component for Svelte syntax highlighting.
114114

115115
The `HighlightAuto` component invokes the `highlightAuto` API from `highlight.js`.
116116

117+
Note that auto-highlighting will result in a larger bundle size in order to infer a language.
118+
119+
Prefer to specify a language if possible.
120+
117121
```svelte
118122
<script>
119123
import { HighlightAuto } from "svelte-highlight";
120-
import github from "svelte-highlight/src/styles/github";
124+
import github from "svelte-highlight/styles/github";
121125
122126
$: code = `body {\n padding: 0;\n color: red;\n}`;
123127
</script>
@@ -233,7 +237,7 @@ Refer to the highlight.js [language definition guide](https://highlightjs.readth
233237

234238
Svelte version 3.31 or greater is required to use this component with TypeScript.
235239

236-
TypeScript definitions are located in the [src folder](./src).
240+
TypeScript definitions are auto-generated by SvelteKit.
237241

238242
## [Supported Languages](SUPPORTED_LANGUAGES.md)
239243

demo/lib/ScopedStyle.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
99
$: code = `<script>
1010
import Highlight from "svelte-highlight";
11-
import typescript from "svelte-highlight/src/languages/typescript";
11+
import typescript from "svelte-highlight/languages/typescript";
1212
${
1313
useInjectedStyles
14-
? `import ${moduleName} from "svelte-highlight/src/styles/${name}";`
15-
: `import "svelte-highlight/src/styles/${name}.css";`
14+
? `import ${moduleName} from "svelte-highlight/styles/${name}";`
15+
: `import "svelte-highlight/styles/${name}.css";`
1616
}
1717
1818
const code = "const add = (a: number, b: number) => a + b;";

demo/lib/ScopedStyleAuto.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
$: code = `<script>
99
import { HighlightAuto } from "svelte-highlight";
10-
import ${moduleName} from "svelte-highlight/src/styles/${name}";
10+
import ${moduleName} from "svelte-highlight/styles/${name}";
1111
1212
const code = ".body { padding: 0; margin: 0; }";
1313
<\/script>

demo/lib/ScopedStyleSvelte.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
$: code = `<script>
99
import { HighlightSvelte } from "svelte-highlight";
10-
import ${moduleName} from "svelte-highlight/src/styles/${name}";
10+
import ${moduleName} from "svelte-highlight/styles/${name}";
1111
1212
const code = \`<button on:click={() => { console.log(0); }}>Click me</button>\`;
1313
<\/script>

demo/routes/index.svelte

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,20 @@
9898
</Row>
9999

100100
<p class="mb-5">
101-
Refer to the <Link
101+
For example set-ups, refer to <Link
102102
inline
103103
size="lg"
104104
rel="external"
105105
href="https://github.com/metonym/svelte-highlight/tree/master/examples/sveltekit"
106106
>
107-
SvelteKit example set-up
107+
examples/sveltekit
108+
</Link> or <Link
109+
inline
110+
size="lg"
111+
rel="external"
112+
href="https://github.com/metonym/svelte-highlight/tree/master/examples/vite"
113+
>
114+
examples/vite
108115
</Link>.
109116
</p>
110117
</Column>
@@ -193,6 +200,10 @@
193200
<code class="code">highlightAuto</code>
194201
API from <code class="code">highlight.js</code>.
195202
</p>
203+
<p>
204+
Note that auto-highlighting will result in a larger bundle size in order
205+
to infer a language. Prefer to specify a language if possible.
206+
</p>
196207
</Column>
197208
<Column noGutter xlg={12}>
198209
<ScopedStyleAuto name="atom-one-dark" moduleName="atomOneDark" />
@@ -299,13 +310,7 @@
299310
TypeScript.
300311
</p>
301312
<p class="mb-5">
302-
TypeScript definitions are located in the <Link
303-
inline
304-
size="lg"
305-
rel="external"
306-
href="https://github.com/metonym/svelte-highlight/tree/master/src"
307-
>src folder in the GitHub repository</Link
308-
>.
313+
TypeScript definitions are auto-generated by SvelteKit.
309314
</p>
310315
</Column>
311316
</Row>

demo/routes/languages.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import Highlight from "svelte-highlight";
2525
import ${
2626
useDirectImport ? moduleName : `{ ${moduleName} }`
27-
} from "svelte-highlight/src/languages${useDirectImport ? `/${name}` : ""}";
27+
} from "svelte-highlight/languages${useDirectImport ? `/${name}` : ""}";
2828
<\/script>
2929
3030
<Highlight language={${moduleName}} code="code" />`;

examples/rollup-typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"rollup-plugin-terser": "^7.0.2",
1616
"svelte": "^3.46.4",
1717
"svelte-check": "2.4.6",
18-
"svelte-highlight": "^5.3.2",
18+
"svelte-highlight": "^6.0.0",
1919
"svelte-preprocess": "^4.10.4",
2020
"tslib": "^2.3.1",
2121
"typescript": "^4.6.3"

examples/rollup-typescript/public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
56
</head>
67
<body>
78
<script src="build/bundle.js"></script>

examples/rollup-typescript/src/App.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import { Highlight, HighlightAuto } from "svelte-highlight";
3-
import typescript from "svelte-highlight/src/languages/typescript";
4-
import atomOneDark from "svelte-highlight/src/styles/atom-one-dark";
3+
import typescript from "svelte-highlight/languages/typescript";
4+
import atomOneDark from "svelte-highlight/styles/atom-one-dark";
55
66
const code = "const add = (a: number, b: number) => a + b;";
77
</script>

examples/rollup-typescript/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,10 +725,10 @@ [email protected]:
725725
svelte-preprocess "^4.0.0"
726726
typescript "*"
727727

728-
svelte-highlight@^5.3.2:
729-
version "5.3.2"
730-
resolved "https://registry.yarnpkg.com/svelte-highlight/-/svelte-highlight-5.3.2.tgz#d58f819d8c94a6a8e71691d60a4d0cfb6d1d3921"
731-
integrity sha512-a9FbXm9oXkoUzLZxGaOpi/UZXxt2tO2+TTRQYtz+UpOFbbRGeZx7zG53QHwv7cpT+/kY10sc6VLZGzjBJviv6w==
728+
svelte-highlight@^6.0.0:
729+
version "6.0.0"
730+
resolved "https://registry.yarnpkg.com/svelte-highlight/-/svelte-highlight-6.0.0.tgz#be499b866a318a2a7d751372a904703597cf0b84"
731+
integrity sha512-ug+7lfrj25QThSXyT9bOJEt9UXk7eEtAIWi/hBiO21FKNLfl46NVUmFTyuMtIDVQ/mu/8zkfwBvMOfL8BNJujA==
732732
dependencies:
733733
highlight.js "11.5.0"
734734

0 commit comments

Comments
 (0)