Skip to content

Conversation

bmorelli25
Copy link
Member

@bmorelli25 bmorelli25 commented Mar 12, 2025

Closes #720.

Tested on console code blocks and non-console code blocks:

cursorful-video-1741823540522.mp4

Signed-off-by: bmorelli25 <brandon.morelli@elastic.co>
@Copilot Copilot AI review requested due to automatic review settings March 12, 2025 23:47
@bmorelli25 bmorelli25 added the bug label Mar 12, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes code copying behavior in Console blocks by updating the logic for retrieving text from code elements.

  • Changes the text extraction from using the whole target element to iterating over individual elements
  • Joins the filtered text from each block using newline characters
Comments suppressed due to low confidence (2)

src/Elastic.Markdown/Assets/copybutton.ts:246

  • The change now extracts text only from elements. Consider adding a fallback behavior in case target.querySelectorAll('code') returns an empty list to ensure no necessary text is inadvertently omitted.
let text = Array.from(target.querySelectorAll('code')).map(code => filterText(code, excludes)).join('\n');

src/Elastic.Markdown/Assets/copybutton.ts:246

  • Ensure that the new extraction logic meets all requirements for cases where the target element may contain non- text that should be included in the copied output.
let text = Array.from(target.querySelectorAll('code')).map(code => filterText(code, excludes)).join('\n');

@bmorelli25 bmorelli25 requested a review from a team March 13, 2025 00:11
@Mpdreamz Mpdreamz merged commit 3cb07b9 into main Mar 13, 2025
8 of 9 checks passed
@Mpdreamz Mpdreamz deleted the fix-code-copy-in-console-blocks branch March 13, 2025 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy code sample button omits HTTP request line
2 participants