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.
- package/CHANGELOG.md +26 -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 +82 -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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,32 @@ 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.1](https://github.com/metonym/svelte-highlight/releases/tag/v7.0.1) - 2022-12-30
|
|
9
|
+
|
|
10
|
+
**Fixes**
|
|
11
|
+
|
|
12
|
+
- reset `table` styles in `LineNumbers`
|
|
13
|
+
|
|
14
|
+
## [7.0.0](https://github.com/metonym/svelte-highlight/releases/tag/v7.0.0) - 2022-12-30
|
|
15
|
+
|
|
16
|
+
**Breaking Changes**
|
|
17
|
+
|
|
18
|
+
- rename langtag style props
|
|
19
|
+
- `--hljs-background` -> `--langtag-background`
|
|
20
|
+
- `--hljs-foreground` -> `--langtag-color`
|
|
21
|
+
- `--hljs-radius` -> `--langtag-border-radius`
|
|
22
|
+
- mark `code`, `language` as required props
|
|
23
|
+
|
|
24
|
+
**Features**
|
|
25
|
+
|
|
26
|
+
- include inferred `language` in `on:highlight` event detail in `HighlightAuto`
|
|
27
|
+
- add `LineNumbers` component to support rendering line numbers
|
|
28
|
+
- upgrade `highlight.js` to version [11.7.0](https://github.com/highlightjs/highlight.js/releases/tag/11.7.0)
|
|
29
|
+
|
|
30
|
+
**Fixes**
|
|
31
|
+
|
|
32
|
+
- use `HTMLAttributes` from `svelte/elements` to correctly type `$$restProps`
|
|
33
|
+
|
|
8
34
|
## [6.2.1](https://github.com/metonym/svelte-highlight/releases/tag/v6.2.1) - 2022-08-07
|
|
9
35
|
|
|
10
36
|
**Fixes**
|
|
@@ -16,7 +42,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
16
42
|
- add dynamic import example
|
|
17
43
|
- document CDN styles usage
|
|
18
44
|
- use TypeScript in all example set-ups
|
|
19
|
-
- remove Sapper example as it is deprecated
|
|
20
45
|
- remove Snowpack example as it is no longer maintained
|
|
21
46
|
- update set-up instructions for SvelteKit/Vite
|
|
22
47
|
|
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
|
-
|
|
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 =
|
|
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"
|
|
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(--
|
|
49
|
-
color: var(--
|
|
50
|
-
border-radius: var(--
|
|
46
|
+
background: var(--langtag-background);
|
|
47
|
+
color: var(--langtag-color);
|
|
48
|
+
border-radius: var(--langtag-border-radius);
|
|
51
49
|
}
|
|
52
50
|
</style>
|