Skip to content

Commit

Permalink
fix: glossary
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgfr committed Dec 3, 2024
1 parent 8938e97 commit 03a8589
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
export const glossaryData = [
{
abbreviations: ["ZC"],
definition: "Definition de la zone commerciale",
term: "Zone commerciale",
variants: [],
references: [],
},
{
abbreviations: [],
definition:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,14 @@ describe("Glossary", () => {
`<webcomponent-tooltip content="word">ward</webcomponent-tooltip>`
);
});

test("should work with a composed name in tag with a non breaking space", async () => {
const htmlContent = "<p>Une zone commerciale&nbsp;</p>";
expect(await addGlossaryContent(glossaryData, htmlContent)).toEqual(
`<p>Une <webcomponent-tooltip content="Definition%20de%20la%20zone%20commerciale">zone commerciale</webcomponent-tooltip>&nbsp;</p>`
);
});

test("should match a variant with plural", async () => {
const htmlContent = `wards`;
expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { GlossaryTerms, Glossary, Term } from "@socialgouv/cdtn-types";
const conventionMatchers =
"[Cc]onventions? [Cc]ollectives?|[Aa]ccords? de [Bb]ranches?|[Dd]ispositions? [Cc]onventionnelles?";

const startWordBreaks = `(?<=^| |\\.|,|'|>|\\()`;
const endWordBreaks = `(?= |\\.|,|'|$|<|\\))`;
const startWordBreaks = `(?<=^| |\\.|,|'|>|\\(|&nbsp;)`;
const endWordBreaks = `(?= |\\.|,|'|$|<|\\)|&nbsp;)`;

const startAnchorOmit = `(?<!<span class="(?:sub-)?title">[^<]*)`;
const endAnchorOmit = `(?![^<]*(?:</a>|</summary>|</strong>.*</summary>|</h[1-6]>))`;
Expand Down

0 comments on commit 03a8589

Please sign in to comment.