sr-npm 1.7.1252 → 1.7.1253
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.
|
@@ -137,7 +137,8 @@ async function htmlRichContentConverter(sections,richContentConverterToken) {
|
|
|
137
137
|
);
|
|
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
142
|
richContentObject[sectionTitle] = richContentWithSpacing
|
|
142
143
|
}
|
|
143
144
|
else {
|
|
@@ -329,6 +330,43 @@ function createEmptyParagraph(id) {
|
|
|
329
330
|
};
|
|
330
331
|
}
|
|
331
332
|
|
|
333
|
+
// Adds empty paragraph nodes between consecutive paragraphs and before lists
|
|
334
|
+
function addEmptyParagraphsBetweenConsecutive(html, richContent) {
|
|
335
|
+
if (!richContent || !richContent.nodes) return richContent;
|
|
336
|
+
|
|
337
|
+
const hasConsecutiveParagraphs = /<\/p>\s*<p/i.test(html);
|
|
338
|
+
const hasParagraphBeforeList = /<\/p>\s*<ul/i.test(html);
|
|
339
|
+
|
|
340
|
+
if (!hasConsecutiveParagraphs && !hasParagraphBeforeList) return richContent;
|
|
341
|
+
|
|
342
|
+
const nodes = richContent.nodes;
|
|
343
|
+
const newNodes = [];
|
|
344
|
+
let nodeIdCounter = 0;
|
|
345
|
+
|
|
346
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
347
|
+
const currentNode = nodes[i];
|
|
348
|
+
const nextNode = nodes[i + 1];
|
|
349
|
+
|
|
350
|
+
newNodes.push(currentNode);
|
|
351
|
+
|
|
352
|
+
if (currentNode.type === 'PARAGRAPH' && nextNode) {
|
|
353
|
+
// Add empty paragraph between consecutive paragraphs
|
|
354
|
+
if (hasConsecutiveParagraphs && nextNode.type === 'PARAGRAPH') {
|
|
355
|
+
newNodes.push(createEmptyParagraph(`empty_consecutive_${nodeIdCounter++}`));
|
|
356
|
+
}
|
|
357
|
+
// Add empty paragraph before list
|
|
358
|
+
if (hasParagraphBeforeList && nextNode.type === 'BULLETED_LIST') {
|
|
359
|
+
newNodes.push(createEmptyParagraph(`empty_before_list_${nodeIdCounter++}`));
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return {
|
|
365
|
+
...richContent,
|
|
366
|
+
nodes: newNodes
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
|
|
332
370
|
|
|
333
371
|
|
|
334
372
|
|