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 {
32
32
}
33
33
34
34
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
+
35
40
if ( this . mdContainer ) {
36
41
const nodes = this . mdContainer . querySelectorAll ( 'pre code' ) ;
37
42
38
43
if ( MarkdownHighlighter . hljs ) {
39
44
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
+ }
41
49
}
42
50
} else {
43
51
MarkdownHighlighter . loadhljs ( ) ;
You can’t perform that action at this time.
0 commit comments