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

Create Insert Around Use Case #60

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jamespeacock
Copy link

For any use case where the goal is to preserve the original text keyword and prepend/append to it, these changes allow for that without replacing the original text with the perhaps differently cased keyword text that matches.

For HTML highlighting in particular, this will be incredibly useful.

These code changes do not affect any other use case, and the custom replacement is optional. I have also included an example in the README for how this could be used.

For the following use case: Inserting a custom <span></span> tag (or any html tag) around a keyword. I want the replacement to use the original sentence word, not the keyword. If I am doing case insensitive matching (most of the time), I want the inserted tag to preserve the original word. 

With the current implementation, this is impossible to accomplish without switching to case sensitive matching. This small intervention allows for custom replacement without affecting anything else.
@coveralls
Copy link

coveralls commented Aug 28, 2018

Coverage Status

Coverage decreased (-0.3%) to 98.973% when pulling 142889e on jamespeacock:master into 5591859 on vi3k6i5:master.

@jamespeacock
Copy link
Author

Will create tests to cover this new usage if you let me know whether this is an acceptable addition to the Keyword Processor.

@jamespeacock
Copy link
Author

Additionally, perhaps this could be a separate method that takes in a 'prepend' and an 'append' rather than a 'replacement' and this could eliminate the need for str.replace() in keyword.py:644

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

Successfully merging this pull request may close these issues.

None yet

2 participants