svelte-highlight 7.1.2 → 7.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/Highlight.svelte +14 -35
- package/Highlight.svelte.d.ts +12 -61
- package/HighlightAuto.svelte +15 -35
- package/HighlightAuto.svelte.d.ts +35 -63
- package/HighlightSvelte.svelte +14 -31
- package/HighlightSvelte.svelte.d.ts +29 -50
- package/LangTag.svelte +32 -0
- package/LangTag.svelte.d.ts +233 -0
- package/LineNumbers.svelte +59 -4
- package/LineNumbers.svelte.d.ts +16 -1
- package/README.md +40 -21
- package/package.json +14 -14
- package/shared.d.ts +61 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [7.2.1](https://github.com/metonym/svelte-highlight/releases/tag/v7.2.1) - 2023-04-01
|
|
9
|
+
|
|
10
|
+
**Fixes**
|
|
11
|
+
|
|
12
|
+
- line numbers should not be covered by a solid fill, custom line background color
|
|
13
|
+
- line numbers column should not be covered by code if scrollable
|
|
14
|
+
|
|
15
|
+
## [7.2.0](https://github.com/metonym/svelte-highlight/releases/tag/v7.2.0) - 2023-02-14
|
|
16
|
+
|
|
17
|
+
**Features**
|
|
18
|
+
|
|
19
|
+
- support highlighted lines in `LineNumbers` through the `highlightedLines` prop
|
|
20
|
+
|
|
8
21
|
## [7.1.2](https://github.com/metonym/svelte-highlight/releases/tag/v7.1.2) - 2023-01-01
|
|
9
22
|
|
|
10
23
|
**Fixes**
|
package/Highlight.svelte
CHANGED
|
@@ -1,50 +1,29 @@
|
|
|
1
|
-
<script context="module">
|
|
2
|
-
</script>
|
|
1
|
+
<script context="module"></script>
|
|
3
2
|
|
|
4
3
|
<script>export let language;
|
|
5
4
|
export let code;
|
|
6
5
|
export let langtag = false;
|
|
7
6
|
import hljs from "highlight.js/lib/core";
|
|
8
7
|
import { createEventDispatcher, afterUpdate } from "svelte";
|
|
8
|
+
import LangTag from "./LangTag.svelte";
|
|
9
9
|
const dispatch = createEventDispatcher();
|
|
10
10
|
let highlighted = "";
|
|
11
11
|
afterUpdate(() => {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
if (highlighted)
|
|
13
|
+
dispatch("highlight", { highlighted });
|
|
14
14
|
});
|
|
15
|
-
$:
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
$: {
|
|
16
|
+
hljs.registerLanguage(language.name, language.register);
|
|
17
|
+
highlighted = hljs.highlight(code, { language: language.name }).value;
|
|
18
18
|
}
|
|
19
19
|
</script>
|
|
20
20
|
|
|
21
21
|
<slot {highlighted}>
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
<LangTag
|
|
23
|
+
{...$$restProps}
|
|
24
|
+
languageName={language.name}
|
|
25
|
+
{langtag}
|
|
26
|
+
{highlighted}
|
|
27
|
+
{code}
|
|
28
|
+
/>
|
|
28
29
|
</slot>
|
|
29
|
-
|
|
30
|
-
<style>
|
|
31
|
-
.langtag {
|
|
32
|
-
position: relative;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.langtag::after {
|
|
36
|
-
content: attr(data-language);
|
|
37
|
-
position: absolute;
|
|
38
|
-
top: 0;
|
|
39
|
-
right: 0;
|
|
40
|
-
padding: 1em;
|
|
41
|
-
display: flex;
|
|
42
|
-
align-items: center;
|
|
43
|
-
justify-content: center;
|
|
44
|
-
background: inherit;
|
|
45
|
-
color: inherit;
|
|
46
|
-
background: var(--langtag-background);
|
|
47
|
-
color: var(--langtag-color);
|
|
48
|
-
border-radius: var(--langtag-border-radius);
|
|
49
|
-
}
|
|
50
|
-
</style>
|
package/Highlight.svelte.d.ts
CHANGED
|
@@ -1,29 +1,13 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type {
|
|
3
|
-
export interface Language {
|
|
4
|
-
name?: string;
|
|
5
|
-
register: LanguageFn;
|
|
6
|
-
}
|
|
7
|
-
export interface Slots {
|
|
8
|
-
default: {
|
|
9
|
-
/**
|
|
10
|
-
* The highlighted HTML as a string.
|
|
11
|
-
* @example "<span>...</span>"
|
|
12
|
-
*/
|
|
13
|
-
highlighted: string;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export interface Events {
|
|
17
|
-
highlight: CustomEvent<{
|
|
18
|
-
/**
|
|
19
|
-
* The highlighted HTML as a string.
|
|
20
|
-
* @example "<span>...</span>"
|
|
21
|
-
*/
|
|
22
|
-
highlighted: string;
|
|
23
|
-
}>;
|
|
24
|
-
}
|
|
2
|
+
import type { Slots, Events } from "./shared";
|
|
25
3
|
declare const __propDef: {
|
|
26
4
|
props: {
|
|
5
|
+
code: any;
|
|
6
|
+
language: import("./languages").LanguageType<string>;
|
|
7
|
+
langtag?: boolean;
|
|
8
|
+
"--langtag-background"?: string;
|
|
9
|
+
"--langtag-color"?: string;
|
|
10
|
+
"--langtag-border-radius"?: string;
|
|
27
11
|
accesskey?: string;
|
|
28
12
|
autofocus?: boolean;
|
|
29
13
|
class?: string;
|
|
@@ -35,6 +19,7 @@ declare const __propDef: {
|
|
|
35
19
|
hidden?: boolean;
|
|
36
20
|
id?: string;
|
|
37
21
|
lang?: string;
|
|
22
|
+
part?: string;
|
|
38
23
|
placeholder?: string;
|
|
39
24
|
slot?: string;
|
|
40
25
|
spellcheck?: import("svelte/elements").Booleanish;
|
|
@@ -135,7 +120,9 @@ declare const __propDef: {
|
|
|
135
120
|
'on:beforeinput'?: import("svelte/elements").EventHandler<InputEvent, HTMLPreElement>;
|
|
136
121
|
'on:input'?: import("svelte/elements").FormEventHandler<HTMLPreElement>;
|
|
137
122
|
'on:reset'?: import("svelte/elements").FormEventHandler<HTMLPreElement>;
|
|
138
|
-
'on:submit'?: import("svelte/elements").EventHandler<Event
|
|
123
|
+
'on:submit'?: import("svelte/elements").EventHandler<Event & {
|
|
124
|
+
readonly submitter: HTMLElement;
|
|
125
|
+
}, HTMLPreElement>;
|
|
139
126
|
'on:invalid'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
140
127
|
'on:formdata'?: import("svelte/elements").EventHandler<Event & {
|
|
141
128
|
readonly formData: FormData;
|
|
@@ -225,45 +212,9 @@ declare const __propDef: {
|
|
|
225
212
|
'on:close'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
226
213
|
'on:fullscreenchange'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
227
214
|
'on:fullscreenerror'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
228
|
-
/**
|
|
229
|
-
* Specify the source code to highlight.
|
|
230
|
-
*/
|
|
231
|
-
code: any;
|
|
232
|
-
/**
|
|
233
|
-
* Provide the language grammar used to highlight the code.
|
|
234
|
-
* Import languages from `svelte-highlight/languages/*`.
|
|
235
|
-
* @example
|
|
236
|
-
* import typescript from "svelte-highlight/languages/typescript";
|
|
237
|
-
*/
|
|
238
|
-
language: Language;
|
|
239
|
-
/**
|
|
240
|
-
* Set to `true` for the language name to be
|
|
241
|
-
* displayed at the top right of the code block.
|
|
242
|
-
*
|
|
243
|
-
* Use style props to customize styles:
|
|
244
|
-
* - `--langtag-background`
|
|
245
|
-
* - `--langtag-color`
|
|
246
|
-
* - `--langtag-border-radius`
|
|
247
|
-
*
|
|
248
|
-
* @default false
|
|
249
|
-
*/
|
|
250
|
-
langtag?: boolean;
|
|
251
|
-
/**
|
|
252
|
-
* Customize the background color of the langtag.
|
|
253
|
-
*/
|
|
254
|
-
"--langtag-background"?: string;
|
|
255
|
-
/**
|
|
256
|
-
* Customize the text color of the langtag.
|
|
257
|
-
*/
|
|
258
|
-
"--langtag-color"?: string;
|
|
259
|
-
/**
|
|
260
|
-
* Customize the border radius of the langtag.
|
|
261
|
-
*/
|
|
262
|
-
"--langtag-border-radius"?: string;
|
|
263
215
|
};
|
|
264
216
|
slots: Slots;
|
|
265
|
-
|
|
266
|
-
events: Events;
|
|
217
|
+
events: Events<import("./shared").HighlightedCode>;
|
|
267
218
|
};
|
|
268
219
|
export type HighlightProps = typeof __propDef.props;
|
|
269
220
|
export type HighlightEvents = typeof __propDef.events;
|
package/HighlightAuto.svelte
CHANGED
|
@@ -1,47 +1,27 @@
|
|
|
1
|
-
<script context="module">
|
|
2
|
-
</script>
|
|
1
|
+
<script context="module"></script>
|
|
3
2
|
|
|
4
|
-
<script>
|
|
3
|
+
<script>import LangTag from "./LangTag.svelte";
|
|
4
|
+
export let code;
|
|
5
5
|
export let langtag = false;
|
|
6
6
|
import hljs from "highlight.js";
|
|
7
7
|
import { createEventDispatcher, afterUpdate } from "svelte";
|
|
8
8
|
const dispatch = createEventDispatcher();
|
|
9
9
|
let highlighted = "";
|
|
10
|
-
let language =
|
|
10
|
+
let language = void 0;
|
|
11
11
|
afterUpdate(() => {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
if (highlighted)
|
|
13
|
+
dispatch("highlight", { highlighted, language });
|
|
14
14
|
});
|
|
15
|
-
$:
|
|
15
|
+
$:
|
|
16
|
+
({ value: highlighted, language } = hljs.highlightAuto(code));
|
|
16
17
|
</script>
|
|
17
18
|
|
|
18
19
|
<slot {highlighted}>
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
<LangTag
|
|
21
|
+
{...$$restProps}
|
|
22
|
+
languageName={language}
|
|
23
|
+
{langtag}
|
|
24
|
+
{highlighted}
|
|
25
|
+
{code}
|
|
26
|
+
/>
|
|
25
27
|
</slot>
|
|
26
|
-
|
|
27
|
-
<style>
|
|
28
|
-
.langtag {
|
|
29
|
-
position: relative;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.langtag::after {
|
|
33
|
-
content: attr(data-language);
|
|
34
|
-
position: absolute;
|
|
35
|
-
top: 0;
|
|
36
|
-
right: 0;
|
|
37
|
-
padding: 1em;
|
|
38
|
-
display: flex;
|
|
39
|
-
align-items: center;
|
|
40
|
-
justify-content: center;
|
|
41
|
-
background: inherit;
|
|
42
|
-
color: inherit;
|
|
43
|
-
background: var(--langtag-background);
|
|
44
|
-
color: var(--langtag-color);
|
|
45
|
-
border-radius: var(--langtag-border-radius);
|
|
46
|
-
}
|
|
47
|
-
</style>
|
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { Slots } from "./
|
|
2
|
+
import type { Slots, Events, HighlightedCode } from "./shared";
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
|
|
6
|
-
autofocus?: boolean;
|
|
7
|
-
class?: string;
|
|
8
|
-
contenteditable?: "inherit" | import("svelte/elements").Booleanish;
|
|
9
|
-
contextmenu?: string;
|
|
10
|
-
dir?: string;
|
|
11
|
-
draggable?: import("svelte/elements").Booleanish;
|
|
12
|
-
enterkeyhint?: "search" | "next" | "done" | "enter" | "go" | "previous" | "send";
|
|
13
|
-
hidden?: boolean;
|
|
5
|
+
code: any;
|
|
14
6
|
id?: string;
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
color?: string;
|
|
8
|
+
translate?: "" | "yes" | "no";
|
|
9
|
+
hidden?: boolean;
|
|
17
10
|
slot?: string;
|
|
18
|
-
spellcheck?: import("svelte/elements").Booleanish;
|
|
19
11
|
style?: string;
|
|
20
|
-
tabindex?: number;
|
|
21
12
|
title?: string;
|
|
22
|
-
|
|
13
|
+
dir?: string;
|
|
14
|
+
contextmenu?: string;
|
|
15
|
+
autocapitalize?: string;
|
|
16
|
+
draggable?: import("svelte/elements").Booleanish;
|
|
23
17
|
inert?: boolean;
|
|
24
|
-
|
|
18
|
+
lang?: string;
|
|
19
|
+
spellcheck?: import("svelte/elements").Booleanish;
|
|
20
|
+
part?: string;
|
|
21
|
+
prefix?: string;
|
|
25
22
|
role?: import("svelte/elements").AriaRole;
|
|
23
|
+
autofocus?: boolean;
|
|
24
|
+
radiogroup?: string;
|
|
25
|
+
accesskey?: string;
|
|
26
|
+
class?: string;
|
|
27
|
+
contenteditable?: "inherit" | import("svelte/elements").Booleanish;
|
|
28
|
+
enterkeyhint?: "search" | "next" | "done" | "enter" | "go" | "previous" | "send";
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
tabindex?: number;
|
|
26
31
|
about?: string;
|
|
27
32
|
datatype?: string;
|
|
28
33
|
inlist?: any;
|
|
29
|
-
prefix?: string;
|
|
30
34
|
property?: string;
|
|
31
35
|
resource?: string;
|
|
32
36
|
typeof?: string;
|
|
33
37
|
vocab?: string;
|
|
34
|
-
autocapitalize?: string;
|
|
35
38
|
autocorrect?: string;
|
|
36
39
|
autosave?: string;
|
|
37
|
-
color?: string;
|
|
38
40
|
itemprop?: string;
|
|
39
41
|
itemscope?: boolean;
|
|
40
42
|
itemtype?: string;
|
|
@@ -99,6 +101,10 @@ declare const __propDef: {
|
|
|
99
101
|
'aria-valuemin'?: number;
|
|
100
102
|
'aria-valuenow'?: number;
|
|
101
103
|
'aria-valuetext'?: string;
|
|
104
|
+
langtag?: boolean;
|
|
105
|
+
"--langtag-background"?: string;
|
|
106
|
+
"--langtag-color"?: string;
|
|
107
|
+
"--langtag-border-radius"?: string;
|
|
102
108
|
'on:copy'?: import("svelte/elements").ClipboardEventHandler<HTMLPreElement>;
|
|
103
109
|
'on:cut'?: import("svelte/elements").ClipboardEventHandler<HTMLPreElement>;
|
|
104
110
|
'on:paste'?: import("svelte/elements").ClipboardEventHandler<HTMLPreElement>;
|
|
@@ -113,7 +119,9 @@ declare const __propDef: {
|
|
|
113
119
|
'on:beforeinput'?: import("svelte/elements").EventHandler<InputEvent, HTMLPreElement>;
|
|
114
120
|
'on:input'?: import("svelte/elements").FormEventHandler<HTMLPreElement>;
|
|
115
121
|
'on:reset'?: import("svelte/elements").FormEventHandler<HTMLPreElement>;
|
|
116
|
-
'on:submit'?: import("svelte/elements").EventHandler<Event
|
|
122
|
+
'on:submit'?: import("svelte/elements").EventHandler<Event & {
|
|
123
|
+
readonly submitter: HTMLElement;
|
|
124
|
+
}, HTMLPreElement>;
|
|
117
125
|
'on:invalid'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
118
126
|
'on:formdata'?: import("svelte/elements").EventHandler<Event & {
|
|
119
127
|
readonly formData: FormData;
|
|
@@ -203,51 +211,15 @@ declare const __propDef: {
|
|
|
203
211
|
'on:close'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
204
212
|
'on:fullscreenchange'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
205
213
|
'on:fullscreenerror'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
206
|
-
/**
|
|
207
|
-
* Specify the source code to highlight.
|
|
208
|
-
*/
|
|
209
|
-
code: any;
|
|
210
|
-
/**
|
|
211
|
-
* Set to `true` for the language name to be
|
|
212
|
-
* displayed at the top right of the code block.
|
|
213
|
-
*
|
|
214
|
-
* Use style props to customize styles:
|
|
215
|
-
* - `--langtag-background`
|
|
216
|
-
* - `--langtag-color`
|
|
217
|
-
* - `--langtag-border-radius`
|
|
218
|
-
*
|
|
219
|
-
* @default false
|
|
220
|
-
*/
|
|
221
|
-
langtag?: boolean;
|
|
222
|
-
/**
|
|
223
|
-
* Customize the background color of the langtag.
|
|
224
|
-
*/
|
|
225
|
-
"--langtag-background"?: string;
|
|
226
|
-
/**
|
|
227
|
-
* Customize the text color of the langtag.
|
|
228
|
-
*/
|
|
229
|
-
"--langtag-color"?: string;
|
|
230
|
-
/**
|
|
231
|
-
* Customize the border radius of the langtag.
|
|
232
|
-
*/
|
|
233
|
-
"--langtag-border-radius"?: string;
|
|
234
214
|
};
|
|
235
215
|
slots: Slots;
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
highlighted: string;
|
|
244
|
-
/**
|
|
245
|
-
* The inferred language name.
|
|
246
|
-
* @example "css"
|
|
247
|
-
*/
|
|
248
|
-
language?: string;
|
|
249
|
-
}>;
|
|
250
|
-
};
|
|
216
|
+
events: Events<HighlightedCode & {
|
|
217
|
+
/**
|
|
218
|
+
* The inferred language name.
|
|
219
|
+
* @example "css"
|
|
220
|
+
*/
|
|
221
|
+
language?: string;
|
|
222
|
+
}>;
|
|
251
223
|
};
|
|
252
224
|
export type HighlightAutoProps = typeof __propDef.props;
|
|
253
225
|
export type HighlightAutoEvents = typeof __propDef.events;
|
package/HighlightSvelte.svelte
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<script context="module">
|
|
2
|
-
</script>
|
|
1
|
+
<script context="module"></script>
|
|
3
2
|
|
|
4
|
-
<script>
|
|
3
|
+
<script>import LangTag from "./LangTag.svelte";
|
|
4
|
+
export let code;
|
|
5
5
|
export let langtag = false;
|
|
6
6
|
import hljs from "highlight.js/lib/core";
|
|
7
7
|
import xml from "highlight.js/lib/languages/xml";
|
|
@@ -13,36 +13,19 @@ hljs.registerLanguage("xml", xml);
|
|
|
13
13
|
hljs.registerLanguage("javascript", javascript);
|
|
14
14
|
hljs.registerLanguage("css", css);
|
|
15
15
|
afterUpdate(() => {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
if (highlighted)
|
|
17
|
+
dispatch("highlight", { highlighted });
|
|
18
18
|
});
|
|
19
|
-
$:
|
|
19
|
+
$:
|
|
20
|
+
highlighted = hljs.highlightAuto(code).value;
|
|
20
21
|
</script>
|
|
21
22
|
|
|
22
23
|
<slot {highlighted}>
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
<LangTag
|
|
25
|
+
{...$$restProps}
|
|
26
|
+
languageName="svelte"
|
|
27
|
+
{langtag}
|
|
28
|
+
{highlighted}
|
|
29
|
+
{code}
|
|
30
|
+
/>
|
|
26
31
|
</slot>
|
|
27
|
-
|
|
28
|
-
<style>
|
|
29
|
-
.langtag {
|
|
30
|
-
position: relative;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.langtag::after {
|
|
34
|
-
content: attr(data-language);
|
|
35
|
-
position: absolute;
|
|
36
|
-
top: 0;
|
|
37
|
-
right: 0;
|
|
38
|
-
padding: 1em;
|
|
39
|
-
display: flex;
|
|
40
|
-
align-items: center;
|
|
41
|
-
justify-content: center;
|
|
42
|
-
background: inherit;
|
|
43
|
-
color: inherit;
|
|
44
|
-
background: var(--langtag-background);
|
|
45
|
-
color: var(--langtag-color);
|
|
46
|
-
border-radius: var(--langtag-border-radius);
|
|
47
|
-
}
|
|
48
|
-
</style>
|
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
-
import type { Slots, Events } from "./
|
|
2
|
+
import type { Slots, Events } from "./shared";
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
-
|
|
6
|
-
autofocus?: boolean;
|
|
7
|
-
class?: string;
|
|
8
|
-
contenteditable?: "inherit" | import("svelte/elements").Booleanish;
|
|
9
|
-
contextmenu?: string;
|
|
10
|
-
dir?: string;
|
|
11
|
-
draggable?: import("svelte/elements").Booleanish;
|
|
12
|
-
enterkeyhint?: "search" | "next" | "done" | "enter" | "go" | "previous" | "send";
|
|
13
|
-
hidden?: boolean;
|
|
5
|
+
code: any;
|
|
14
6
|
id?: string;
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
color?: string;
|
|
8
|
+
translate?: "" | "yes" | "no";
|
|
9
|
+
hidden?: boolean;
|
|
17
10
|
slot?: string;
|
|
18
|
-
spellcheck?: import("svelte/elements").Booleanish;
|
|
19
11
|
style?: string;
|
|
20
|
-
tabindex?: number;
|
|
21
12
|
title?: string;
|
|
22
|
-
|
|
13
|
+
dir?: string;
|
|
14
|
+
contextmenu?: string;
|
|
15
|
+
autocapitalize?: string;
|
|
16
|
+
draggable?: import("svelte/elements").Booleanish;
|
|
23
17
|
inert?: boolean;
|
|
24
|
-
|
|
18
|
+
lang?: string;
|
|
19
|
+
spellcheck?: import("svelte/elements").Booleanish;
|
|
20
|
+
part?: string;
|
|
21
|
+
prefix?: string;
|
|
25
22
|
role?: import("svelte/elements").AriaRole;
|
|
23
|
+
autofocus?: boolean;
|
|
24
|
+
radiogroup?: string;
|
|
25
|
+
accesskey?: string;
|
|
26
|
+
class?: string;
|
|
27
|
+
contenteditable?: "inherit" | import("svelte/elements").Booleanish;
|
|
28
|
+
enterkeyhint?: "search" | "next" | "done" | "enter" | "go" | "previous" | "send";
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
tabindex?: number;
|
|
26
31
|
about?: string;
|
|
27
32
|
datatype?: string;
|
|
28
33
|
inlist?: any;
|
|
29
|
-
prefix?: string;
|
|
30
34
|
property?: string;
|
|
31
35
|
resource?: string;
|
|
32
36
|
typeof?: string;
|
|
33
37
|
vocab?: string;
|
|
34
|
-
autocapitalize?: string;
|
|
35
38
|
autocorrect?: string;
|
|
36
39
|
autosave?: string;
|
|
37
|
-
color?: string;
|
|
38
40
|
itemprop?: string;
|
|
39
41
|
itemscope?: boolean;
|
|
40
42
|
itemtype?: string;
|
|
@@ -99,6 +101,10 @@ declare const __propDef: {
|
|
|
99
101
|
'aria-valuemin'?: number;
|
|
100
102
|
'aria-valuenow'?: number;
|
|
101
103
|
'aria-valuetext'?: string;
|
|
104
|
+
langtag?: boolean;
|
|
105
|
+
"--langtag-background"?: string;
|
|
106
|
+
"--langtag-color"?: string;
|
|
107
|
+
"--langtag-border-radius"?: string;
|
|
102
108
|
'on:copy'?: import("svelte/elements").ClipboardEventHandler<HTMLPreElement>;
|
|
103
109
|
'on:cut'?: import("svelte/elements").ClipboardEventHandler<HTMLPreElement>;
|
|
104
110
|
'on:paste'?: import("svelte/elements").ClipboardEventHandler<HTMLPreElement>;
|
|
@@ -113,7 +119,9 @@ declare const __propDef: {
|
|
|
113
119
|
'on:beforeinput'?: import("svelte/elements").EventHandler<InputEvent, HTMLPreElement>;
|
|
114
120
|
'on:input'?: import("svelte/elements").FormEventHandler<HTMLPreElement>;
|
|
115
121
|
'on:reset'?: import("svelte/elements").FormEventHandler<HTMLPreElement>;
|
|
116
|
-
'on:submit'?: import("svelte/elements").EventHandler<Event
|
|
122
|
+
'on:submit'?: import("svelte/elements").EventHandler<Event & {
|
|
123
|
+
readonly submitter: HTMLElement;
|
|
124
|
+
}, HTMLPreElement>;
|
|
117
125
|
'on:invalid'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
118
126
|
'on:formdata'?: import("svelte/elements").EventHandler<Event & {
|
|
119
127
|
readonly formData: FormData;
|
|
@@ -203,38 +211,9 @@ declare const __propDef: {
|
|
|
203
211
|
'on:close'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
204
212
|
'on:fullscreenchange'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
205
213
|
'on:fullscreenerror'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
206
|
-
/**
|
|
207
|
-
* Specify the source code to highlight.
|
|
208
|
-
*/
|
|
209
|
-
code: any;
|
|
210
|
-
/**
|
|
211
|
-
* Set to `true` for the language name to be
|
|
212
|
-
* displayed at the top right of the code block.
|
|
213
|
-
*
|
|
214
|
-
* Use style props to customize styles:
|
|
215
|
-
* - `--langtag-background`
|
|
216
|
-
* - `--langtag-color`
|
|
217
|
-
* - `--langtag-border-radius`
|
|
218
|
-
*
|
|
219
|
-
* @default false
|
|
220
|
-
*/
|
|
221
|
-
langtag?: boolean;
|
|
222
|
-
/**
|
|
223
|
-
* Customize the background color of the langtag.
|
|
224
|
-
*/
|
|
225
|
-
"--langtag-background"?: string;
|
|
226
|
-
/**
|
|
227
|
-
* Customize the text color of the langtag.
|
|
228
|
-
*/
|
|
229
|
-
"--langtag-color"?: string;
|
|
230
|
-
/**
|
|
231
|
-
* Customize the border radius of the langtag.
|
|
232
|
-
*/
|
|
233
|
-
"--langtag-border-radius"?: string;
|
|
234
214
|
};
|
|
235
215
|
slots: Slots;
|
|
236
|
-
|
|
237
|
-
events: Events;
|
|
216
|
+
events: Events<import("./shared").HighlightedCode>;
|
|
238
217
|
};
|
|
239
218
|
export type HighlightSvelteProps = typeof __propDef.props;
|
|
240
219
|
export type HighlightSvelteEvents = typeof __propDef.events;
|
package/LangTag.svelte
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script context="module"></script>
|
|
2
|
+
|
|
3
|
+
<script>export let langtag = false;
|
|
4
|
+
export let highlighted;
|
|
5
|
+
export let code;
|
|
6
|
+
export let languageName = "plaintext";
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<pre class:langtag data-language={languageName} {...$$restProps}><code
|
|
10
|
+
class:hljs={true}
|
|
11
|
+
>{#if highlighted}{@html highlighted}{:else}{code}{/if}</code
|
|
12
|
+
></pre>
|
|
13
|
+
|
|
14
|
+
<style>
|
|
15
|
+
.langtag {
|
|
16
|
+
position: relative;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.langtag::after {
|
|
20
|
+
content: attr(data-language);
|
|
21
|
+
position: absolute;
|
|
22
|
+
top: 0;
|
|
23
|
+
right: 0;
|
|
24
|
+
padding: 1em;
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
background: var(--langtag-background, inherit);
|
|
29
|
+
color: var(--langtag-color, inherit);
|
|
30
|
+
border-radius: var(--langtag-border-radius);
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
code: any;
|
|
5
|
+
id?: string;
|
|
6
|
+
color?: string;
|
|
7
|
+
translate?: "" | "yes" | "no";
|
|
8
|
+
hidden?: boolean;
|
|
9
|
+
slot?: string;
|
|
10
|
+
style?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
dir?: string;
|
|
13
|
+
contextmenu?: string;
|
|
14
|
+
autocapitalize?: string;
|
|
15
|
+
draggable?: import("svelte/elements").Booleanish;
|
|
16
|
+
inert?: boolean;
|
|
17
|
+
lang?: string;
|
|
18
|
+
spellcheck?: import("svelte/elements").Booleanish;
|
|
19
|
+
part?: string;
|
|
20
|
+
prefix?: string;
|
|
21
|
+
role?: import("svelte/elements").AriaRole;
|
|
22
|
+
autofocus?: boolean;
|
|
23
|
+
radiogroup?: string;
|
|
24
|
+
accesskey?: string;
|
|
25
|
+
class?: string;
|
|
26
|
+
contenteditable?: "inherit" | import("svelte/elements").Booleanish;
|
|
27
|
+
enterkeyhint?: "search" | "next" | "done" | "enter" | "go" | "previous" | "send";
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
tabindex?: number;
|
|
30
|
+
about?: string;
|
|
31
|
+
datatype?: string;
|
|
32
|
+
inlist?: any;
|
|
33
|
+
property?: string;
|
|
34
|
+
resource?: string;
|
|
35
|
+
typeof?: string;
|
|
36
|
+
vocab?: string;
|
|
37
|
+
autocorrect?: string;
|
|
38
|
+
autosave?: string;
|
|
39
|
+
itemprop?: string;
|
|
40
|
+
itemscope?: boolean;
|
|
41
|
+
itemtype?: string;
|
|
42
|
+
itemid?: string;
|
|
43
|
+
itemref?: string;
|
|
44
|
+
results?: number;
|
|
45
|
+
security?: string;
|
|
46
|
+
unselectable?: "off" | "on";
|
|
47
|
+
inputmode?: "search" | "numeric" | "none" | "url" | "text" | "decimal" | "tel" | "email";
|
|
48
|
+
is?: string;
|
|
49
|
+
'bind:innerHTML'?: string;
|
|
50
|
+
'bind:textContent'?: string;
|
|
51
|
+
'data-sveltekit-noscroll'?: true | "" | "off";
|
|
52
|
+
'data-sveltekit-preload-code'?: true | "" | "eager" | "off" | "viewport" | "hover" | "tap";
|
|
53
|
+
'data-sveltekit-preload-data'?: true | "" | "off" | "hover" | "tap";
|
|
54
|
+
'data-sveltekit-reload'?: true | "" | "off";
|
|
55
|
+
'aria-activedescendant'?: string;
|
|
56
|
+
'aria-atomic'?: import("svelte/elements").Booleanish;
|
|
57
|
+
'aria-autocomplete'?: "inline" | "both" | "none" | "list";
|
|
58
|
+
'aria-busy'?: import("svelte/elements").Booleanish;
|
|
59
|
+
'aria-checked'?: boolean | "false" | "true" | "mixed";
|
|
60
|
+
'aria-colcount'?: number;
|
|
61
|
+
'aria-colindex'?: number;
|
|
62
|
+
'aria-colspan'?: number;
|
|
63
|
+
'aria-controls'?: string;
|
|
64
|
+
'aria-current'?: "location" | "time" | import("svelte/elements").Booleanish | "page" | "step" | "date";
|
|
65
|
+
'aria-describedby'?: string;
|
|
66
|
+
'aria-details'?: string;
|
|
67
|
+
'aria-disabled'?: import("svelte/elements").Booleanish;
|
|
68
|
+
'aria-dropeffect'?: "link" | "none" | "copy" | "move" | "execute" | "popup";
|
|
69
|
+
'aria-errormessage'?: string;
|
|
70
|
+
'aria-expanded'?: import("svelte/elements").Booleanish;
|
|
71
|
+
'aria-flowto'?: string;
|
|
72
|
+
'aria-grabbed'?: import("svelte/elements").Booleanish;
|
|
73
|
+
'aria-haspopup'?: "grid" | "dialog" | "menu" | import("svelte/elements").Booleanish | "listbox" | "tree";
|
|
74
|
+
'aria-hidden'?: import("svelte/elements").Booleanish;
|
|
75
|
+
'aria-invalid'?: import("svelte/elements").Booleanish | "grammar" | "spelling";
|
|
76
|
+
'aria-keyshortcuts'?: string;
|
|
77
|
+
'aria-label'?: string;
|
|
78
|
+
'aria-labelledby'?: string;
|
|
79
|
+
'aria-level'?: number;
|
|
80
|
+
'aria-live'?: "off" | "assertive" | "polite";
|
|
81
|
+
'aria-modal'?: import("svelte/elements").Booleanish;
|
|
82
|
+
'aria-multiline'?: import("svelte/elements").Booleanish;
|
|
83
|
+
'aria-multiselectable'?: import("svelte/elements").Booleanish;
|
|
84
|
+
'aria-orientation'?: "horizontal" | "vertical";
|
|
85
|
+
'aria-owns'?: string;
|
|
86
|
+
'aria-placeholder'?: string;
|
|
87
|
+
'aria-posinset'?: number;
|
|
88
|
+
'aria-pressed'?: boolean | "false" | "true" | "mixed";
|
|
89
|
+
'aria-readonly'?: import("svelte/elements").Booleanish;
|
|
90
|
+
'aria-relevant'?: "all" | "text" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals";
|
|
91
|
+
'aria-required'?: import("svelte/elements").Booleanish;
|
|
92
|
+
'aria-roledescription'?: string;
|
|
93
|
+
'aria-rowcount'?: number;
|
|
94
|
+
'aria-rowindex'?: number;
|
|
95
|
+
'aria-rowspan'?: number;
|
|
96
|
+
'aria-selected'?: import("svelte/elements").Booleanish;
|
|
97
|
+
'aria-setsize'?: number;
|
|
98
|
+
'aria-sort'?: "none" | "other" | "ascending" | "descending";
|
|
99
|
+
'aria-valuemax'?: number;
|
|
100
|
+
'aria-valuemin'?: number;
|
|
101
|
+
'aria-valuenow'?: number;
|
|
102
|
+
'aria-valuetext'?: string;
|
|
103
|
+
langtag?: boolean;
|
|
104
|
+
"--langtag-background"?: string;
|
|
105
|
+
"--langtag-color"?: string;
|
|
106
|
+
"--langtag-border-radius"?: string;
|
|
107
|
+
'on:copy'?: import("svelte/elements").ClipboardEventHandler<HTMLPreElement>;
|
|
108
|
+
'on:cut'?: import("svelte/elements").ClipboardEventHandler<HTMLPreElement>;
|
|
109
|
+
'on:paste'?: import("svelte/elements").ClipboardEventHandler<HTMLPreElement>;
|
|
110
|
+
'on:compositionend'?: import("svelte/elements").CompositionEventHandler<HTMLPreElement>;
|
|
111
|
+
'on:compositionstart'?: import("svelte/elements").CompositionEventHandler<HTMLPreElement>;
|
|
112
|
+
'on:compositionupdate'?: import("svelte/elements").CompositionEventHandler<HTMLPreElement>;
|
|
113
|
+
'on:focus'?: import("svelte/elements").FocusEventHandler<HTMLPreElement>;
|
|
114
|
+
'on:focusin'?: import("svelte/elements").FocusEventHandler<HTMLPreElement>;
|
|
115
|
+
'on:focusout'?: import("svelte/elements").FocusEventHandler<HTMLPreElement>;
|
|
116
|
+
'on:blur'?: import("svelte/elements").FocusEventHandler<HTMLPreElement>;
|
|
117
|
+
'on:change'?: import("svelte/elements").FormEventHandler<HTMLPreElement>;
|
|
118
|
+
'on:beforeinput'?: import("svelte/elements").EventHandler<InputEvent, HTMLPreElement>;
|
|
119
|
+
'on:input'?: import("svelte/elements").FormEventHandler<HTMLPreElement>;
|
|
120
|
+
'on:reset'?: import("svelte/elements").FormEventHandler<HTMLPreElement>;
|
|
121
|
+
'on:submit'?: import("svelte/elements").EventHandler<Event & {
|
|
122
|
+
readonly submitter: HTMLElement;
|
|
123
|
+
}, HTMLPreElement>;
|
|
124
|
+
'on:invalid'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
125
|
+
'on:formdata'?: import("svelte/elements").EventHandler<Event & {
|
|
126
|
+
readonly formData: FormData;
|
|
127
|
+
}, HTMLPreElement>;
|
|
128
|
+
'on:load'?: import("svelte/elements").EventHandler<Event, Element>;
|
|
129
|
+
'on:error'?: import("svelte/elements").EventHandler<Event, Element>;
|
|
130
|
+
'on:toggle'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
131
|
+
'on:keydown'?: import("svelte/elements").KeyboardEventHandler<HTMLPreElement>;
|
|
132
|
+
'on:keypress'?: import("svelte/elements").KeyboardEventHandler<HTMLPreElement>;
|
|
133
|
+
'on:keyup'?: import("svelte/elements").KeyboardEventHandler<HTMLPreElement>;
|
|
134
|
+
'on:abort'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
135
|
+
'on:canplay'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
136
|
+
'on:canplaythrough'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
137
|
+
'on:cuechange'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
138
|
+
'on:durationchange'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
139
|
+
'on:emptied'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
140
|
+
'on:encrypted'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
141
|
+
'on:ended'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
142
|
+
'on:loadeddata'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
143
|
+
'on:loadedmetadata'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
144
|
+
'on:loadstart'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
145
|
+
'on:pause'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
146
|
+
'on:play'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
147
|
+
'on:playing'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
148
|
+
'on:progress'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
149
|
+
'on:ratechange'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
150
|
+
'on:seeked'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
151
|
+
'on:seeking'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
152
|
+
'on:stalled'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
153
|
+
'on:suspend'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
154
|
+
'on:timeupdate'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
155
|
+
'on:volumechange'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
156
|
+
'on:waiting'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
157
|
+
'on:auxclick'?: import("svelte/elements").MouseEventHandler<HTMLPreElement>;
|
|
158
|
+
'on:click'?: import("svelte/elements").MouseEventHandler<HTMLPreElement>;
|
|
159
|
+
'on:contextmenu'?: import("svelte/elements").MouseEventHandler<HTMLPreElement>;
|
|
160
|
+
'on:dblclick'?: import("svelte/elements").MouseEventHandler<HTMLPreElement>;
|
|
161
|
+
'on:drag'?: import("svelte/elements").DragEventHandler<HTMLPreElement>;
|
|
162
|
+
'on:dragend'?: import("svelte/elements").DragEventHandler<HTMLPreElement>;
|
|
163
|
+
'on:dragenter'?: import("svelte/elements").DragEventHandler<HTMLPreElement>;
|
|
164
|
+
'on:dragexit'?: import("svelte/elements").DragEventHandler<HTMLPreElement>;
|
|
165
|
+
'on:dragleave'?: import("svelte/elements").DragEventHandler<HTMLPreElement>;
|
|
166
|
+
'on:dragover'?: import("svelte/elements").DragEventHandler<HTMLPreElement>;
|
|
167
|
+
'on:dragstart'?: import("svelte/elements").DragEventHandler<HTMLPreElement>;
|
|
168
|
+
'on:drop'?: import("svelte/elements").DragEventHandler<HTMLPreElement>;
|
|
169
|
+
'on:mousedown'?: import("svelte/elements").MouseEventHandler<HTMLPreElement>;
|
|
170
|
+
'on:mouseenter'?: import("svelte/elements").MouseEventHandler<HTMLPreElement>;
|
|
171
|
+
'on:mouseleave'?: import("svelte/elements").MouseEventHandler<HTMLPreElement>;
|
|
172
|
+
'on:mousemove'?: import("svelte/elements").MouseEventHandler<HTMLPreElement>;
|
|
173
|
+
'on:mouseout'?: import("svelte/elements").MouseEventHandler<HTMLPreElement>;
|
|
174
|
+
'on:mouseover'?: import("svelte/elements").MouseEventHandler<HTMLPreElement>;
|
|
175
|
+
'on:mouseup'?: import("svelte/elements").MouseEventHandler<HTMLPreElement>;
|
|
176
|
+
'on:select'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
177
|
+
'on:selectionchange'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
178
|
+
'on:selectstart'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
179
|
+
'on:touchcancel'?: import("svelte/elements").TouchEventHandler<HTMLPreElement>;
|
|
180
|
+
'on:touchend'?: import("svelte/elements").TouchEventHandler<HTMLPreElement>;
|
|
181
|
+
'on:touchmove'?: import("svelte/elements").TouchEventHandler<HTMLPreElement>;
|
|
182
|
+
'on:touchstart'?: import("svelte/elements").TouchEventHandler<HTMLPreElement>;
|
|
183
|
+
'on:gotpointercapture'?: import("svelte/elements").PointerEventHandler<HTMLPreElement>;
|
|
184
|
+
'on:pointercancel'?: import("svelte/elements").PointerEventHandler<HTMLPreElement>;
|
|
185
|
+
'on:pointerdown'?: import("svelte/elements").PointerEventHandler<HTMLPreElement>;
|
|
186
|
+
'on:pointerenter'?: import("svelte/elements").PointerEventHandler<HTMLPreElement>;
|
|
187
|
+
'on:pointerleave'?: import("svelte/elements").PointerEventHandler<HTMLPreElement>;
|
|
188
|
+
'on:pointermove'?: import("svelte/elements").PointerEventHandler<HTMLPreElement>;
|
|
189
|
+
'on:pointerout'?: import("svelte/elements").PointerEventHandler<HTMLPreElement>;
|
|
190
|
+
'on:pointerover'?: import("svelte/elements").PointerEventHandler<HTMLPreElement>;
|
|
191
|
+
'on:pointerup'?: import("svelte/elements").PointerEventHandler<HTMLPreElement>;
|
|
192
|
+
'on:lostpointercapture'?: import("svelte/elements").PointerEventHandler<HTMLPreElement>;
|
|
193
|
+
'on:scroll'?: import("svelte/elements").UIEventHandler<HTMLPreElement>;
|
|
194
|
+
'on:resize'?: import("svelte/elements").UIEventHandler<HTMLPreElement>;
|
|
195
|
+
'on:wheel'?: import("svelte/elements").WheelEventHandler<HTMLPreElement>;
|
|
196
|
+
'on:animationstart'?: import("svelte/elements").AnimationEventHandler<HTMLPreElement>;
|
|
197
|
+
'on:animationend'?: import("svelte/elements").AnimationEventHandler<HTMLPreElement>;
|
|
198
|
+
'on:animationiteration'?: import("svelte/elements").AnimationEventHandler<HTMLPreElement>;
|
|
199
|
+
'on:transitionstart'?: import("svelte/elements").TransitionEventHandler<HTMLPreElement>;
|
|
200
|
+
'on:transitionrun'?: import("svelte/elements").TransitionEventHandler<HTMLPreElement>;
|
|
201
|
+
'on:transitionend'?: import("svelte/elements").TransitionEventHandler<HTMLPreElement>;
|
|
202
|
+
'on:transitioncancel'?: import("svelte/elements").TransitionEventHandler<HTMLPreElement>;
|
|
203
|
+
'on:outrostart'?: import("svelte/elements").EventHandler<CustomEvent<null>, HTMLPreElement>;
|
|
204
|
+
'on:outroend'?: import("svelte/elements").EventHandler<CustomEvent<null>, HTMLPreElement>;
|
|
205
|
+
'on:introstart'?: import("svelte/elements").EventHandler<CustomEvent<null>, HTMLPreElement>;
|
|
206
|
+
'on:introend'?: import("svelte/elements").EventHandler<CustomEvent<null>, HTMLPreElement>;
|
|
207
|
+
'on:message'?: import("svelte/elements").MessageEventHandler<HTMLPreElement>;
|
|
208
|
+
'on:messageerror'?: import("svelte/elements").MessageEventHandler<HTMLPreElement>;
|
|
209
|
+
'on:cancel'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
210
|
+
'on:close'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
211
|
+
'on:fullscreenchange'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
212
|
+
'on:fullscreenerror'?: import("svelte/elements").EventHandler<Event, HTMLPreElement>;
|
|
213
|
+
/**
|
|
214
|
+
* Specify the highlighted code.
|
|
215
|
+
*/
|
|
216
|
+
highlighted: string | undefined;
|
|
217
|
+
/**
|
|
218
|
+
* Specifiy the language name.
|
|
219
|
+
* @default "plaintext"
|
|
220
|
+
*/
|
|
221
|
+
languageName?: string;
|
|
222
|
+
};
|
|
223
|
+
events: {
|
|
224
|
+
[evt: string]: CustomEvent<any>;
|
|
225
|
+
};
|
|
226
|
+
slots: {};
|
|
227
|
+
};
|
|
228
|
+
export type LangTagProps = typeof __propDef.props;
|
|
229
|
+
export type LangTagEvents = typeof __propDef.events;
|
|
230
|
+
export type LangTagSlots = typeof __propDef.slots;
|
|
231
|
+
export default class LangTag extends SvelteComponentTyped<LangTagProps, LangTagEvents, LangTagSlots> {
|
|
232
|
+
}
|
|
233
|
+
export {};
|
package/LineNumbers.svelte
CHANGED
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
export let hideBorder = false;
|
|
3
3
|
export let wrapLines = false;
|
|
4
4
|
export let startingLineNumber = 1;
|
|
5
|
+
export let highlightedLines = [];
|
|
5
6
|
const DIGIT_WIDTH = 12;
|
|
6
7
|
const MIN_DIGITS = 2;
|
|
7
|
-
|
|
8
|
-
$:
|
|
9
|
-
|
|
10
|
-
$:
|
|
8
|
+
const HIGHLIGHTED_BACKGROUND = "rgba(254, 241, 96, 0.2)";
|
|
9
|
+
$:
|
|
10
|
+
lines = highlighted.split("\n");
|
|
11
|
+
$:
|
|
12
|
+
len_digits = lines.length.toString().length;
|
|
13
|
+
$:
|
|
14
|
+
len = len_digits - MIN_DIGITS < 1 ? MIN_DIGITS : len_digits;
|
|
15
|
+
$:
|
|
16
|
+
width = len * DIGIT_WIDTH;
|
|
11
17
|
</script>
|
|
12
18
|
|
|
13
19
|
<div style:overflow-x="auto" {...$$restProps}>
|
|
@@ -28,9 +34,21 @@ $: width = len * DIGIT_WIDTH;
|
|
|
28
34
|
<code style:color="var(--line-number-color, currentColor)">
|
|
29
35
|
{lineNumber}
|
|
30
36
|
</code>
|
|
37
|
+
{#if highlightedLines.includes(i)}
|
|
38
|
+
<div
|
|
39
|
+
class:line-background={true}
|
|
40
|
+
style:background="var(--highlighted-background, {HIGHLIGHTED_BACKGROUND})"
|
|
41
|
+
/>
|
|
42
|
+
{/if}
|
|
31
43
|
</td>
|
|
32
44
|
<td>
|
|
33
45
|
<pre class:wrapLines><code>{@html line || "\n"}</code></pre>
|
|
46
|
+
{#if highlightedLines.includes(i)}
|
|
47
|
+
<div
|
|
48
|
+
class:line-background={true}
|
|
49
|
+
style:background="var(--highlighted-background, {HIGHLIGHTED_BACKGROUND})"
|
|
50
|
+
/>
|
|
51
|
+
{/if}
|
|
34
52
|
</td>
|
|
35
53
|
</tr>
|
|
36
54
|
{/each}
|
|
@@ -66,6 +84,10 @@ $: width = len * DIGIT_WIDTH;
|
|
|
66
84
|
padding-bottom: 1em;
|
|
67
85
|
}
|
|
68
86
|
|
|
87
|
+
tr td:first-of-type {
|
|
88
|
+
z-index: 2;
|
|
89
|
+
}
|
|
90
|
+
|
|
69
91
|
td {
|
|
70
92
|
padding-left: var(--padding-left, 1em);
|
|
71
93
|
padding-right: var(--padding-right, 1em);
|
|
@@ -84,4 +106,37 @@ $: width = len * DIGIT_WIDTH;
|
|
|
84
106
|
.wrapLines {
|
|
85
107
|
white-space: pre-wrap;
|
|
86
108
|
}
|
|
109
|
+
|
|
110
|
+
td,
|
|
111
|
+
td > code,
|
|
112
|
+
pre {
|
|
113
|
+
position: relative;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
td > code,
|
|
117
|
+
pre {
|
|
118
|
+
z-index: 1;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.line-background {
|
|
122
|
+
position: absolute;
|
|
123
|
+
z-index: 0;
|
|
124
|
+
top: 0;
|
|
125
|
+
left: 0;
|
|
126
|
+
width: 100%;
|
|
127
|
+
height: 100%;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
tr:first-of-type td .line-background,
|
|
131
|
+
tr:last-of-type td .line-background {
|
|
132
|
+
height: calc(100% - 1em);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
tr:first-of-type td .line-background {
|
|
136
|
+
top: 1em;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
tr:last-of-type td .line-background {
|
|
140
|
+
bottom: 1em;
|
|
141
|
+
}
|
|
87
142
|
</style>
|
package/LineNumbers.svelte.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ declare const __propDef: {
|
|
|
12
12
|
hidden?: boolean;
|
|
13
13
|
id?: string;
|
|
14
14
|
lang?: string;
|
|
15
|
+
part?: string;
|
|
15
16
|
placeholder?: string;
|
|
16
17
|
slot?: string;
|
|
17
18
|
spellcheck?: import("svelte/elements").Booleanish;
|
|
@@ -112,7 +113,9 @@ declare const __propDef: {
|
|
|
112
113
|
'on:beforeinput'?: import("svelte/elements").EventHandler<InputEvent, HTMLDivElement>;
|
|
113
114
|
'on:input'?: import("svelte/elements").FormEventHandler<HTMLDivElement>;
|
|
114
115
|
'on:reset'?: import("svelte/elements").FormEventHandler<HTMLDivElement>;
|
|
115
|
-
'on:submit'?: import("svelte/elements").EventHandler<Event
|
|
116
|
+
'on:submit'?: import("svelte/elements").EventHandler<Event & {
|
|
117
|
+
readonly submitter: HTMLElement;
|
|
118
|
+
}, HTMLDivElement>;
|
|
116
119
|
'on:invalid'?: import("svelte/elements").EventHandler<Event, HTMLDivElement>;
|
|
117
120
|
'on:formdata'?: import("svelte/elements").EventHandler<Event & {
|
|
118
121
|
readonly formData: FormData;
|
|
@@ -225,6 +228,12 @@ declare const __propDef: {
|
|
|
225
228
|
* @default false
|
|
226
229
|
*/
|
|
227
230
|
wrapLines?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Specify the line indices to highlight.
|
|
233
|
+
* @default []
|
|
234
|
+
* @example [0, 1, 9]
|
|
235
|
+
*/
|
|
236
|
+
highlightedLines?: number[];
|
|
228
237
|
/**
|
|
229
238
|
* Specify the text color for line numbers.
|
|
230
239
|
* Defaults to the current theme color applied to `.hljs code`.
|
|
@@ -251,6 +260,12 @@ declare const __propDef: {
|
|
|
251
260
|
* @example 0
|
|
252
261
|
*/
|
|
253
262
|
"--padding-right"?: number | string;
|
|
263
|
+
/**
|
|
264
|
+
* Specify the background color of highlighted lines.
|
|
265
|
+
* @default "rgba(254, 241, 96, 0.2)"
|
|
266
|
+
* @example "#fff"
|
|
267
|
+
*/
|
|
268
|
+
"--highlighted-background"?: string;
|
|
254
269
|
};
|
|
255
270
|
events: {
|
|
256
271
|
[evt: string]: CustomEvent<any>;
|
package/README.md
CHANGED
|
@@ -208,36 +208,54 @@ Set `wrapLines` to `true` to hide the border of the line numbers column.
|
|
|
208
208
|
</Highlight>
|
|
209
209
|
```
|
|
210
210
|
|
|
211
|
-
### Custom
|
|
211
|
+
### Custom Starting Line Number
|
|
212
212
|
|
|
213
|
-
|
|
213
|
+
The line number starts at `1`. Customize this via the `startingLineNumber` prop.
|
|
214
214
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
215
|
+
```svelte
|
|
216
|
+
<Highlight language={typescript} {code} let:highlighted>
|
|
217
|
+
<LineNumbers {highlighted} startingLineNumber={42} />
|
|
218
|
+
</Highlight>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Highlighted Lines
|
|
222
|
+
|
|
223
|
+
Specify the lines to highlight using the `highlightedLines` prop. Indices start at zero.
|
|
224
|
+
|
|
225
|
+
Use `--highlighted-background` to customize the background color of highlighted lines.
|
|
221
226
|
|
|
222
227
|
```svelte
|
|
223
228
|
<Highlight language={typescript} {code} let:highlighted>
|
|
224
229
|
<LineNumbers
|
|
225
230
|
{highlighted}
|
|
226
|
-
|
|
227
|
-
--
|
|
228
|
-
--padding-left={0}
|
|
229
|
-
--padding-right="3em"
|
|
231
|
+
highlightedLines={[0, 2, 3, 14]}
|
|
232
|
+
--highlighted-background="#000"
|
|
230
233
|
/>
|
|
231
234
|
</Highlight>
|
|
232
235
|
```
|
|
233
236
|
|
|
234
|
-
### Custom
|
|
237
|
+
### Custom Styles
|
|
235
238
|
|
|
236
|
-
|
|
239
|
+
Use `--style-props` to customize styles.
|
|
240
|
+
|
|
241
|
+
| Style prop | Description | Default value |
|
|
242
|
+
| :----------------------- | :----------------------------------------- | :------------------------ |
|
|
243
|
+
| --line-number-color | Text color of the line numbers | `currentColor` |
|
|
244
|
+
| --border-color | Border color of the column of line numbers | `currentColor` |
|
|
245
|
+
| --padding-left | Left padding for `td` elements | `1em` |
|
|
246
|
+
| --padding-right | Right padding for `td` elements | `1em` |
|
|
247
|
+
| --highlighted-background | Background color of highlighted lines | `rgba(254, 241, 96, 0.2)` |
|
|
237
248
|
|
|
238
249
|
```svelte
|
|
239
250
|
<Highlight language={typescript} {code} let:highlighted>
|
|
240
|
-
<LineNumbers
|
|
251
|
+
<LineNumbers
|
|
252
|
+
{highlighted}
|
|
253
|
+
--line-number-color="pink"
|
|
254
|
+
--border-color="rgba(255, 255, 255, 0.2)"
|
|
255
|
+
--padding-left={0}
|
|
256
|
+
--padding-right="3em"
|
|
257
|
+
--highlighted-background="#000"
|
|
258
|
+
/>
|
|
241
259
|
</Highlight>
|
|
242
260
|
```
|
|
243
261
|
|
|
@@ -378,12 +396,13 @@ In the example below, the `HighlightAuto` component and injected styles are dyna
|
|
|
378
396
|
|
|
379
397
|
#### Props
|
|
380
398
|
|
|
381
|
-
| Name | Type
|
|
382
|
-
| :----------------- |
|
|
383
|
-
| highlighted | `string`
|
|
384
|
-
| hideBorder | `boolean`
|
|
385
|
-
| wrapLines | `boolean`
|
|
386
|
-
| startingLineNumber | `number`
|
|
399
|
+
| Name | Type | Default value |
|
|
400
|
+
| :----------------- | :--------- | :------------- |
|
|
401
|
+
| highlighted | `string` | N/A (required) |
|
|
402
|
+
| hideBorder | `boolean` | `false` |
|
|
403
|
+
| wrapLines | `boolean` | `false` |
|
|
404
|
+
| startingLineNumber | `number` | `1` |
|
|
405
|
+
| highlightedLines | `number[]` | `[]` |
|
|
387
406
|
|
|
388
407
|
`$$restProps` are forwarded to the top-level `div` element.
|
|
389
408
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-highlight",
|
|
3
|
-
"version": "7.1
|
|
3
|
+
"version": "7.2.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Syntax Highlighting for Svelte using highlight.js",
|
|
6
6
|
"author": "Eric Liu (https://github.com/metonym)",
|
|
@@ -12,27 +12,26 @@
|
|
|
12
12
|
"highlight.js": "11.7.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@sveltejs/adapter-static": "
|
|
16
|
-
"@sveltejs/kit": "1.0
|
|
17
|
-
"@sveltejs/package": "^1.0.
|
|
15
|
+
"@sveltejs/adapter-static": "2.0.1",
|
|
16
|
+
"@sveltejs/kit": "1.11.0",
|
|
17
|
+
"@sveltejs/package": "^1.0.2",
|
|
18
18
|
"@testing-library/svelte": "^3.2.2",
|
|
19
19
|
"@testing-library/user-event": "^14.4.3",
|
|
20
20
|
"@types/prettier": "^2.7.2",
|
|
21
|
-
"carbon-components-svelte": "^0.
|
|
21
|
+
"carbon-components-svelte": "^0.73.3",
|
|
22
22
|
"carbon-icons-svelte": "^11.4.0",
|
|
23
23
|
"carbon-preprocess-svelte": "^0.9.1",
|
|
24
|
-
"jsdom": "^
|
|
25
|
-
"prettier": "^2.8.
|
|
24
|
+
"jsdom": "^21.1.0",
|
|
25
|
+
"prettier": "^2.8.4",
|
|
26
26
|
"prettier-plugin-svelte": "^2.9.0",
|
|
27
|
-
"svelte": "^3.55.
|
|
28
|
-
"svelte-check": "^3.
|
|
27
|
+
"svelte": "^3.55.1",
|
|
28
|
+
"svelte-check": "^3.1.2",
|
|
29
29
|
"svelte-focus-key": "^0.3.2",
|
|
30
|
-
"
|
|
31
|
-
"svelte2tsx": "^0.6.0",
|
|
30
|
+
"svelte2tsx": "^0.6.7",
|
|
32
31
|
"totalist": "^3.0.0",
|
|
33
|
-
"typescript": "^4.9.
|
|
34
|
-
"vite": "^4.
|
|
35
|
-
"vitest": "^0.
|
|
32
|
+
"typescript": "^4.9.5",
|
|
33
|
+
"vite": "^4.1.4",
|
|
34
|
+
"vitest": "^0.29.2"
|
|
36
35
|
},
|
|
37
36
|
"repository": {
|
|
38
37
|
"type": "git",
|
|
@@ -55,6 +54,7 @@
|
|
|
55
54
|
"./Highlight.svelte": "./Highlight.svelte",
|
|
56
55
|
"./HighlightAuto.svelte": "./HighlightAuto.svelte",
|
|
57
56
|
"./HighlightSvelte.svelte": "./HighlightSvelte.svelte",
|
|
57
|
+
"./LangTag.svelte": "./LangTag.svelte",
|
|
58
58
|
"./LineNumbers.svelte": "./LineNumbers.svelte",
|
|
59
59
|
".": "./index.js",
|
|
60
60
|
"./languages/1c": "./languages/1c.js",
|
package/shared.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
2
|
+
import type { LanguageType } from "./languages";
|
|
3
|
+
|
|
4
|
+
export interface Props extends HTMLAttributes<HTMLPreElement> {
|
|
5
|
+
/**
|
|
6
|
+
* Specify the text to highlight.
|
|
7
|
+
*/
|
|
8
|
+
code: any;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Provide the language grammar used to highlight the code.
|
|
12
|
+
* Import languages from `svelte-highlight/languages/*`.
|
|
13
|
+
* @example
|
|
14
|
+
* import typescript from "svelte-highlight/languages/typescript";
|
|
15
|
+
*/
|
|
16
|
+
language: LanguageType<string>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Set to `true` for the language name to be
|
|
20
|
+
* displayed at the top right of the code block.
|
|
21
|
+
*
|
|
22
|
+
* Use style props to customize styles:
|
|
23
|
+
* - `--langtag-background`
|
|
24
|
+
* - `--langtag-color`
|
|
25
|
+
* - `--langtag-border-radius`
|
|
26
|
+
*
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
langtag?: boolean;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Customize the background color of the langtag.
|
|
33
|
+
*/
|
|
34
|
+
"--langtag-background"?: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Customize the text color of the langtag.
|
|
38
|
+
*/
|
|
39
|
+
"--langtag-color"?: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Customize the border radius of the langtag.
|
|
43
|
+
*/
|
|
44
|
+
"--langtag-border-radius"?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface HighlightedCode {
|
|
48
|
+
/**
|
|
49
|
+
* The highlighted HTML as a string.
|
|
50
|
+
* @example "<span>...</span>"
|
|
51
|
+
*/
|
|
52
|
+
highlighted: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface Slots {
|
|
56
|
+
default: HighlightedCode;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface Events<THighlight = HighlightedCode> {
|
|
60
|
+
highlight: CustomEvent<THighlight>;
|
|
61
|
+
}
|