Skip to content

Commit

Permalink
exclude president from wikipedia link
Browse files Browse the repository at this point in the history
  • Loading branch information
louispaulet committed Apr 14, 2023
1 parent 933bd06 commit 3489249
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ function convertSpeakerNameToWikipediaLink(text) {
const wikipediaBaseURL = "https://fr.wikipedia.org/wiki/";

function encodeSpeakerName(name) {
console.log(name)
name = name.replace('M. ', '')
name = name.replace('Mme ', '')
name = name.replaceAll('.', '')
name = name.replaceAll(',', '')
console.log(name)
return encodeURIComponent(name.trim().replace(/\s+/g, "_"));
}

return text.replace(regex, (match, speakerName) => {
if (speakerName.includes("la présidente")){
return match
}
const encodedName = encodeSpeakerName(speakerName);
const wikipediaURL = `${wikipediaBaseURL}${encodedName}`;
return `<strong><a href="${wikipediaURL}">${speakerName}</a></strong>`;
Expand Down

0 comments on commit 3489249

Please # to comment.