@@ -102,7 +102,7 @@ overwrite sphinx-copybutton's behavior.
102102Strip and configure input prompts for code cells
103103------------------------------------------------
104104
105- By default, ``sphinx-copybutton `` will remove Python prompts (`` >>> `` ) from
105+ By default, ``sphinx-copybutton `` will remove Python prompts (" >>> " ) from
106106the beginning of each copied line. If it detects these prompts, then *only *
107107the lines that contain prompts will be copied (after removing the prompt text).
108108If no lines with prompts are found, then the full contents of the cell will be
@@ -140,8 +140,9 @@ To disable this behavior, use the following configuration in ``conf.py``:
140140 Configure whether the input prompts should be stripped
141141~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
142142
143+ By default, sphinx-copybutton will remove the prompt text from lines
143144according to the value of ``copybutton_prompt_text `` (by default,
144- this value is `` >>> `` ).
145+ this value is " >>> " ).
145146
146147To disable this behavior and copy the full text of lines with prompts
147148(for example, if you'd like to copy *only * the lines with prompts, but not
@@ -154,36 +155,11 @@ strip the prompts), use the following configuration in ``conf.py``:
154155 Use a different copy button image
155156---------------------------------
156157
157- To use a different image for your copy buttons, the easiest thing to do is
158- to add a small bit of javascript to your Sphinx build that points the image
159- to something new. Follow these steps:
158+ To use a different image for your copy buttons, do the following:
160159
161- 1. Create a new javascript file in your site's static folder
162- (e.g., ``_static/js/custom.js ``). In it, put the following code:
163-
164- .. code-block :: javascript
165-
166- const updateCopyButtonImages = () => {
167- const copybuttonimages = document .querySelectorAll (' a.copybtn img' )
168- copybuttonimages .forEach ((img , index ) => {
169- img .setAttribute (' src' , ' path-to-new-image.svg' )
170- })
171- }
172-
173- runWhenDOMLoaded (updateCopyButtonImages)
174-
175-
176- 2. Add this javascript file to your `conf.py ` configuration like so:
177-
178- .. code-block :: python
179-
180- def setup (app ):
181- app.add_javascript(' js/custom.js' );
182-
183- This will replace the copybutton images each time the page loads!
184-
185- **If you know of a better way to do this with sphinx, please don't hesitate to
186- recommend something! **
160+ 1. Place the image in the ``_static/ `` folder of your site.
161+ 2. Set the ``copybutton_image_path `` variable in your ``conf.py `` to be the
162+ path to your image file, **relative to ** ``_static/ ``.
187163
188164Development
189165===========
0 commit comments