@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.
- package/lib/model/texte.js +20 -8
- package/package.json +1 -1
package/lib/model/texte.js
CHANGED
|
@@ -195,10 +195,10 @@ export function transformExposeDesMotifs(document) {
|
|
|
195
195
|
continue;
|
|
196
196
|
}
|
|
197
197
|
else {
|
|
198
|
-
|
|
198
|
+
secondParagraph.remove();
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
|
|
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
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
|
-
|
|
243
|
-
|
|
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
|
}
|