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

Allow to configure the HTML part of regexes #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oriolbcn
Copy link

Why is this change needed?

Emojione does not replace emojis that are inside an or tag. This can be problematic in some scenarios. In our case this is problematic when processing content generated by an editor (TinyMCE), since the editor generates spans to format text.

I don't have the full context to understand the reasons behind the decision to avoid the content inside these tags, but in our case removing them does not cause any problem and solve the problem.

What's the change

The change makes the part of the regexes that match HTML configurable, so that by default it keeps the same behaviour but, if wanted, a new regex can be provided. In our case, the same regex without the part.

The ugly part is that when the HTML regex is changed, the other regexes need to be recomputed, that's why I added the computeRegexes method, so you would use it like:

emojione.htmlRegexp = "<object[^>]>.?

|<(?:object|embed|svg|img|div|span|p|a)[^>]*>";
emojione.computeRegexes();

Making this more clean would require moving all the regexes inside methods and that's a bigger change.

The change allows to fix joypixels/emojione#537 from the old repo

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.

emojione.toImage() does not work when emoji is within span tag
1 participant