sphinx-copybutton icon indicating copy to clipboard operation
sphinx-copybutton copied to clipboard

Default regular expression for the copy button fails for double digit ipython cells

Open mosc9575 opened this issue 7 months ago • 0 comments

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]: ', ' ...: ', ' .....: '

mosc9575 avatar Jul 22 '24 08:07 mosc9575