This repository was archived by the owner on Nov 2, 2024. It is now read-only.
File tree 2 files changed +49
-18
lines changed 2 files changed +49
-18
lines changed Original file line number Diff line number Diff line change @@ -195,9 +195,11 @@ function mkaz_prism_theme_css_ver() {
195
195
196
196
if ( is_array ( $ tags ['code ' ] ) ) {
197
197
$ tags ['code ' ]['data-lang ' ] = array ();
198
+ $ tags ['code ' ]['lang ' ] = array ();
198
199
} else {
199
200
$ tags ['code ' ] = array (
200
201
'data-lang ' => array (),
202
+ 'lang ' => array (),
201
203
);
202
204
}
203
205
return $ tags ;
Original file line number Diff line number Diff line change @@ -19,32 +19,61 @@ const addSyntaxToCodeBlock = ( settings ) => {
19
19
return settings ;
20
20
}
21
21
22
- const newCodeBlockSettings = {
22
+ const blockAttributes = {
23
+ ...settings . attributes ,
24
+ language : {
25
+ type : 'string' ,
26
+ selector : 'code' ,
27
+ source : 'attribute' ,
28
+ attribute : 'data-lang' ,
29
+ } ,
30
+ lineNumbers : {
31
+ type : 'boolean' ,
32
+ } ,
33
+ title : {
34
+ type : 'string' ,
35
+ source : 'attribute' ,
36
+ selector : 'pre' ,
37
+ attribute : 'title' ,
38
+ } ,
39
+ } ;
40
+
41
+ return {
23
42
...settings ,
24
43
25
- attributes : {
26
- ...settings . attributes ,
27
- language : {
28
- type : 'string' ,
29
- selector : 'code' ,
30
- source : 'attribute' ,
31
- attribute : 'data-lang' ,
32
- } ,
33
- lineNumbers : {
34
- type : 'boolean' ,
44
+ attributes : blockAttributes ,
45
+
46
+ deprecated : [ {
47
+ // old attributes
48
+ attributes : {
49
+ ...blockAttributes ,
50
+ language : {
51
+ type : 'string' ,
52
+ selector : 'code' ,
53
+ source : 'attribute' ,
54
+ attribute : 'lang' ,
55
+ } ,
35
56
} ,
36
- title : {
37
- type : 'string' ,
38
- source : 'attribute' ,
39
- selector : 'pre' ,
40
- attribute : 'title' ,
57
+ migrate : ( attributes ) => { return attributes ; } ,
58
+ // old save function
59
+ save : ( { attributes } ) => {
60
+ let cls = '' ;
61
+ cls = ( attributes . language ) ? 'language-' + attributes . language : '' ;
62
+ cls = ( attributes . lineNumbers ) ? cls + ' line-numbers' : cls ;
63
+ return (
64
+ < pre title = { attributes . title } >
65
+ < code lang = { attributes . language } className = { cls } >
66
+ { attributes . content }
67
+ </ code >
68
+ </ pre >
69
+ ) ;
41
70
} ,
42
- } ,
71
+ } ] ,
72
+
43
73
edit,
44
74
save,
45
75
} ;
46
76
47
- return newCodeBlockSettings ;
48
77
} ;
49
78
50
79
// Register Filter
You can’t perform that action at this time.
0 commit comments