diff --git a/modules/home/code-line.tsx b/modules/home/code-line.tsx index 06da7478..945ba826 100644 --- a/modules/home/code-line.tsx +++ b/modules/home/code-line.tsx @@ -21,8 +21,15 @@ export const CodeLine = ({ line }: { line: string }) => { return ; }; + const escapeHtml = (code: string): string => + code + .replace(/&/g, '&') + .replace(//g, '>'); + const highlightCode = (code: string) => { - return code + const safe = escapeHtml(code); + return safe .replace(/import|from|export|default|return|const|new/g, '$&') .replace(/'[^']*'/g, '$&') .replace(/"[^"]*"/g, '$&')