Skip to content

Commit

Permalink
ENH: Exclude unselectable text from being copied (update) (#178)
Browse files Browse the repository at this point in the history
Co-authored-by: Brian Carlsen <carlsen.bri@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Sep 29, 2022
1 parent 6599429 commit cd2440f
Show file tree
Hide file tree
Showing 8 changed files with 1,768 additions and 6 deletions.
19 changes: 19 additions & 0 deletions docs/use.md
Expand Up @@ -366,3 +366,22 @@ button.copybtn {
See the [Sphinx documentation on custom CSS for more information](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_static_path).
[regex101]: https://regex101.com
## Exclude text from being copied
You may exclude elements matching CSS selectors from being copied by
specifying the `copybutton_exclude` option in ``conf.py``. For
example, a viewer usually doesn't want to copy the line numbers, and
CSS provides a way to exclude this. This option implements that
option for sphinx-copybutton as well.
```{code-block} python
copybutton_exclude = '.exclude_me'
```
By default `.linenos, .gp` are excluded. If you specify the
`copybutton_exclude` option it will replace the default. `.linenos`
is the Sphinx default for line numbers, and `.gp` is Pygments (the
default highlighter of Sphinx) for "prompt", e.g. `$` in a
shell-session. `.gp` is excluded in upstream Sphinx by default.

0 comments on commit cd2440f

Please sign in to comment.