svelte-highlight 7.0.1 → 7.1.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 +12 -0
- package/LineNumbers.svelte +2 -1
- package/LineNumbers.svelte.d.ts +5 -0
- package/README.md +16 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,18 @@ 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.1.1](https://github.com/metonym/svelte-highlight/releases/tag/v7.1.1) - 2022-12-31
|
|
9
|
+
|
|
10
|
+
**Fixes**
|
|
11
|
+
|
|
12
|
+
- republish package
|
|
13
|
+
|
|
14
|
+
## [7.1.0](https://github.com/metonym/svelte-highlight/releases/tag/v7.1.0) - 2022-12-31
|
|
15
|
+
|
|
16
|
+
**Features**
|
|
17
|
+
|
|
18
|
+
- add `startingLineNumber` prop to `LineNumbers`
|
|
19
|
+
|
|
8
20
|
## [7.0.1](https://github.com/metonym/svelte-highlight/releases/tag/v7.0.1) - 2022-12-30
|
|
9
21
|
|
|
10
22
|
**Fixes**
|
package/LineNumbers.svelte
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>export let highlighted;
|
|
2
2
|
export let hideBorder = false;
|
|
3
3
|
export let wrapLines = false;
|
|
4
|
+
export let startingLineNumber = 1;
|
|
4
5
|
const DIGIT_WIDTH = 12;
|
|
5
6
|
const MIN_DIGITS = 2;
|
|
6
7
|
$: lines = highlighted.split("\n");
|
|
@@ -13,7 +14,7 @@ $: width = len * DIGIT_WIDTH;
|
|
|
13
14
|
<table>
|
|
14
15
|
<tbody class:hljs={true}>
|
|
15
16
|
{#each lines as line, i}
|
|
16
|
-
{@const lineNumber = i +
|
|
17
|
+
{@const lineNumber = i + startingLineNumber}
|
|
17
18
|
{@const isFirst = i === 0}
|
|
18
19
|
{@const isLast = i === lines.length - 1}
|
|
19
20
|
<tr>
|
package/LineNumbers.svelte.d.ts
CHANGED
|
@@ -215,6 +215,11 @@ declare const __propDef: {
|
|
|
215
215
|
* @default false
|
|
216
216
|
*/
|
|
217
217
|
hideBorder?: boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Specify which starting line number should be displayed.
|
|
220
|
+
* @default 1
|
|
221
|
+
*/
|
|
222
|
+
startingLineNumber?: number;
|
|
218
223
|
/**
|
|
219
224
|
* Set to `true` for lines to wrap.
|
|
220
225
|
* @default false
|
package/README.md
CHANGED
|
@@ -231,6 +231,16 @@ Use `--style-props` to customize styles.
|
|
|
231
231
|
</Highlight>
|
|
232
232
|
```
|
|
233
233
|
|
|
234
|
+
### Custom Starting Line Number
|
|
235
|
+
|
|
236
|
+
The line number starts at `1`. Customize this via the `startingLineNumber` prop.
|
|
237
|
+
|
|
238
|
+
```svelte
|
|
239
|
+
<Highlight language={typescript} {code} let:highlighted>
|
|
240
|
+
<LineNumbers {highlighted} startingLineNumber={42} />
|
|
241
|
+
</Highlight>
|
|
242
|
+
```
|
|
243
|
+
|
|
234
244
|
## Language Targeting
|
|
235
245
|
|
|
236
246
|
All `Highlight` components apply a `data-language` attribute on the codeblock containing the language name.
|
|
@@ -368,11 +378,12 @@ In the example below, the `HighlightAuto` component and injected styles are dyna
|
|
|
368
378
|
|
|
369
379
|
#### Props
|
|
370
380
|
|
|
371
|
-
| Name
|
|
372
|
-
|
|
|
373
|
-
| highlighted
|
|
374
|
-
| hideBorder
|
|
375
|
-
| wrapLines
|
|
381
|
+
| Name | Type | Default value |
|
|
382
|
+
| :----------------- | :-------- | :------------- |
|
|
383
|
+
| highlighted | `string` | N/A (required) |
|
|
384
|
+
| hideBorder | `boolean` | `false` |
|
|
385
|
+
| wrapLines | `boolean` | `false` |
|
|
386
|
+
| startingLineNumber | `number` | `1` |
|
|
376
387
|
|
|
377
388
|
`$$restProps` are forwarded to the top-level `div` element.
|
|
378
389
|
|