svelte-highlight 6.2.1 → 7.0.0
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 +20 -1
- package/Highlight.svelte +9 -11
- package/Highlight.svelte.d.ts +228 -332
- package/HighlightAuto.svelte +10 -11
- package/HighlightAuto.svelte.d.ts +233 -327
- package/HighlightSvelte.svelte +7 -6
- package/HighlightSvelte.svelte.d.ts +218 -325
- package/LineNumbers.svelte +64 -0
- package/LineNumbers.svelte.d.ts +260 -0
- package/README.md +191 -54
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +21 -19
package/HighlightAuto.svelte
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
<script context="module">export {};
|
|
2
2
|
</script>
|
|
3
3
|
|
|
4
|
-
<script>export let code
|
|
4
|
+
<script>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
|
-
let highlighted =
|
|
9
|
+
let highlighted = "";
|
|
10
10
|
let language = undefined;
|
|
11
11
|
afterUpdate(() => {
|
|
12
12
|
if (highlighted)
|
|
13
|
-
dispatch("highlight", { highlighted });
|
|
13
|
+
dispatch("highlight", { highlighted, language });
|
|
14
14
|
});
|
|
15
|
-
$:
|
|
16
|
-
({ value: highlighted, language } = hljs.highlightAuto(code));
|
|
17
|
-
}
|
|
15
|
+
$: ({ value: highlighted, language } = hljs.highlightAuto(code));
|
|
18
16
|
</script>
|
|
19
17
|
|
|
20
18
|
<slot {highlighted}>
|
|
21
|
-
<!-- prettier-ignore -->
|
|
22
19
|
<pre
|
|
23
20
|
class:langtag
|
|
24
21
|
data-language={language || "plaintext"}
|
|
25
|
-
{...$$restProps}><code class="hljs"
|
|
22
|
+
{...$$restProps}><code class="hljs"
|
|
23
|
+
>{#if highlighted !== undefined}{@html highlighted}{:else}{code}{/if}</code
|
|
24
|
+
></pre>
|
|
26
25
|
</slot>
|
|
27
26
|
|
|
28
27
|
<style>
|
|
@@ -41,8 +40,8 @@ $: if (code) {
|
|
|
41
40
|
justify-content: center;
|
|
42
41
|
background: inherit;
|
|
43
42
|
color: inherit;
|
|
44
|
-
background: var(--
|
|
45
|
-
color: var(--
|
|
46
|
-
border-radius: var(--
|
|
43
|
+
background: var(--langtag-background);
|
|
44
|
+
color: var(--langtag-color);
|
|
45
|
+
border-radius: var(--langtag-border-radius);
|
|
47
46
|
}
|
|
48
47
|
</style>
|