Open
Conversation
Author
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
transformEntitieswhich is enabled by default that will handle HTML entities and transform them automatically - the current functionality. Passingfalsedisables 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
casefallthrough as a makeshiftgoto, 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 intodefaultto avoid the fallthrough, for example). This was the best balance between code readability and performance in my opinion.