Skip to content

Commit cd2440f

Browse files
rkdarstbicarlsenpre-commit-ci[bot]
authored
ENH: Exclude unselectable text from being copied (update) (#178)
Co-authored-by: Brian Carlsen <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 6599429 commit cd2440f

File tree

8 files changed

+1768
-6
lines changed

8 files changed

+1768
-6
lines changed

docs/use.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,22 @@ button.copybtn {
366366
See the [Sphinx documentation on custom CSS for more information](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_static_path).
367367
368368
[regex101]: https://regex101.com
369+
370+
371+
## Exclude text from being copied
372+
373+
You may exclude elements matching CSS selectors from being copied by
374+
specifying the `copybutton_exclude` option in ``conf.py``. For
375+
example, a viewer usually doesn't want to copy the line numbers, and
376+
CSS provides a way to exclude this. This option implements that
377+
option for sphinx-copybutton as well.
378+
379+
380+
```{code-block} python
381+
copybutton_exclude = '.exclude_me'
382+
```
383+
By default `.linenos, .gp` are excluded. If you specify the
384+
`copybutton_exclude` option it will replace the default. `.linenos`
385+
is the Sphinx default for line numbers, and `.gp` is Pygments (the
386+
default highlighter of Sphinx) for "prompt", e.g. `$` in a
387+
shell-session. `.gp` is excluded in upstream Sphinx by default.

0 commit comments

Comments
 (0)