svelte-highlight 7.0.0 → 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 CHANGED
@@ -5,6 +5,12 @@ 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
+
8
14
  ## [7.0.0](https://github.com/metonym/svelte-highlight/releases/tag/v7.0.0) - 2022-12-30
9
15
 
10
16
  **Breaking Changes**
@@ -1,8 +1,8 @@
1
1
  <script>export let highlighted;
2
2
  export let hideBorder = false;
3
3
  export let wrapLines = false;
4
- const DIGIT_WIDTH = 18;
5
- const MIN_DIGITS = 3;
4
+ const DIGIT_WIDTH = 12;
5
+ const MIN_DIGITS = 2;
6
6
  $: lines = highlighted.split("\n");
7
7
  $: len_digits = lines.length.toString().length;
8
8
  $: len = len_digits - MIN_DIGITS < 1 ? MIN_DIGITS : len_digits;
@@ -10,7 +10,7 @@ $: width = len * DIGIT_WIDTH;
10
10
  </script>
11
11
 
12
12
  <div style:overflow-x="auto" {...$$restProps}>
13
- <table style:width="100%">
13
+ <table>
14
14
  <tbody class:hljs={true}>
15
15
  {#each lines as line, i}
16
16
  {@const lineNumber = i + 1}
@@ -27,7 +27,6 @@ $: width = len * DIGIT_WIDTH;
27
27
  style:padding-top={isFirst ? "1em" : undefined}
28
28
  style:padding-bottom={isLast ? "1em" : undefined}
29
29
  style:width={width + "px"}
30
- style:min-width={width + "px"}
31
30
  >
32
31
  <code style:color="var(--line-number-color, currentColor)">
33
32
  {lineNumber}
@@ -43,6 +42,25 @@ $: width = len * DIGIT_WIDTH;
43
42
  </div>
44
43
 
45
44
  <style>
45
+ pre {
46
+ margin: 0;
47
+ }
48
+
49
+ table,
50
+ tr,
51
+ td {
52
+ padding: 0;
53
+ border: 0;
54
+ margin: 0;
55
+ vertical-align: baseline;
56
+ }
57
+
58
+ table {
59
+ width: 100%;
60
+ border-collapse: collapse;
61
+ border-spacing: 0;
62
+ }
63
+
46
64
  td {
47
65
  padding-left: var(--padding-left, 1em);
48
66
  padding-right: var(--padding-right, 1em);
package/README.md CHANGED
@@ -170,7 +170,7 @@ Use the `LineNumbers` component to render the highlighted code with line numbers
170
170
 
171
171
  ```svelte
172
172
  <script>
173
- import Hightlight, { LineNumbers } from "svelte-highlight";
173
+ import Highlight, { LineNumbers } from "svelte-highlight";
174
174
  import typescript from "svelte-highlight/languages/typescript";
175
175
  import atomOneDark from "svelte-highlight/styles/atom-one-dark";
176
176
 
@@ -225,7 +225,7 @@ Use `--style-props` to customize styles.
225
225
  {highlighted}
226
226
  --line-number-color="pink"
227
227
  --border-color="rgba(255, 255, 255, 0.2)"
228
- --padding-left="0"
228
+ --padding-left={0}
229
229
  --padding-right="3em"
230
230
  />
231
231
  </Highlight>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-highlight",
3
- "version": "7.0.0",
3
+ "version": "7.0.1",
4
4
  "license": "MIT",
5
5
  "description": "Syntax Highlighting for Svelte using highlight.js",
6
6
  "author": "Eric Liu (https://github.com/metonym)",