nonBreakingSpaces.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // insérer des espaces insécables avant les signes de ponctuations et remplacer les guillemets
  2. if (debug) console.log('start nonBreakingSpaces');
  3. (function() {
  4. let contentsToClean = document.querySelectorAll('.labeur, .free, .latour, .latour_nohead, .lampe, .lampe_nohead, .bibliographie');
  5. for (let content of contentsToClean) {
  6. content.innerHTML = content.innerHTML.replaceAll(' :', ' :');
  7. content.innerHTML = content.innerHTML.replaceAll(' ?', ' ?');
  8. content.innerHTML = content.innerHTML.replaceAll(' !', ' !');
  9. content.innerHTML = content.innerHTML.replaceAll('« ', '« ');
  10. content.innerHTML = content.innerHTML.replaceAll(' »', ' »');
  11. content.innerHTML = content.innerHTML.replaceAll('(« ', '(« ');
  12. content.innerHTML = content.innerHTML.replaceAll(' »)', ' »)');
  13. content.innerHTML = content.innerHTML.replaceAll('“', '« ');
  14. content.innerHTML = content.innerHTML.replaceAll('”', ' »');
  15. content.innerHTML = content.innerHTML.replaceAll(' min', ' min');
  16. }
  17. })();
  18. if (debug) console.log('end nonBreakingSpaces');
  19. /*
  20. // micro-typo
  21. for(let j = 0; j < contentToParse[i].childNodes.length; j++) {
  22. let contentHTML = contentToParse[i].childNodes[j].innerHTML;
  23. if (contentHTML != undefined) {
  24. contentToParse[i].childNodes[j].innerHTML = contentToParse[i].childNodes[j].innerHTML.replaceAll(' :', '&nbsp;:');
  25. contentToParse[i].childNodes[j].innerHTML = contentToParse[i].childNodes[j].innerHTML.replaceAll(' ?', '&nbsp;?');
  26. contentToParse[i].childNodes[j].innerHTML = contentToParse[i].childNodes[j].innerHTML.replaceAll(' !', '&nbsp;!');
  27. contentToParse[i].childNodes[j].innerHTML = contentToParse[i].childNodes[j].innerHTML.replaceAll('« ', '«&nbsp;');
  28. contentToParse[i].childNodes[j].innerHTML = contentToParse[i].childNodes[j].innerHTML.replaceAll(' »', '&nbsp;»');
  29. contentToParse[i].childNodes[j].innerHTML = contentToParse[i].childNodes[j].innerHTML.replaceAll('(« ', '(«&nbsp;');
  30. contentToParse[i].childNodes[j].innerHTML = contentToParse[i].childNodes[j].innerHTML.replaceAll(' »)', '&nbsp;»)');
  31. contentToParse[i].childNodes[j].innerHTML = contentToParse[i].childNodes[j].innerHTML.replaceAll('“', '«&nbsp;');
  32. contentToParse[i].childNodes[j].innerHTML = contentToParse[i].childNodes[j].innerHTML.replaceAll('”', '&nbsp;»');
  33. contentToParse[i].childNodes[j].innerHTML = contentToParse[i].childNodes[j].innerHTML.replaceAll(' min', '&nbsp;min');
  34. }
  35. } */