Skip to content

Commit

Permalink
fix(glossary): remove unsupported lookbehind
Browse files Browse the repository at this point in the history
  • Loading branch information
lionelB committed Dec 19, 2019
1 parent a108a23 commit 8b2bc4b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2257,7 +2257,7 @@ exports[`<Answer /> should renders related content 1`] = `
annualisation du temps de travail
</span>
</span>
.
.
<span
data-tooltip-ref="__tt__1"
>
Expand All @@ -2266,10 +2266,10 @@ exports[`<Answer /> should renders related content 1`] = `
data-reach-tooltip-trigger=""
tabindex="0"
>
Annualisation
Annualisation
</span>
</span>
de l'
de l
<span
data-tooltip-ref="__tt__2"
>
Expand All @@ -2278,7 +2278,7 @@ exports[`<Answer /> should renders related content 1`] = `
data-reach-tooltip-trigger=""
tabindex="0"
>
annualisation
'annualisation
</span>
</span>
.
Expand Down Expand Up @@ -3041,7 +3041,7 @@ exports[`<Answer /> should renders tooltip 1`] = `
<strong>
html
</strong>
contenant des tooltip sur certains mot comme
contenant des tooltip sur certains mot comme
<span
data-tooltip-ref="__tt__2"
>
Expand All @@ -3050,7 +3050,7 @@ exports[`<Answer /> should renders tooltip 1`] = `
data-reach-tooltip-trigger=""
tabindex="0"
>
rescrit
rescrit
</span>
</span>
. match aussi les abbréviation comme
Expand All @@ -3065,7 +3065,7 @@ exports[`<Answer /> should renders tooltip 1`] = `
APE
</span>
</span>
mais pas ape ou ses variantes comme
mais pas ape ou ses variantes comme
<span
data-tooltip-ref="__tt__0"
>
Expand All @@ -3074,7 +3074,7 @@ exports[`<Answer /> should renders tooltip 1`] = `
data-reach-tooltip-trigger=""
tabindex="0"
>
code ape
code ape
</span>
</span>
</p>
Expand Down Expand Up @@ -3515,31 +3515,29 @@ exports[`<Answer /> should renders tooltip for words with diacritics without bre
class="test-content"
>
Contenu au format
<strong>
<strong<span
data-tooltip-ref="__tt__1"
>
comme
<span
data-tooltip-ref="__tt__1"
data-tooltip-ref="__tt__0"
>
<span
class="c10"
data-reach-tooltip-trigger=""
tabindex="0"
>
indemnités
code ape
</span>
</span>
</strong>
comme
<span
data-tooltip-ref="__tt__0"
>
<span
class="c10"
data-reach-tooltip-trigger=""
tabindex="0"
>
code ape
&gt;indemnités
</span>
</span>
</strong<span>
</p>
</div>
<div>
Expand Down Expand Up @@ -3988,7 +3986,7 @@ exports[`<Answer /> should renders tooltip without breaking previous word 1`] =
annualisation du temps de travail
</span>
</span>
.
.
<span
data-tooltip-ref="__tt__1"
>
Expand All @@ -3997,10 +3995,10 @@ exports[`<Answer /> should renders tooltip without breaking previous word 1`] =
data-reach-tooltip-trigger=""
tabindex="0"
>
Annualisation
Annualisation
</span>
</span>
de l'
de l
<span
data-tooltip-ref="__tt__2"
>
Expand All @@ -4009,7 +4007,7 @@ exports[`<Answer /> should renders tooltip without breaking previous word 1`] =
data-reach-tooltip-trigger=""
tabindex="0"
>
annualisation
'annualisation
</span>
</span>
.
Expand Down
4 changes: 3 additions & 1 deletion packages/code-du-travail-frontend/src/glossary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export default function useGlossary(children, html) {
// So we do a kind of \b equivalent.
// the main différence is that matched pattern can include a whitespace as first char
const frDiacritics = "àâäçéèêëïîôöùûüÿœæÀÂÄÇÉÈÊËÎÏÔÖÙÛÜŸŒÆ";
const wordBoundaryStart = `(?<=^|[^-/_\\w${frDiacritics}])`;
// before using lookbehind
// @see https://stackoverflow.com/questions/2449779/why-cant-i-use-accented-characters-next-to-a-word-boundary
const wordBoundaryStart = `(?:^|[^\\w${frDiacritics}])`;
const wordBoundaryEnd = `(?![\\w${frDiacritics}])`;
const patterns = [...new Set([item.title, ...item.variants])]
.map(
Expand Down

0 comments on commit 8b2bc4b

Please sign in to comment.