diff --git a/src/code/code.test.tsx b/src/code/code.test.tsx index 653c54c..e9fd11e 100644 --- a/src/code/code.test.tsx +++ b/src/code/code.test.tsx @@ -379,7 +379,7 @@ describe('Code', () => { background-color: var(--codice-control-color); } - }
test
" + }
test
" `) }) diff --git a/src/code/code.tsx b/src/code/code.tsx index 209dc36..b4f6953 100644 --- a/src/code/code.tsx +++ b/src/code/code.tsx @@ -16,7 +16,7 @@ const getPresetByExt = (ext: string) => { case 'py': return presets.python case 'rs': - return presets.rust + return presets.rust default: return undefined } @@ -63,19 +63,19 @@ function generateHighlightedLines( .map((child, childIndex) => { const { tagName: Token, type, children, properties } = child return ( - {(children[0].value)} ) }) - + return ( - void }) { if (!title && !controls) return null return ( -
@@ -135,16 +135,16 @@ export function CodeHeader({
) : null} - + {title ? : null} ) } -function CodeFrame({ - children, +function CodeFrame({ + children, preformatted, asMarkup, -}: { +}: { children: React.ReactNode preformatted: boolean asMarkup: boolean @@ -186,8 +186,8 @@ export function Code({ asMarkup?: boolean extension?: string } & React.HTMLAttributes) { - const lineElements = useMemo(() => - asMarkup + const lineElements = useMemo(() => + asMarkup ? code : generateHighlightedLines(code, highlightLines, lineNumbers, title, extension), [code, highlightLines, lineNumbers, title, extension, asMarkup] @@ -196,9 +196,9 @@ export function Code({ return ( // Add both attribute because it's both root component and child component (of editor)
diff --git a/src/editor/editor.test.tsx b/src/editor/editor.test.tsx index 77a8d61..24c6780 100644 --- a/src/editor/editor.test.tsx +++ b/src/editor/editor.test.tsx @@ -121,7 +121,7 @@ describe('Code', () => { background-color: var(--codice-control-color); } - }