@tricoteuses/senat 2.5.8 → 2.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/model/texte.js +20 -8
  2. package/package.json +1 -1
@@ -195,10 +195,10 @@ export function transformExposeDesMotifs(document) {
195
195
  continue;
196
196
  }
197
197
  else {
198
- sectionElement.removeChild(secondParagraph);
198
+ secondParagraph.remove();
199
199
  }
200
200
  }
201
- sectionElement.removeChild(firstParagraph);
201
+ firstParagraph.remove();
202
202
  return {
203
203
  text: sectionElement.textContent?.trim() ?? null,
204
204
  html: sectionElement.innerHTML?.trim() ?? null,
@@ -231,14 +231,26 @@ export async function parseTexteFromFile(xmlFilePath) {
231
231
  return null;
232
232
  }
233
233
  export function parseExposeDesMotifs(exposeDesMotifsHtml) {
234
- const { document } = new JSDOM(exposeDesMotifsHtml, {
235
- contentType: "text/html",
236
- }).window;
237
- return transformExposeDesMotifs(document);
234
+ try {
235
+ const { document } = new JSDOM(exposeDesMotifsHtml, {
236
+ contentType: "text/html",
237
+ }).window;
238
+ return transformExposeDesMotifs(document);
239
+ }
240
+ catch (error) {
241
+ console.error(`Could not parse exposé des motifs with error ${error}`);
242
+ }
243
+ return null;
238
244
  }
239
245
  // Prevent from memory leak
240
246
  // https://github.com/jsdom/jsdom/issues/2583#issuecomment-559520814
241
247
  export async function parseExposeDesMotifsFromFile(htmlFilePath) {
242
- const { document } = (await JSDOM.fromFile(htmlFilePath, { contentType: "text/html" })).window;
243
- return transformExposeDesMotifs(document);
248
+ try {
249
+ const { document } = (await JSDOM.fromFile(htmlFilePath, { contentType: "text/html" })).window;
250
+ return transformExposeDesMotifs(document);
251
+ }
252
+ catch (error) {
253
+ console.error(`Could not parse exposé des motifs with error ${error}`);
254
+ }
255
+ return null;
244
256
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tricoteuses/senat",
3
- "version": "2.5.8",
3
+ "version": "2.5.9",
4
4
  "description": "Handle French Sénat's open data",
5
5
  "keywords": [
6
6
  "France",