@@ -3,6 +3,8 @@ import snackbar from 'mods/snackbar/js/index.ts';
33import i18n from './i18n' ;
44
55export default class Panel {
6+ private highlight : HTMLElement
7+
68 private pre : HTMLElement
79
810 private wrapper : HTMLElement
@@ -21,6 +23,7 @@ export default class Panel {
2123 }
2224
2325 this . pre = this . code . parentElement as HTMLElement
26+ this . highlight = this . pre . parentElement as HTMLElement
2427
2528 this . ele = document . createElement ( 'div' )
2629 this . ele . className = 'code-block-panel'
@@ -30,7 +33,7 @@ export default class Panel {
3033 this . wrapper . appendChild ( this . ele )
3134
3235 this . maxLines ( )
33- this . language ( )
36+ this . title ( )
3437 this . lineNoButton ( )
3538 this . wrapButton ( )
3639 this . expandButton ( )
@@ -57,17 +60,14 @@ export default class Panel {
5760 }
5861 }
5962
60- // Show the code language.
61- private language ( ) {
62- const lang = this . code . getAttribute ( 'data-lang ' )
63- if ( ! lang || lang === 'fallback' ) {
63+ // Display the title
64+ private title ( ) {
65+ const title = this . highlight . getAttribute ( 'title ' )
66+ if ( title === null ) {
6467 return
6568 }
6669
67- const e = document . createElement ( 'span' )
68- e . className = 'code-block-lang'
69- e . innerText = lang
70- this . pre . appendChild ( e )
70+ this . code . setAttribute ( 'title' , title )
7171 }
7272
7373 private button ( name : string , callback : CallableFunction ) : HTMLButtonElement {
0 commit comments