sr-npm 1.7.1246 → 1.7.1249

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,13 @@ 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);
162
165
 
163
166
  const pTagRegex = /<p>(.*?)<\/p>/gi;
164
167
  let match;
@@ -199,7 +202,7 @@ function addSpacingToRichContent(html, richContent) {
199
202
  };
200
203
 
201
204
  // Check if a paragraph node's text matches one with &#xa0; in HTML
202
- const needsSpacingAfter = (node) => {
205
+ const needsSpacingAfter = (node, nextNode) => {
203
206
  if (node.type !== 'PARAGRAPH') return false;
204
207
 
205
208
  // Add spacing after bold paragraphs
@@ -207,6 +210,11 @@ function addSpacingToRichContent(html, richContent) {
207
210
  return true;
208
211
  }
209
212
 
213
+ // If HTML has consecutive <p> tags and next node is also a paragraph, add spacing
214
+ if (hasConsecutiveParagraphs && nextNode && nextNode.type === 'PARAGRAPH') {
215
+ return true;
216
+ }
217
+
210
218
  const text = node.nodes?.[0]?.textData?.text || '';
211
219
  const trimmedText = text.trim();
212
220
 
@@ -278,8 +286,8 @@ function addSpacingToRichContent(html, richContent) {
278
286
  } else {
279
287
  newNodes.push(currentNode);
280
288
 
281
- // Add empty paragraph ONLY after paragraphs with &#xa0; or after lists
282
- if ((needsSpacingAfter(currentNode) || isListEnd(currentNode, nextNode)) && nextNode) {
289
+ // Add empty paragraph after paragraphs with &#xa0;, consecutive paragraphs, or after lists
290
+ if ((needsSpacingAfter(currentNode, nextNode) || isListEnd(currentNode, nextNode)) && nextNode) {
283
291
  newNodes.push(createEmptyParagraph(`empty_${nodeIdCounter++}`));
284
292
  }
285
293
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sr-npm",
3
- "version": "1.7.1246",
3
+ "version": "1.7.1249",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {