File tree 9 files changed +169
-90
lines changed
plugin-prismjs/tests/__snapshots__
plugin-shiki/tests/__snapshots__
tools/highlighter-helper/src 9 files changed +169
-90
lines changed Original file line number Diff line number Diff line change @@ -405,7 +405,7 @@ body > div {
405
405
- Type: ` boolean | CodeBlockTitleRender `
406
406
407
407
``` ts
408
- type CodeBlockTitleRender = (title : string ) => string
408
+ type CodeBlockTitleRender = (title : string , code : string ) => string
409
409
` ` `
410
410
411
411
- Default: ` true `
@@ -419,14 +419,14 @@ body > div {
419
419
**Input:**
420
420
421
421
` ` ` ` md {1}
422
- ` ` ` ts title =" Code Block Title "
422
+ ` ` ` ts title =" foo/baz.js "
423
423
console .log (' hello' )
424
424
` ` `
425
425
` ` ` `
426
426
427
427
**Output:**
428
428
429
- ` ` ` ts title =" Code Block Title "
429
+ ` ` ` ts title =" foo/baz.js "
430
430
console .log (' hello' )
431
431
` ` `
432
432
Original file line number Diff line number Diff line change @@ -399,7 +399,7 @@ body > div {
399
399
- Type: ` boolean | CodeBlockTitleRender `
400
400
401
401
``` ts
402
- type CodeBlockTitleRender = (title : string ) => string
402
+ type CodeBlockTitleRender = (title : string , code : string ) => string
403
403
` ` `
404
404
405
405
- Default: ` true `
@@ -413,14 +413,14 @@ body > div {
413
413
**Input:**
414
414
415
415
` ` ` ` md {1}
416
- ` ` ` ts title =" Code Block Title "
416
+ ` ` ` ts title =" foo/baz.js "
417
417
console .log (' hello' )
418
418
` ` `
419
419
` ` ` `
420
420
421
421
**Output:**
422
422
423
- ` ` ` ts title =" Code Block Title "
423
+ ` ` ` ts title =" foo/baz.js "
424
424
console .log (' hello' )
425
425
` ` `
426
426
Original file line number Diff line number Diff line change @@ -405,7 +405,7 @@ body > div {
405
405
- 类型:` boolean | CodeBlockTitleRender `
406
406
407
407
``` ts
408
- type CodeBlockTitleRender = (title : string ) => string
408
+ type CodeBlockTitleRender = (title : string , code : string ) => string
409
409
` ` `
410
410
411
411
- 默认值: ` true `
@@ -419,14 +419,14 @@ body > div {
419
419
**输入:**
420
420
421
421
` ` ` ` md {1}
422
- ` ` ` ts title =" 代码块标题 "
422
+ ` ` ` ts title =" foo/baz.js "
423
423
console .log (' hello' )
424
424
` ` `
425
425
` ` ` `
426
426
427
427
**输出:**
428
428
429
- ` ` ` ts title =" 代码块标题 "
429
+ ` ` ` ts title =" foo/baz.js "
430
430
console .log (' hello' )
431
431
` ` `
432
432
Original file line number Diff line number Diff line change @@ -401,7 +401,7 @@ body > div {
401
401
- 类型:` boolean | CodeBlockTitleRender `
402
402
403
403
``` ts
404
- type CodeBlockTitleRender = (title : string ) => string
404
+ type CodeBlockTitleRender = (title : string , code : string ) => string
405
405
` ` `
406
406
407
407
- 默认值: ` true `
@@ -415,14 +415,14 @@ body > div {
415
415
**输入:**
416
416
417
417
` ` ` ` md {1}
418
- ` ` ` ts title =" 代码块标题 "
418
+ ` ` ` ts title =" foo/baz.js "
419
419
console .log (' hello' )
420
420
` ` `
421
421
` ` ` `
422
422
423
423
**输出:**
424
424
425
- ` ` ` ts title =" 代码块标题 "
425
+ ` ` ` ts title =" foo/baz.js "
426
426
console .log (' hello' )
427
427
` ` `
428
428
Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1
1
:root {
2
- --code-title-c-text : var (--vp-c-text );
3
- --code-title-c-bg : var (--code-c-highlight-bg );
4
- --code-title-bar-c-bg : var (--code-c-bg );
5
- }
6
-
7
- [data-theme = ' dark' ] {
8
- --code-title-c-bg : #181819 ;
2
+ --code-title-c-text : var (--vp-c-text-mute );
3
+ --code-title-c-bg : var (--code-c-bg );
4
+ --code-title-divider : var (--code-c-highlight-bg , var (--code-c-text ));
9
5
}
10
6
11
7
.code-block-title {
18
14
overflow-x : auto ;
19
15
20
16
margin : 0.75rem 0 -0.75rem ;
21
- padding : 0 ;
17
+ padding : 0 12px ;
18
+ border-bottom : solid 1px var (--code-title-divider );
22
19
border-radius : 6px 6px 0 0 ;
23
20
24
21
background : var (--code-title-c-bg );
25
- list-style : none ;
26
22
27
23
white-space : nowrap ;
28
24
38
34
39
35
display : inline-block ;
40
36
41
- min-width : 3rem ;
42
37
margin : 0 ;
43
- padding : 6px 12px ;
44
- border-width : 0 ;
45
- border-radius : 6px 6px 0 0 ;
38
+ padding : 8px 12px ;
46
39
47
- background : var (--code-title-bar-c-bg );
48
40
color : var (--code-title-c-text );
49
41
50
- font-weight : 600 ;
42
+ font-weight : 500 ;
51
43
font-size : 0.875em ;
52
- line-height : 1.4 ;
44
+ line-height : 1.7 ;
53
45
54
46
transition : background var (--vp-t-color );
55
-
56
- & ::after {
57
- content : ' ' ;
58
-
59
- position : absolute ;
60
- bottom : 0 ;
61
- left : 100% ;
62
- z-index : 1 ;
63
-
64
- width : 6px ;
65
- height : 6px ;
66
-
67
- background : radial-gradient (
68
- 12px at right top ,
69
- transparent 50% ,
70
- var (--code-c-bg ) 50%
71
- );
72
- }
73
47
}
74
48
}
75
49
}
Original file line number Diff line number Diff line change 1
- export type CodeBlockTitleRender = ( title : string ) => string
1
+ export type CodeBlockTitleRender = ( title : string , code : string ) => string
2
2
3
3
export interface MarkdownItCodeBlockTitleOptions {
4
4
/**
Original file line number Diff line number Diff line change @@ -5,8 +5,13 @@ import type {
5
5
MarkdownItCodeBlockTitleOptions ,
6
6
} from './options.js'
7
7
8
- const defaultTitleRender : CodeBlockTitleRender = ( title : string ) =>
9
- `<div class="code-block-title-bar"><span class="title">${ title } </span></div>`
8
+ const defaultTitleRender : CodeBlockTitleRender = ( title , code ) =>
9
+ `<div class="code-block-title">
10
+ <div class="code-block-title-bar">
11
+ <span class="title" data-title="${ title } ">${ title } </span>
12
+ </div>
13
+ ${ code }
14
+ </div>`
10
15
11
16
export const codeBlockTitle = (
12
17
md : Markdown ,
@@ -31,6 +36,6 @@ export const codeBlockTitle = (
31
36
32
37
if ( ! title ) return rawCode
33
38
34
- return `<div class="code-block-title"> ${ titleRender ( title ) } ${ rawCode } </div>`
39
+ return titleRender ( title , rawCode )
35
40
}
36
41
}
You can’t perform that action at this time.
0 commit comments