sr-npm 1.7.1254 → 1.7.1257
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/backend/data.js
CHANGED
|
@@ -287,7 +287,7 @@ async function saveJobsDescriptionsAndLocationApplyUrlReferencesToCMS() {
|
|
|
287
287
|
const chunkPromises = chunk.map(async job => {
|
|
288
288
|
try {
|
|
289
289
|
const jobDetails = await fetchJobDescription(job._id);
|
|
290
|
-
const richContentDescription=await htmlRichContentConverter(jobDetails.jobAd.sections,richContentConverterToken);
|
|
290
|
+
const richContentDescription=await htmlRichContentConverter(jobDetails.jobAd.sections,richContentConverterToken,job.name);
|
|
291
291
|
const jobLocation = fetchJobLocation(jobDetails);
|
|
292
292
|
const {applyLink , referFriendLink} = fetchApplyAndReferFriendLink(jobDetails);
|
|
293
293
|
const updatedJob = {
|
|
@@ -114,7 +114,7 @@ async function fetchJobDescription(jobId,testObject=undefined) {
|
|
|
114
114
|
return await makeSmartRecruitersRequest(`/v1/companies/${companyId}/postings/${jobId}`,templateType);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
async function htmlRichContentConverter(sections,richContentConverterToken) {
|
|
117
|
+
async function htmlRichContentConverter(sections,richContentConverterToken,jobName) {
|
|
118
118
|
|
|
119
119
|
const richContentObject = {}
|
|
120
120
|
for (const [sectionTitle, sectionData] of Object.entries(sections)) {
|
|
@@ -138,7 +138,7 @@ async function htmlRichContentConverter(sections,richContentConverterToken) {
|
|
|
138
138
|
if (response.ok) {
|
|
139
139
|
const data = await response.json();
|
|
140
140
|
// const richContentWithSpacing=addSpacingToRichContent(sectionData.text,data.richContent.richContent);
|
|
141
|
-
const richContentWithSpacing=addEmptyParagraphsBetweenConsecutive(sectionData.text,data.richContent.richContent);
|
|
141
|
+
const richContentWithSpacing=addEmptyParagraphsBetweenConsecutive(sectionData.text,data.richContent.richContent,jobName);
|
|
142
142
|
richContentObject[sectionTitle] = richContentWithSpacing
|
|
143
143
|
}
|
|
144
144
|
else {
|
|
@@ -330,12 +330,20 @@ function createEmptyParagraph(id) {
|
|
|
330
330
|
};
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
-
// Adds empty paragraph
|
|
334
|
-
function addEmptyParagraphsBetweenConsecutive(html, richContent) {
|
|
333
|
+
// Adds empty paragraph nodes between consecutive paragraphs and before lists
|
|
334
|
+
function addEmptyParagraphsBetweenConsecutive(html, richContent,jobName) {
|
|
335
|
+
|
|
336
|
+
if(jobName===" Apparel Team Member - The Warehouse, Dargaville")
|
|
337
|
+
{
|
|
338
|
+
console.log("rich content is : ",richContent);
|
|
339
|
+
}
|
|
335
340
|
if (!richContent || !richContent.nodes) return richContent;
|
|
336
341
|
|
|
337
|
-
const
|
|
338
|
-
|
|
342
|
+
const hasConsecutiveParagraphs = /<\/p>\s*<p/i.test(html);
|
|
343
|
+
const hasParagraphBeforeList = /<\/p>\s*<ul/i.test(html);
|
|
344
|
+
const hasParagraphAfterList = /<\/ul>\s*<p/i.test(html);
|
|
345
|
+
|
|
346
|
+
if (!hasConsecutiveParagraphs && !hasParagraphBeforeList && !hasParagraphAfterList) return richContent;
|
|
339
347
|
|
|
340
348
|
const nodes = richContent.nodes;
|
|
341
349
|
const newNodes = [];
|
|
@@ -347,9 +355,20 @@ function addEmptyParagraphsBetweenConsecutive(html, richContent) {
|
|
|
347
355
|
|
|
348
356
|
newNodes.push(currentNode);
|
|
349
357
|
|
|
350
|
-
// Add empty paragraph after each paragraph if there's something after it
|
|
351
358
|
if (currentNode.type === 'PARAGRAPH' && nextNode) {
|
|
352
|
-
|
|
359
|
+
// Add empty paragraph between consecutive paragraphs
|
|
360
|
+
if (hasConsecutiveParagraphs && nextNode.type === 'PARAGRAPH') {
|
|
361
|
+
newNodes.push(createEmptyParagraph(`empty_consecutive_${nodeIdCounter++}`));
|
|
362
|
+
}
|
|
363
|
+
// Add empty paragraph before list
|
|
364
|
+
if (hasParagraphBeforeList && nextNode.type === 'BULLETED_LIST') {
|
|
365
|
+
newNodes.push(createEmptyParagraph(`empty_before_list_${nodeIdCounter++}`));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// Add empty paragraph after list
|
|
370
|
+
if (hasParagraphAfterList && currentNode.type === 'BULLETED_LIST' && nextNode && nextNode.type === 'PARAGRAPH') {
|
|
371
|
+
newNodes.push(createEmptyParagraph(`empty_after_list_${nodeIdCounter++}`));
|
|
353
372
|
}
|
|
354
373
|
}
|
|
355
374
|
|