sphinx-copybutton
sphinx-copybutton copied to clipboard
Default regular expression for the copy button fails for double digit ipython cells
Context
If ipython is used to run the code examples in the documentation and there are more than 9 cells, the regular expression suggested in using regexp prompt identifiers does not match the continuation and as a result does not copy the complete examples.
See the issue https://github.com/pydata/xarray/issues/9263 for an GitHub issue and https://docs.xarray.dev/en/stable/user-guide/io.html#hdf5 for a failing example.
Proposal
I suggest to update the section using regexp prompt identifiers in the docs.
The regular expression could be
copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.{3,}: | {5,8}: "
copybutton_prompt_is_regexp = True
which would also match the continuation
Prompt Name | RegEx Pattern | Matched String Examples |
---|---|---|
ipython and qtconsole + continuation |
In \[\d*\]: {2,5}\.{3,}: |
'In []: ' , 'In [999]: ' , ' ...: ' , ' .....: ' |