File tree Expand file tree Collapse file tree 1 file changed +17
-27
lines changed
Expand file tree Collapse file tree 1 file changed +17
-27
lines changed Original file line number Diff line number Diff line change 3030 console . error ( e ) ;
3131 }
3232
33- // Highlight.js is deferred to run after DOMContentLoaded. Wait for it
34- // to make sure it runs synchronously, so that tooltips can be added to
35- // code elements after they are highlighted.
36- if ( document . readyState === 'loading' ) {
37- window . addEventListener ( 'DOMContentLoaded' , highlightCodeAndAddTooltips ) ;
38- } else {
39- highlightCodeAndAddTooltips ( ) ;
33+ // Highlight.js, must run before tippy to allow tooltips in code.
34+ try {
35+ if ( typeof hljs !== 'undefined' ) {
36+ highlightCode ( ) ;
37+ }
38+ } catch ( e ) {
39+ console . error ( e ) ;
40+ }
41+
42+ try {
43+ if ( typeof tippy !== 'undefined' ) {
44+ addTooltips ( ) ;
45+ }
46+ } catch ( e ) {
47+ console . error ( e ) ;
4048 }
4149 }
4250
263271 descriptionsContainer . prepend ( selectElement ) ;
264272 }
265273
266- function highlightCodeAndAddTooltips ( ) {
267- // Highlight.js, must run before tippy to allow tooltips in code.
268- try {
269- if ( typeof hljs !== 'undefined' ) {
270- highlightCode ( ) ;
271- }
272- } catch ( e ) {
273- console . error ( e ) ;
274- }
275-
276- try {
277- if ( typeof tippy !== 'undefined' ) {
278- addTooltips ( ) ;
279- }
280- } catch ( e ) {
281- console . error ( e ) ;
282- }
283- }
284-
285274 function highlightCode ( ) {
286275 const cssSelector = [
287276 'pre code[class^="language-"]' ,
299288
300289 hljs . addPlugin ( hljsMergeHTMLPlugin ( ) ) ;
301290
302- hljs . highlightAll ( ) ;
291+ const blocks = document . querySelectorAll ( cssSelector ) ;
292+ blocks . forEach ( hljs . highlightElement ) ;
303293 }
304294
305295 function addTooltips ( ) {
You can’t perform that action at this time.
0 commit comments