Skip to content
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

Replacement functionality, or index #10

Open
konklone opened this issue May 6, 2014 · 0 comments
Open

Replacement functionality, or index #10

konklone opened this issue May 6, 2014 · 0 comments

Comments

@konklone
Copy link
Contributor

konklone commented May 6, 2014

It's impossible to do find/replace with walverine results right now, because there's not a reliable match index brought back for results, no regexes exposed for Citation to use, and there's no replacement functionality built into Walverine itself.

Either would work, and I'm honestly not sure which is better from Citation's end.

As of issue press time, I'm planning to go with a solution that does a second pass over the whole string for replacement. It'll first detect all cites without replacing, then re-pass doing a split() on a string with the same combined regex, and join the string back together using the original detected cites (after replacement) as the joining hinges.

This approach would require walverine to offer its own replacement feature, or to expose a Citation-like API, with some sort of final regex(es) I could combine alongside other citators'.

If walverine instead only returned a match index, and Citation implemented replacement by using detected indices of all results, and then bookkeeping those indices (and updating them) as strings are replaced and the length is changed -- then I could also do it that way.

I'm not sure what's better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant