Skip to content
This repository was archived by the owner on Jul 23, 2019. It is now read-only.

Allow to configure the HTML part of regexes#645

Open
oriolbcn wants to merge 3 commits into
joypixels:masterfrom
MarsBased:master
Open

Allow to configure the HTML part of regexes#645
oriolbcn wants to merge 3 commits into
joypixels:masterfrom
MarsBased:master

Conversation

@oriolbcn

Copy link
Copy Markdown

Why is this change needed?

Emojione does not replace emojis that are inside an <object> or <span> 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 understand the reasons for avoiding the content inside these tags, but in our case removing them does not cause any problem and solve these issues.

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>|<(?: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 #537

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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