File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
targets/export-elasticsearch/src/ingester/glossary Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -39,13 +39,33 @@ describe("Glossary", () => {
39
39
) ;
40
40
} ) ;
41
41
42
+ test ( "should add webcomponent tooltip even if next tag is omitted" , ( ) => {
43
+ const htmlContent = `<p>indemnité</p><summary>test</summary>` ;
44
+ expect ( addGlossary ( htmlContent ) ) . toEqual (
45
+ `<p><webcomponent-tooltip content="Sommes%20vers%C3%A9es%20en%20compensation%20ou%20en%20r%C3%A9paration%20de%20quelque%20chose.">indemnité</webcomponent-tooltip></p><summary>test</summary>`
46
+ ) ;
47
+ } ) ;
48
+
42
49
test ( "should not add webcomponent tooltip in a summary tag with strong" , ( ) => {
43
50
const htmlContent = `<summary><strong>L'indemnité de fin de contrat n'est pas due dans les cas suivants</strong></summary>` ;
44
51
expect ( addGlossary ( htmlContent ) ) . toEqual (
45
52
`<summary><strong>L'indemnité de fin de contrat n'est pas due dans les cas suivants</strong></summary>`
46
53
) ;
47
54
} ) ;
48
55
56
+ test . each `
57
+ heading
58
+ ${ "h1" }
59
+ ${ "h2" }
60
+ ${ "h3" }
61
+ ${ "h4" }
62
+ ${ "h5" }
63
+ ${ "h6" }
64
+ ` ( "should not add webcomponent tooltip in $heading" , ( { heading } ) => {
65
+ const markdown = `<${ heading } >indemnité</${ heading } >` ;
66
+ expect ( addGlossary ( markdown ) ) . toEqual ( markdown ) ;
67
+ } ) ;
68
+
49
69
test ( "should not replace html property for cc word" , ( ) => {
50
70
const htmlContent =
51
71
'<p class="un accord de branche ou pas">voici une convention collective et un web component mais aussi dispositions, ceci est un test</p>' ;
Original file line number Diff line number Diff line change @@ -7,12 +7,11 @@ const conventionMatchers =
7
7
const startWordBreaks = `(?<=^| |\\.|,|'|>|\\()` ;
8
8
const endWordBreaks = `(?= |\\.|,|'|$|<|\\))` ;
9
9
10
- const startAnchorOmit = `(?<!<a>|<summary>|<summary><strong>)` ;
11
- const endAnchorOmit = `(?![^<]*</a>|[^<]*</summary>|[^<]*</strong></summary>)` ;
10
+ const endAnchorOmit = `(?![^<]*</a>|[^<]*</summary>|[^<]*</strong></summary>|[^<]*</h[1-6]>)` ;
12
11
13
12
const tagAttributeOmit = `(?<=(^|>)[^><]*)` ;
14
13
15
- const startTag = `${ startAnchorOmit } ${ tagAttributeOmit } ${ startWordBreaks } ` ;
14
+ const startTag = `${ tagAttributeOmit } ${ startWordBreaks } ` ;
16
15
const endTag = `${ endWordBreaks } ${ endAnchorOmit } ` ;
17
16
18
17
export const explodeGlossaryTerms = ( glossary : Glossary ) : GlossaryTerms [ ] => {
You can’t perform that action at this time.
0 commit comments