executablebooks / sphinx-copybutton

Add a "copy" button to code blocks in Sphinx
https://sphinx-copybutton.readthedocs.io/en/latest/
MIT License
255 stars 49 forks source link

ID of the `div.highlight pre` element gets overwritten #115

Open So-Cool opened 3 years ago

So-Cool commented 3 years ago

Describe the bug

The extension overwrites the id of the div.highlight pre element with codecell# (if it already has one). The expected behaviour would be to use the id that already exists.

To Reproduce

  1. Create a code block with an id, e.g.:
    <div class="highlight">
       <pre id="my-id">
           code...
       </pre>
    </div>
  2. Open the HTML page.
  3. my-id is overwritten with codecell0.

Expected behavior

my-id is preserved and used to facilitate the extension functionality.

Environment

Additional context

Jupyter Book: 0.9.1
MyST-NB: 0.10.1
Sphinx Book Theme: 0.0.39
MyST-Parser: 0.12.10
Jupyter-Cache: 0.4.1
NbClient: 0.5.1
welcome[bot] commented 3 years ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada: