sr-npm 1.7.1246 → 1.7.1252
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.
|
@@ -155,10 +155,15 @@ function addSpacingToRichContent(html, richContent) {
|
|
|
155
155
|
return richContent;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
|
|
158
159
|
// Extract paragraph texts from HTML that end with  
|
|
159
160
|
const htmlParagraphsWithSpace = [];
|
|
160
161
|
// Extract paragraphs with <br> tags
|
|
161
162
|
const htmlParagraphsWithBr = new Map(); // text -> array of parts split by <br>
|
|
163
|
+
// Check if HTML has consecutive paragraphs (</p><p> pattern)
|
|
164
|
+
const hasConsecutiveParagraphs = /<\/p>\s*<p/i.test(html);
|
|
165
|
+
// Check if HTML has paragraph followed by list (</p><ul> pattern)
|
|
166
|
+
const hasParagraphBeforeList = /<\/p>\s*<ul/i.test(html);
|
|
162
167
|
|
|
163
168
|
const pTagRegex = /<p>(.*?)<\/p>/gi;
|
|
164
169
|
let match;
|
|
@@ -199,7 +204,7 @@ function addSpacingToRichContent(html, richContent) {
|
|
|
199
204
|
};
|
|
200
205
|
|
|
201
206
|
// Check if a paragraph node's text matches one with   in HTML
|
|
202
|
-
const needsSpacingAfter = (node) => {
|
|
207
|
+
const needsSpacingAfter = (node, nextNode) => {
|
|
203
208
|
if (node.type !== 'PARAGRAPH') return false;
|
|
204
209
|
|
|
205
210
|
// Add spacing after bold paragraphs
|
|
@@ -207,6 +212,16 @@ function addSpacingToRichContent(html, richContent) {
|
|
|
207
212
|
return true;
|
|
208
213
|
}
|
|
209
214
|
|
|
215
|
+
// If HTML has consecutive <p> tags and next node is also a paragraph, add spacing
|
|
216
|
+
if (hasConsecutiveParagraphs && nextNode && nextNode.type === 'PARAGRAPH') {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// If HTML has </p><ul> and next node is a list, add spacing
|
|
221
|
+
if (hasParagraphBeforeList && nextNode && nextNode.type === 'BULLETED_LIST') {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
|
|
210
225
|
const text = node.nodes?.[0]?.textData?.text || '';
|
|
211
226
|
const trimmedText = text.trim();
|
|
212
227
|
|
|
@@ -278,8 +293,8 @@ function addSpacingToRichContent(html, richContent) {
|
|
|
278
293
|
} else {
|
|
279
294
|
newNodes.push(currentNode);
|
|
280
295
|
|
|
281
|
-
// Add empty paragraph
|
|
282
|
-
if ((needsSpacingAfter(currentNode) || isListEnd(currentNode, nextNode)) && nextNode) {
|
|
296
|
+
// Add empty paragraph after paragraphs with  , consecutive paragraphs, or after lists
|
|
297
|
+
if ((needsSpacingAfter(currentNode, nextNode) || isListEnd(currentNode, nextNode)) && nextNode) {
|
|
283
298
|
newNodes.push(createEmptyParagraph(`empty_${nodeIdCounter++}`));
|
|
284
299
|
}
|
|
285
300
|
}
|