-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't make regexp work #96
Comments
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗 |
Oh no regexes can be tricky. It looks like you have two spaces after dollar, have you tried using the specific white space regex: |
Thanks for your reply! I tried: On the built document, the Copy button copies the entire block, but does not omit the "$ " prompt. |
FWIW, the JavaScript regex "or" pattern looks to involve parentheses: https://www.w3schools.com/jsref/jsref_regexp_xy.asp. but I'm not having much luck permutating on that, either... |
@choldgraf just remembered that I left @wabernatScality hanging a bit here lol. I'm a bit out of ideas, without perhaps going into the code and trying to add more test cases |
@wabernatScality do you still have these issues? this is also something I don't know how to debug either, I am terrible with regexes :-/ it sounds like it might be a bit of time before we can figure out a solution, just FYI |
We have not found a solution. I've rolled out sphinx-copybutton with regexp turned off, hoping our own talent might be sufficiently bent out of shape to fix it as a challenge. In the meantime, we make do with '$ ' as our default "cropped" prompt. |
Sounds good - if anybody can figure out a fix for why this isn't working I am happy to review and cut a release quickly 👍 |
Any updates on this issue? I can also reproduce it with and without |
I am facing a similar issue (perhaps exactly the same). I was asked to setup a After quite a lot of debugging, my guess is that @wabernat was on the right track: ORs using
Both regexp validate at regexp101.com and match against the same set of examples.
To be honest, I have no idea how to fix this issue, since my regexp knowledge is for sure lower than @choldgraf 's 😅 |
Hello all, I am currently working on the same project as @wabernat was 3 years ago for the same company, and ran into the same problems, which led me to this issue ! We use a variety of prompts in the following formats:
(each one has a trailing space) I managed to get the regex to work by adding the following lines in our conf.py file:
The documentation is a bit unclear and feels like we have to use enclose the regular expression in a raw string for it to work, but it seems that it is not the case. Can anyone confirm or deny ? Also, the documentation should display basic examples of regex to copy-paste as is to the conf.py of a project, at least for testing purposes. Example: The following configuration will treat the string "# " or "$ " as prompts which will not be copied.
I can open a documentation PR if you agree with this proposal. Thanks ! Edit: behavior seems to be the same with or without the |
@stefanodavid You may have solved your issue already, but maybe try the following:
I do not know the regex best practices, but if it is either "cluster" or "single" + "# " or "$ " (which is only 4 possible prompts), maybe it is not worth factorizing everything! |
@Samy-Oubouaziz in the end I used indeed a similar approach to what you propose: to enumerate all possible prompts. However. as I mentioned, I had quite a number of different prompt (around12-14 IIRC, I left that project now so can't check), each with My comment however was more to point out that this extension currently does not support complex regexp with |
Thank you @stefanodavid ! This might be a good time to close this issue @choldgraf, and maybe open a doc PR for better regex explanations for users who are not familiar with it, including:
Thanks again ! |
When I try to use regular expressions in the copybutton_prompt_text field (with copybutton_remove_prompts and copybutton_prompt_is_regex set to True), sphinx-copybutton does not remove prompts.
To reproduce the behavior:
Expectations
I expect sphinx-copybutton to detect and omit from copying the user "
$
" OR root "#
" prompts (i.e., exclude both prompt strings from copying) .Environment
A virtual environment (Dockerized) running:
Additional context
I am embarrassed to open this as a bug report, as my assumption is that this is either my ineptitude with regexp (though I have tried every permutation that I can imagine) or a weird setup issue. Is there a canonical environment in which regexps are functional?
The text was updated successfully, but these errors were encountered: