-
Notifications
You must be signed in to change notification settings - Fork 145
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
Proposal: wrap combine mode #71
Comments
Thanks for writing this up. 👍 Seems like a good idea! I'm pondering a slight re-write of the lib (the code is getting a bit difficult to maintain), and this definitely seems like a feature worth putting in (especially the 'combine' mode). Not sure of timeline, but shall update this ticket when the time comes. |
FWIW, I had ported my code to Fibrio so I could use it easily on the server. The author of that project also refactored the code, so it might be helpful to look at. |
I noticed back in 2012 that @padolsey mentioned it as 1 of 2 solutions to solve the problem in https://j11y.io/javascript/replacing-text-in-the-dom-solved/ |
@hftf Are you aware of any forks that implement this feature? |
@pjebs I am not aware of any, no. In my opinion, this is the main feature I would expect to bring the project up to a 1.0 milestone. |
I have created a $30 USD bounty for anyone who can solve this: |
Do you think this may be relevant: https://github.com/bfred-it/zip-text-nodes (in some way)? |
Would love this too! |
Introduction
The main idea of this library is to split a match into portions when it crosses element boundaries.
As expected, the following code splits the matched word
b1b2
among two<w>
elements:However, if the entire match corresponds to properly-nested HTML, then it is possible to just use a single element to wrap the match. So instead of the following:
the two portions
b1
andb2
could be combined as such:Proposal
I think it could be useful to add this behavior in a new option called
wrapCombineMode
.separate
combine
Otherwise, fall back to
separate
.split
(If the entire match encompasses balanced HTML, it is wrapped.
Otherwise, split up elements that cross the edges of the match.)
Here are some test cases (spaced out for legibility):
Basic balanced
Complex balanced
Unbalanced
The text was updated successfully, but these errors were encountered: