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 CHANGED
@@ -5,6 +5,26 @@ 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.0.0](https://github.com/metonym/svelte-highlight/releases/tag/v7.0.0) - 2022-12-30
9
+
10
+ **Breaking Changes**
11
+
12
+ - rename langtag style props
13
+ - `--hljs-background` -> `--langtag-background`
14
+ - `--hljs-foreground` -> `--langtag-color`
15
+ - `--hljs-radius` -> `--langtag-border-radius`
16
+ - mark `code`, `language` as required props
17
+
18
+ **Features**
19
+
20
+ - include inferred `language` in `on:highlight` event detail in `HighlightAuto`
21
+ - add `LineNumbers` component to support rendering line numbers
22
+ - upgrade `highlight.js` to version [11.7.0](https://github.com/highlightjs/highlight.js/releases/tag/11.7.0)
23
+
24
+ **Fixes**
25
+
26
+ - use `HTMLAttributes` from `svelte/elements` to correctly type `$$restProps`
27
+
8
28
  ## [6.2.1](https://github.com/metonym/svelte-highlight/releases/tag/v6.2.1) - 2022-08-07
9
29
 
10
30
  **Fixes**
@@ -16,7 +36,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
16
36
  - add dynamic import example
17
37
  - document CDN styles usage
18
38
  - use TypeScript in all example set-ups
19
- - remove Sapper example as it is deprecated
20
39
  - remove Snowpack example as it is no longer maintained
21
40
  - update set-up instructions for SvelteKit/Vite
22
41
 
package/Highlight.svelte CHANGED
@@ -1,16 +1,13 @@
1
1
  <script context="module">export {};
2
2
  </script>
3
3
 
4
- <script>export let language = {
5
- name: undefined,
6
- register: undefined,
7
- };
8
- export let code = undefined;
4
+ <script>export let language;
5
+ export let code;
9
6
  export let langtag = false;
10
7
  import hljs from "highlight.js/lib/core";
11
8
  import { createEventDispatcher, afterUpdate } from "svelte";
12
9
  const dispatch = createEventDispatcher();
13
- let highlighted = undefined;
10
+ let highlighted = "";
14
11
  afterUpdate(() => {
15
12
  if (highlighted)
16
13
  dispatch("highlight", { highlighted });
@@ -22,11 +19,12 @@ $: if (language.name && language.register) {
22
19
  </script>
23
20
 
24
21
  <slot {highlighted}>
25
- <!-- prettier-ignore -->
26
22
  <pre
27
23
  class:langtag
28
24
  data-language={language.name || "plaintext"}
29
- {...$$restProps}><code class="hljs">{#if highlighted !== undefined}{@html highlighted}{:else}{code}{/if}</code></pre>
25
+ {...$$restProps}><code class="hljs"
26
+ >{#if highlighted !== undefined}{@html highlighted}{:else}{code}{/if}</code
27
+ ></pre>
30
28
  </slot>
31
29
 
32
30
  <style>
@@ -45,8 +43,8 @@ $: if (language.name && language.register) {
45
43
  justify-content: center;
46
44
  background: inherit;
47
45
  color: inherit;
48
- background: var(--hljs-background);
49
- color: var(--hljs-foreground);
50
- border-radius: var(--hljs-radius);
46
+ background: var(--langtag-background);
47
+ color: var(--langtag-color);
48
+ border-radius: var(--langtag-border-radius);
51
49
  }
52
50
  </style>