sphinx-copybutton
sphinx-copybutton copied to clipboard
[Improvement suggestion] Use Class Tag to enable any element copy to clipboard
I checked your code, looks like it assign a unique copy to each code block, and use that ID to copy code block to clipboard.
I am wondering, is it possible to just assign a special class to any html element, then your library automatically assign an ID to it, and do the same trick?
If you can implement that, you can define a custom rst:
.. role::
:class: scb
Then you can use this to allow copy anything to clipboard:
Copy :scb:`This` to clipboard.
How's that sounds?
Hmmm - yep that does seem like it should be possible. Currently it just looks for div.highlight pre sections, but if there were a "special" class that sphinx-copybutton knew to look for, you could make these contents copyable. The CSS might not look as seamless in this case though :-/
I believe the code in Pull Request 138 could be easily adapted to add this functionality.