This repository was archived by the owner on Nov 2, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +49
-18
lines changed Expand file tree Collapse file tree 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() {
195195
196196 if ( is_array ( $ tags ['code ' ] ) ) {
197197 $ tags ['code ' ]['data-lang ' ] = array ();
198+ $ tags ['code ' ]['lang ' ] = array ();
198199 } else {
199200 $ tags ['code ' ] = array (
200201 'data-lang ' => array (),
202+ 'lang ' => array (),
201203 );
202204 }
203205 return $ tags ;
Original file line number Diff line number Diff line change @@ -19,32 +19,61 @@ const addSyntaxToCodeBlock = ( settings ) => {
1919 return settings ;
2020 }
2121
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 {
2342 ...settings ,
2443
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+ } ,
3556 } ,
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+ ) ;
4170 } ,
42- } ,
71+ } ] ,
72+
4373 edit,
4474 save,
4575 } ;
4676
47- return newCodeBlockSettings ;
4877} ;
4978
5079// Register Filter
You can’t perform that action at this time.
0 commit comments