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 transformEntities option #120

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

Add transformEntities option #120

wants to merge 1 commit into from

Conversation

Qix-
Copy link

@Qix- Qix- commented Dec 10, 2020

Ref #105

A bit of context is in #105 (comment) but ultimately this parser should not be transforming HTML entities for the user - that's up to the compiler or the user agent.

While I personally believe this functionality should be stripped from this package entirely and downstream consumers should be the ones to make that decision, I figured that'd be less palatable than keeping things backwards compatible.

Therefore, this PR introduces the option transformEntities which is enabled by default that will handle HTML entities and transform them automatically - the current functionality. Passing false disables this and leaves HTML entities untouched.

This is imperative for proper parsing for many non-React frameworks.


A note about the implementation: to keep things performant, I (ab)use an explicit case fallthrough as a makeshift goto, avoiding duplicated code or more string fetches, etc. The branch is inevitable, but thankfully only occurs if & is detected (which is much less often than if it were to be put into default to avoid the fallthrough, for example). This was the best balance between code readability and performance in my opinion.

@Qix-
Copy link
Author

Qix- commented Dec 10, 2020

By the way, Travis CI removed support for open source projects as of Nov 2. Best to move to Circle or Actions or something if you want to keep automated testing working.

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

1 participant