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

Add support for phone numbers, and for highlighting only pre-tagged matches #36

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

Conversation

granoff
Copy link

@granoff granoff commented Aug 9, 2015

Phone number support is provided using the phone number data detector. Some refactoring of existing code streamlined this enhancement.

There is also the addition of a flag that prevents matches that do not already have a link attribute from being decorated and made tappable. I needed this because the phone number data detector will match text like "phone number 508-555-1234" rather than just "508-555-1234" and I wanted patterns like the latter highlighted. Similarly, words like "toll free" are also picked up if they precede a phone number.

I had already written code in my own project to find and decorate just the phone numbers, so it made sense to add support to this class to honor pre-set links and their text and ignore matches without a pre-set link.

The use case for the latter part is a string with several phone numbers, not all of which are callable (e.g. a FAX number). By pre-decorating the callable numbers only, and setting the new ignoreMatchesWithoutLinkAttribute flag, only those matching text ranges already having a link are decorated by the class.

I also updated the demo app.

@jonataspc
Copy link

Great job man! That was exacty what I was looking for.

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.

2 participants