Skip to content

Commit

Permalink
docs: add clarification comment why \n\n replace is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
tkajtoch committed Jun 1, 2023
1 parent da540ee commit de36c35
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/code/code_block_copy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]
);
Expand Down

0 comments on commit de36c35

Please sign in to comment.