-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Custom regexp flags for RegExp Replace In Note Button Action #372
Comments
After more trial and error I got a working regex that won't replace itself by prefixing the query with I also think that it would be immensly helpful to add the
Though I appreciate it's a potential breaking change to existing expressions, so maybe the flags could be set in the button builder instead? (Which would allow for the other regex flags to be used if people needed) |
A flags option sounds like a good idea, with the fallback being
That does not sound feasible to me. The plugin would need to somehow modify the regexp to make it not match the button and I have no idea how I would do that. Another thing that complicates this is that not every button knows where it is located in the file (due to limited information available in the obsidian API). |
I completely appreciate this and had the same thought myself.
My hope was some wizardry could be done with something similar to the "replace self" functionality (since this is how I am handling it at the moment). I'll admit I've not looked into how it works, but the replace self means the button has someway to identify itself as a button(?). My thinking is that a copy of the original button could be taken, regex replace run, then the original button inserted back over the resulting button... Flags would go a long way to helping with this. |
This does not work because we do not know how many lines above the button have been changed. E.g. the regex could insert 5 lines above the button position (which we can't know reliably) and if we try to re-insert the button we reinsert it at the wrong place. |
Please fill out these Check-boxes
This Issue Occurs on
Plugin Version
1.1.2
Describe the Issue
The regexpreplaceinnote action does not seem to work as expected. When pressing the button to replace the regex in the file, the expression in the button recognises and replaces itself, often breaking the button syntax.
Even the example in the docs page doesn't function correctly.
https://www.moritzjung.dev/obsidian-meta-bind-plugin-docs/reference/buttonactions/regexpreplaceinnote/
Steps to Reproduce
Expected Behavior
I would expect the button to not replace the regex in itself.
As an aside, I have tried changing the expression to handle this scenario using the regex start and end of string tokens (^ and $) as well as trying to set the flags (g m i e s etc) but can't seem to work out if / how these would be applied. Could the docs be updated with more complex examples that cover setting expression flags?
The text was updated successfully, but these errors were encountered: