Take a screenshot of code that reads clearly
A screenshot cropped out of an editor brings everything with it — the cursor, the gutter icons, a stray tooltip, whatever theme you happen to be using at the wrong contrast for the person reading it. This makes the picture instead of capturing it: paste the snippet, pick a theme that reads well wherever it is going, and get an image with nothing in it but the code. Because the text is laid out rather than captured, it is crisp at any size instead of being tied to whatever your display was doing at the time, and you can export it as a vector if it is going into a document. Nothing you paste leaves the browser.