Skip to content

Commit

Permalink
Merge 59d8d8f into 5153abf
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed May 29, 2024
2 parents 5153abf + 59d8d8f commit b7a0717
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 126 deletions.
85 changes: 33 additions & 52 deletions docs/plugins/markdown/prismjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,12 @@ export default {

- Details:

Configure code line numbers.

- `true`: Enable line numbers.
- `false`: Disable line numbers.
- `true`: enable line numbers.
- `false`: disabled line numbers.
- `number`: the minimum number of lines to enable line numbers.
For example, if you set it to 4, line numbers will only be enabled when your code block has at least 4 lines of code.

You can add `:line-numbers` / `:no-line-numbers` mark in your fenced code blocks to override the value set in config.

You can also customize the starting line number by adding `=` after `:line-numbers`. For example, `:line-numbers=2` means the line numbers in code blocks will start from `2`.
You can add `:line-numbers` / `:no-line-numbers` mark in your fenced code blocks to override the value set in config, and customize the beginning number by adding `=` after `:line-numbers`. For example, `:line-numbers=2` means the line numbers in code blocks will start from `2`.

**Input:**

Expand All @@ -70,13 +66,13 @@ const line2 = 'This is line 2'
const line3 = 'This is line 3'
```

```ts:no-line-numbers
```ts :no-line-numbers
// line-numbers is disabled
const line2 = 'This is line 2'
const line3 = 'This is line 3'
```

```ts:line-numbers=2
```ts :line-numbers=2
// line-numbers is enabled and start from 2
const line3 = 'This is line 3'
const line4 = 'This is line 4'
Expand All @@ -85,19 +81,19 @@ const line4 = 'This is line 4'

**Output:**

```ts:line-numbers
```ts :line-numbers
// line-numbers is enabled
const line2 = 'This is line 2'
const line3 = 'This is line 3'
```

```ts:no-line-numbers
```ts :no-line-numbers
// line-numbers is disabled
const line2 = 'This is line 2'
const line3 = 'This is line 3'
```

```ts:line-numbers=2
```ts :line-numbers=2
// line-numbers is enabled and start from 2
const line3 = 'This is line 3'
const line4 = 'This is line 4'
Expand All @@ -111,24 +107,16 @@ const line4 = 'This is line 4'

- Details:

Enable code line highlighting or not.

You can highlight specified lines of your code blocks by adding line ranges mark in your fenced code blocks.

Examples for line ranges mark:
Whether enable code line highlighting. You can highlight specified lines of your code blocks by adding line ranges mark in your fenced code blocks:

- Line ranges: `{5-8}`
- Multiple single lines: `{4,7,9}`
- Combined: `{4,7-13,16,23-27,40}`

::: tip
In the new version, we have rewritten the implementation of `highlightLines`. It now achieves line highlighting by adding the class name `highlighted` to `<span class="line">` within the code block.
:::

**Input:**

````md
```ts{1,7-9}
```ts {1,7-9}
import { defaultTheme } from '@vuepress/theme-default'
import { defineUserConfig } from 'vuepress'

Expand All @@ -144,7 +132,7 @@ export default defineUserConfig({

**Output:**

```ts{1,7-9}
```ts {1,7-9}
import { defaultTheme } from '@vuepress/theme-default'
import { defineUserConfig } from 'vuepress'

Expand All @@ -157,23 +145,6 @@ export default defineUserConfig({
})
```

### preWrapper

- Type: `boolean`

- Default: `true`

- Details:

Enable the extra wrapper of the `<pre>` tag or not.

The wrapper is required by the `lineNumbers`. That means, if you disable `preWrapper`, the line line numbers will also be disabled.

::: tip
You can disable it if you want to implement them in client side. For example,
[Prismjs Line Highlight](https://prismjs.com/plugins/line-highlight/) or [Prismjs Line Numbers](https://prismjs.com/plugins/line-numbers/).
:::

:::: tip

In the new version, some functionalities similar to [shiki](https://shiki.style/packages/transformers) have been implemented, allowing you to style code blocks using the same syntax.
Expand All @@ -192,9 +163,7 @@ The following features requires additional style to work, which should be handle

- Default: `false`

- Details:

Whether enable notation diff
- Details: Whether enable notation diff.

- Example:

Expand All @@ -213,9 +182,7 @@ The following features requires additional style to work, which should be handle

- Default: `false`

- Details:

Whether enable notation focus.
- Details: Whether enable notation focus.

- Example:

Expand All @@ -234,9 +201,7 @@ The following features requires additional style to work, which should be handle

- Default: `false`

- Details:

Whether enable notation highlight.
- Details: Whether enable notation highlight.

- Example:

Expand All @@ -255,9 +220,7 @@ The following features requires additional style to work, which should be handle

- Default: `false`

- Details:

Whether enable notation error level.
- Details: Whether enable notation error level.

- Example:

Expand All @@ -269,3 +232,21 @@ The following features requires additional style to work, which should be handle

- Also see:
- [Shiki > Notation Error Level](https://shiki.style/packages/transformers#transformernotationerrorlevel)

### preWrapper

- Type: `boolean`

- Default: `true`

- Details:

Adds extra wrapper outside `<pre>` tag or not.

The wrapper is required by the `lineNumbers`. That means, if you disable `preWrapper`, the line line numbers will also be disabled.

::: tip

You can disable it if you want to implement them in client side. For example, [Prismjs Line Highlight](https://prismjs.com/plugins/line-highlight/) or [Prismjs Line Numbers](https://prismjs.com/plugins/line-numbers/).

:::
Loading

0 comments on commit b7a0717

Please sign in to comment.