Skip to content

Commit

Permalink
copybutton_exclude: Add documentation (copied from executablebooks#138)
Browse files Browse the repository at this point in the history
- Re-add documentation from PR executablebooks#138 - that PR got conflicted with a
  docs rearrangement, so I add the docs back in one chunk now.  I
  include my own suggestions in that PR.
  • Loading branch information
rkdarst committed Sep 13, 2022
1 parent 6094cf3 commit 0674a7d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/use.md
Original file line number Diff line number Diff line change
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 0674a7d

Please sign in to comment.