cleanParagraphsParsing.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // nettoyer le parsing des pragraphes
  2. if (debug) console.log('start cleanParagraphsParsing');
  3. (function() {
  4. let labeurs = document.querySelectorAll('.labeur, .free');
  5. for(let labeur of labeurs) {
  6. if (labeur.childNodes.length == 1) {
  7. labeur.innerHTML = '<p>' + labeur.innerHTML + '</p>';
  8. } else {
  9. labeur.innerHTML = "<p>" + labeur.innerHTML.replace("<p>", "");
  10. }
  11. // data align last split
  12. if (labeur.innerHTML.includes('<br>')) {
  13. if (labeur.childElementCount > 0) {
  14. for (let j = 0; j < labeur.childElementCount; j++) {
  15. let parts = labeur.children[j].innerHTML.split('<br>');
  16. let newParts = parts.map(function(part) {
  17. return `<p>${ part }</p>`;
  18. });
  19. labeur.children[j].innerHTML = newParts.join('');
  20. }
  21. } else {
  22. let parts = labeur.innerHTML.split('<br>');
  23. let newParts = parts.map(function(part) {
  24. return `<p>${ part }</p>`;
  25. });
  26. labeur.innerHTML = newParts.join('');
  27. }
  28. }
  29. }
  30. })();
  31. if (debug) console.log('end cleanParagraphsParsing');