Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(glossary): correction des   sur la reconnaissance des mots #1511

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>`
);
});
Comment on lines +546 to +551
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Top le test 👍


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
Loading