File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
components/dash-core-components/src/fragments Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -32,12 +32,20 @@ export default class DashMarkdown extends Component {
3232 }
3333
3434 highlightCode ( ) {
35+ const isHighlighted = node => {
36+ // a highlighted node will have <span> children which are what color the text
37+ return node . children . length > 0 ;
38+ } ;
39+
3540 if ( this . mdContainer ) {
3641 const nodes = this . mdContainer . querySelectorAll ( 'pre code' ) ;
3742
3843 if ( MarkdownHighlighter . hljs ) {
3944 for ( let i = 0 ; i < nodes . length ; i ++ ) {
40- MarkdownHighlighter . hljs . highlightElement ( nodes [ i ] ) ;
45+ if ( ! isHighlighted ( nodes [ i ] ) ) {
46+ nodes [ i ] . removeAttribute ( 'data-highlighted' ) ;
47+ MarkdownHighlighter . hljs . highlightElement ( nodes [ i ] ) ;
48+ }
4149 }
4250 } else {
4351 MarkdownHighlighter . loadhljs ( ) ;
You can’t perform that action at this time.
0 commit comments