Repository navigation
Fix position-based highlighting when a text contains ampersand and other reserved HTML entities - #20595
Merged
Conversation
Pull Request Test Coverage Report for Build 5963441257
💛 - Coveralls |
…ess-seo into 179-fix-position-based-highlighting-when-a-text-contains-ampersand-and-other-reserved-htlm-entities
Contributor
|
This solution currently does not work for the block editor, because there we do not take HTML entities into account when we remove HTML tags in |
…ntities in the html
…into 179-fix-position-based-highlighting-when-a-text-contains-ampersand-and-other-reserved-htlm-entities
FAMarfuaty
marked this pull request as ready for review
September 22, 2023 06:27
Contributor
|
CR: looks great, just some small fixes for readability 🥇 |
Contributor
|
ACC: During acceptance I found two bugs unrelated to this PR, for which I will create issues:
Otherwise, this PR is good to go! 🚀 |
mhkuu
deleted the
179-fix-position-based-highlighting-when-a-text-contains-ampersand-and-other-reserved-htlm-entities
branch
September 25, 2023 07:26
9 of 18 tasks
11 of 16 tasks
8 of 18 tasks
10 of 18 tasks
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.
Context
&in the editor's HTML. This in turn messed up the position-based highlighting feature since when creating the Mark object (the object that represent the highlighting) inyoastseo, we calculate the ampersand length as 1 (referring to &), instead of 5. This means that for Classic editor, we need to calculate the ampersand length as 5, instead of 1.&instead of&. This means that when creating the Mark object for Gutenberg, we should still calculate the ampersand length as 1, instead of 5.<for<,©for©, as they all start with an ampersand.Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
The summary of the approach:
Yoastseo
&enters the paper as html entities (e.g.&)&=>&<=><>=>>"=>"'=>'–=>–—=>—©=>©®=>®™=>™£=>£¥=>¥€=>€$=>$°=>°≈=>≈≠=>≠&in the html entity into#, e.g.&->#amp;before building the tree. This is to avoid early conversion of the html entity into its reserved character version. This also means that when the tree is build, we're calculating the length of the html entity instead of the reserved character, so&will be 5 character long#amp;back to its reserved character&, while keeping the length information as 5 instead of 1. This is done so that we would still be able to match word "J&T" matches "J&T"gutenberg.js
adjustMarkOffsetsofpackages/js/src/decorator/helpers/positionBasedAnnotationHelper.js, we run a check if the block html contains html entities&has 1 length instead of 5Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
Scenario 1: Testing in Classic editor
Kick & Click™&character is NOT highlighted, the ™️ IS highlighted)Kick & Click™in the first paragraph, and instead add its HTML entity,™, so that it saysClick™®to the wordLINAKin the third paragraph so that it'sLINAK®K&C&character is ALSO highlighted)£to the number 4899 in the last paragraph so that it becomes4899£"to the beginning and end to the secondK&Cin the last paragraph so that it becomes"K&C"Scenario 2: Testing in Block editor
Scenario 3: Testing content, created in Classic editor, in Block editor
Kick & Click™(don't convert the content to blocks yet)&character is NOT highlighted, the ™️ IS highlighted)&character is NOT highlighted, the ™️ IS highlighted)Scenario 4: Testing content, created in Block editor, in Classic editor
K&C&character is ALSO highlighted)Scenario 4: Testing content in Elementor
Kick & Click™Kick & Click™in the first paragraph, and instead add its HTML entity,™, so that it saysClick™®to the wordLINAKin the third paragraph so that it'sLINAK®K&C£to the number 4899 in the last paragraph so that it becomes4899£"to the beginning and end to the secondK&Cin the last paragraph so that it becomes"K&C"Scenario 5:Test in Shopify
Relevant test scenarios
Test instructions for QA when the code is in the RC
QA can test this PR by following these steps:
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
UI changes
Other environments
[shopify-seo], added test instructions for Shopify and attached theShopifylabel to this PR.Documentation
Quality assurance
Innovation
innovationlabel.Fixes #179