Skip to content

Commit 2bafe60

Browse files
committed
adapt regex
1 parent 18c5f57 commit 2bafe60

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

packages/yoastseo/src/languageProcessing/helpers/word/markWordsInSentences.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import matchWords from "../match/matchTextWithArray";
66
import arrayToRegex from "../regex/createRegexFromArray";
77

88
// Regex to deconstruct an anchor into open tag, content and close tag.
9-
const anchorDeconstructionRegex = /(<a[\s]+[^>]+>)((?:.|[\n\r\u2028\u2029])*?)(<\/a>)/;
10-
9+
// [^] matches any character, including newline
10+
const anchorDeconstructionRegex = /(<a[\s]+[^>]+>)([^]*?)(<\/a>)/;
1111

1212
/**
1313
* Deconstructs an anchor to the opening tag and the content. The content is the anchor text.
@@ -61,7 +61,6 @@ const getMarkedAnchors = function( sentence, wordsRegex ) {
6161
// Create a new anchor tag with a (marked) anchor text.
6262
return reConstructAnchor( openTag, markedAnchorText );
6363
} );
64-
6564
return { anchors, markedAnchors };
6665
};
6766

@@ -124,7 +123,6 @@ export function markWordsInSentences( wordsToMark, sentences, locale, matchWordC
124123

125124
sentences.forEach( function( sentence ) {
126125
wordsFoundInSentence = matchWords( sentence, wordsToMark, locale, matchWordCustomHelper ).matches;
127-
128126
if ( wordsFoundInSentence.length > 0 ) {
129127
markings = markings.concat( new Mark( {
130128
original: sentence,

0 commit comments

Comments
 (0)