Feature request: click to copy code

A feature that I believe would be of benefit to users is a ‘click-to-copy’ button at the top RH corner of a code box.

I trust that my description is clear enough as I’m sure you’ve all seen this kind of feature on many coding related websites, not least of which is GitHub.

My thanks to you for running this excellent Forum.

Good idea, and it’s a feature of Discourse:

This feature is off by default, but if your community could benefit from it, you can turn it on by enabling the show copy button on codeblocks site setting.

4 Likes

This would encourage folks to run the posted code (their own and others’) and surely improve the post content.

I’ve already spent a bunch of time dragging copy-cursors around on my phone with various degrees of success. This feature would speed up desktop/laptop copying, too.

NOTE: It only works on code blocks.

My post here at >> DISCOURSE.ORG << is an example. Hover over the code block.

@admins Please could you enable this feature? Thank you!

Should be on now!

6 Likes

Testing:

code block

Edit: Confirmed, thank you!

1 Like

Here’s a draft announcement:
ALL: The admin team has enabled a CodeCOPY feature in Discourse. You can now click on the ‘copy’ icon that appears when you hover over a code block. (Code blocks only, not in-line code.)

1 Like

Is there a category here for such announcements about discuss.python.org?

Thank you for this: I’m sure it will be beneficial to all.

Have a good day.

Not specifically. Discourse Feedback is probably the closest.

Good question that brings up an even better point: If there were a single separate or customary category for announcements, you’d have to navigate to it or subscribe to notices. …And then how do you direct the announcements to the user subgroup and/or category that the announcement applies to in order to broadcast it at the proper scope? (Users, Core Dev, PEP, Packaging, PSF, etc.)

A relatively clean solution would be to have a locked “Announcements” post pinned to the top of each forum for posting announcements relevant to that forum.

By the same token, a pinned Announcements post in the “General Discussion” category (that was proposed HERE with apparent consensus) would be the meta-location for site-wide announcements.

UPDATE: An ‘Enlarge Code’ (Wide View) button shows up in THIS POST, but not any other posts I’ve checked. Does anyone know about this? Maybe Discourse only embeds it into new code blocks…?

image

SOLVED:

print("code block test") #It's triggered by a line extending past the right edge of the code block frame.