fixes a bug where yoast markers break html of content in shopify and classic#19499
fixes a bug where yoast markers break html of content in shopify and classic#19499hdvos wants to merge 28 commits intofeature/lingo-fixesfrom
Conversation
FAMarfuaty
left a comment
There was a problem hiding this comment.
Good job for finding that smart and neat logic for not applying yoastmark in html tags! 🙌🏽
I have a suggestion for checking whether ACF plugin is used. It needs to be adapted, since it's currently not working that way :)
|
NOTES:
The two points above are not in the scope of this PR. |
…into 19477-yoast-markers-break-html-of-content-in-shopify-and-classic
…into 19477-yoast-markers-break-html-of-content-in-shopify-and-classic
…l-of-content-in-shopify-and-classic
There was a problem hiding this comment.
It's super nice that you found a solution to the mind-boggling situation 🐡 🙌🏽
I have a few comments and minor suggestions (that I think can be directly committed? you're the judge 😸 )
Another thing, since we introduce an additional check in the sentence tokenizer which we use everywhere (as proven by the adapted fullTextTests), maybe you can think of an additional impact to check?
Otherwise, the code is good to go!
| const element = document.createElement( "body" ); | ||
| element.innerHTML = str; | ||
| return element.innerHTML; | ||
| } |
There was a problem hiding this comment.
Nice that you rename the function and also make the description even clearer! 🤩
| const lastTagType = lastTokenText.match( tagTypeRegex )[ 1 ]; | ||
|
|
||
| return firstTagType === lastTagType && [ "p", "div", "h1", "h2", "h3", "h4", "h5", "h6", "span" ].includes( firstTagType ); | ||
| } |
There was a problem hiding this comment.
@hdvos Is there a reason why we only check the tags in the array and not the others? 🤔
There was a problem hiding this comment.
@FAMarfuaty : yes. This is the list of types for which I deem it safe to remove the first and the last tag. If you were to include stylistic tags such as <i> and <b>, the chance of creating corrupted html would be too big as it is not unlikely that only the first and last word of a paragraph/block are italics. For example <i>First words</i> ... <i> last words.</i> would be normalized to the corrupted First words</i> ... <i> last words.
Also, I think these types of 'semantic' tags, is this is the situation this function was intended for.
Co-authored-by: Aida Marfuaty <48715883+FAMarfuaty@users.noreply.github.com>
|
@FAMarfuaty : regarding the extra impact check. I will add one that smoke tests the sentence tokenizer. |
Context
catnipalso occurred in the url in the anchor).>) appears in the same sentence after a word that must be marked, then this word cannot be marked. The decision was made that solving this would cost too much time compared to the gains.Summary
This PR can be summarized in the following changelog entry:
yoastmarktags broke the HTML when applied to inline HTML attributes.yoastmarkto anchor tag attributes.Relevant technical choices:
getSentencesFromTokens, a check was added. Previously, if there was an opening tag on the beginning of the text, and a closing tag at the end, both would be removed, regardless of whether they belonged together. In this PR a check is added that does a rudimentary (and not watertight) check whether they belong together. Once we have the html parser, this should be replaced.Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
NOTE: while testing, you might note that there are different results for the same text between post and page in default editor. This is reproducible on
trunk. And this issue was created for itWordPress
catnip.txt
NOTE: Add the text in
Texteditor mode in Classic editor, and in Code editor mode in Block editorKeyword density assessment
hrefvalue doesn't contain yoast mark tags, e.g."<yoastmark class='yoast-text-mark'>"or"</yoastmark>"hrefvalue doesn't contain yoast mark tags, e.g."<yoastmark class='yoast-text-mark'>"or"</yoastmark>"Keyphrase distribution assessment
composer require yoast/wordpress-seo:dev-PC-965-yoast-markers-break-html-of-content@devbefore building ithrefvalue doesn't contain yoast mark tags, e.g."<yoastmark class='yoast-text-mark'>"or"</yoastmark>"hrefvalue doesn't contain yoast mark tags, e.g."<yoastmark class='yoast-text-mark'>"or"</yoastmark>"Synonyms:
catmintas a keyphrase synonym.catnipare markedcatnipas well as all occurrences ofcatmintare markedWord complexity assessment
hrefvalue doesn't contain yoast mark tags, e.g."<yoastmark class='yoast-text-mark'>"or"</yoastmark>"Sentence length, Passive voice, and Transition words assessment
However, the compounds were found to repel <a href="https://en.wikipedia.org/wiki/Mosquito" rel="nofollow">mosquitos</a>, and it is hypothesized that rubbing against the plants provides the cats with a chemical coat that protects them against mosquito bites.NOTE: Add the text in
Texteditor mode in Classic editor, and in Code editor mode in Block editorConsecutive sentences assessment
<a href="https://en.wikipedia.org/wiki/Cat">Cats</a> detect nepetalactone through their <a href="https://en.wikipedia.org/wiki/Olfactory_epithelium">olfactory epithelium</a>, not through their vomeronasal organ. <a href="https://en.wikipedia.org/wiki/Cat">Cats</a> detect nepetalactone through their <a href="https://en.wikipedia.org/wiki/Olfactory_epithelium">olfactory epithelium</a>, not through their vomeronasal organ. <a href="https://en.wikipedia.org/wiki/Cat">Cats</a> detect nepetalactone through their <a href="https://en.wikipedia.org/wiki/Olfactory_epithelium">olfactory epithelium</a>, not through their vomeronasal organ.NOTE: Add the text in
Texteditor mode in Classic editor, and in Code editor mode in Block editorParagraph length assessment
Paragraph length assessment
Inclusive language analysis
Upgrade routine
Install and activate the previous version of Yoast SEO
Set the site language to English
Create a post in Classic editor and add this text:
catnip.txt
NOTE: Add the text in
Texteditor mode in Classic editorSet "catnip" as the focus keyphrase
Embed this link below to the phrase "catnip flowers":
Smoke test Advanced custom fields
Smoke classic editor block in block editor
Test in Shopify
Install and activate Yoast SEO for Shopify
maininshopify-seowordpress-seobefore buildingSet the store language to English
Create a product and add this text:
catnip.txt
NOTE: the test instruction below should be repeated in all content types in Shopify
Keyword density and Keyphrase distribution assessment
hrefvalue doesn't contain yoast mark tags, e.g."<yoastmark class='yoast-text-mark'>"or"</yoastmark>"hrefvalue doesn't contain yoast mark tags, e.g."<yoastmark class='yoast-text-mark'>"or"</yoastmark>"Confirm that the keyword density assessment still detects 8 occurrences of the keyphrase in the text
Click the eye icon of keyword density assessment
Confirm that the "catnip" in "catnip flower" is highlighted
Check the anchor link of the phrase and confirm that the
hrefvalue doesn't contain yoast mark tags, e.g."<yoastmark class='yoast-text-mark'>"or"</yoastmark>"Click the eye icon of keyphrase distribution assessment
Confirm that the "catnip" in "catnip flowers" is highlighted
Check the anchor link of the phrase and confirm that the
hrefvalue doesn't contain yoast mark tags, e.g."<yoastmark class='yoast-text-mark'>"or"</yoastmark>"Word complexity assessment
hrefvalue doesn't contain yoast mark tags, e.g."<yoastmark class='yoast-text-mark'>"or"</yoastmark>"(Smoke) Test impact by sentence tokenizer
<i>The cat</i> was greeted by <i>the dog</i>.<div>The cat was greeted by the dog</div>.midgetto a few random sentences in the post. This should trigger the inclusive language assessment formidget.midget.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 and noted the work hours.Fixes #19477