svelte-highlight 6.2.1 → 7.0.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.
@@ -1,28 +1,27 @@
1
1
  <script context="module">export {};
2
2
  </script>
3
3
 
4
- <script>export let code = undefined;
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 = undefined;
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
- $: if (code) {
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">{#if highlighted !== undefined}{@html highlighted}{:else}{code}{/if}</code></pre>
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(--hljs-background);
45
- color: var(--hljs-foreground);
46
- border-radius: var(--hljs-radius);
43
+ background: var(--langtag-background);
44
+ color: var(--langtag-color);
45
+ border-radius: var(--langtag-border-radius);
47
46
  }
48
47
  </style>