From de36c350f534aaaca26e0f1a63c8ccfd3672ef72 Mon Sep 17 00:00:00 2001 From: Tomasz Kajtoch Date: Thu, 1 Jun 2023 16:15:03 +0200 Subject: [PATCH] docs: add clarification comment why \n\n replace is needed --- src/components/code/code_block_copy.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/code/code_block_copy.tsx b/src/components/code/code_block_copy.tsx index 3469810cc70f..ea3eb0722097 100644 --- a/src/components/code/code_block_copy.tsx +++ b/src/components/code/code_block_copy.tsx @@ -32,6 +32,8 @@ export const useCopy = ({ // Normalize line terminations to match native JS format ?.replace(NEW_LINE_REGEX_GLOBAL, '\n') // Reduce two or more consecutive new line characters to a single one + // This is needed primarily because of how syntax highlighting + // generated DOM elements affect `innerText` output. .replace(/\n{2,}/g, '\n') || '', [_innerText] );