1- import { IGACAnnotation } from '../services/gac-annotations' ;
2- import Highlight from 'react-highlight' ;
3- import { useRef , useState , useMemo , useLayoutEffect } from 'react' ;
1+ import { useLayoutEffect , useMemo , useRef , useState } from 'react' ;
42import ReactMarkdown from 'react-markdown/with-html' ;
3+ import SyntaxHighlighter from 'react-syntax-highlighter' ;
4+ import { arduinoLight } from 'react-syntax-highlighter/dist/cjs/styles/hljs' ;
5+ import { IGACAnnotation } from '../services/gac-annotations' ;
56
67interface IAnnotatedSourceProps {
78 code : string ;
@@ -39,7 +40,6 @@ export function AnnotatedSource({ code, annotations }: IAnnotatedSourceProps) {
3940
4041 const [ activeAnnotation , setActiveAnnotation ] = useState < IGACAnnotation | null > ( null ) ;
4142
42- const highlightedCode = useMemo ( ( ) => < Highlight > { code } </ Highlight > , [ code ] ) ;
4343 const annotatedLines = useMemo ( ( ) => {
4444 const result = new Map < number , IGACAnnotation > ( ) ;
4545 for ( const annotation of annotations ) {
@@ -112,7 +112,17 @@ export function AnnotatedSource({ code, annotations }: IAnnotatedSourceProps) {
112112 < div className = "annotation-markers" ref = { markersRef } >
113113 < AnnotationMarkers annotations = { annotations } />
114114 </ div >
115- { highlightedCode }
115+ < SyntaxHighlighter
116+ language = "arduino"
117+ style = { arduinoLight }
118+ customStyle = { {
119+ marginTop : 0 ,
120+ padding : 0 ,
121+ background : 'transparent' ,
122+ } }
123+ >
124+ { code }
125+ </ SyntaxHighlighter >
116126 { activeAnnotation && (
117127 < div
118128 className = "annotation-info"
@@ -133,13 +143,6 @@ export function AnnotatedSource({ code, annotations }: IAnnotatedSourceProps) {
133143 position: relative;
134144 display: flex;
135145 }
136- .code-box > :global(pre) {
137- margin-top: 0;
138- }
139- .code-box > :global(pre > code) {
140- background: transparent;
141- padding: 0;
142- }
143146
144147 .annotation-markers {
145148 width: 8px;
0 commit comments