@cloudrac3r/turndown 7.1.4 → 7.1.5

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/dist/turndown.js CHANGED
@@ -119,7 +119,7 @@ var TurndownService = (function () {
119
119
  replacement: function (content) {
120
120
  content = content.replace(/^\n+|\n+$/g, '');
121
121
  content = content.replace(/^/gm, '> ');
122
- return '\n\n' + content + '\n\n'
122
+ return '\n\n' + content + '\n'
123
123
  }
124
124
  };
125
125
 
@@ -888,7 +888,7 @@ var TurndownService = (function () {
888
888
  replacement = replacementForNode.call(self, node);
889
889
  }
890
890
 
891
- return join(output, replacement)
891
+ return join(output, replacement, node.tagName, node.previousElementSibling?.tagName)
892
892
  }, '')
893
893
  }
894
894
 
@@ -940,10 +940,13 @@ var TurndownService = (function () {
940
940
  * @type String
941
941
  */
942
942
 
943
- function join (output, replacement) {
943
+ function join (output, replacement, tag, previousSiblingTag) {
944
944
  var s1 = trimTrailingNewlines(output);
945
945
  var s2 = trimLeadingNewlines(replacement);
946
946
  var nls = Math.max(output.length - s1.length, replacement.length - s2.length);
947
+ if (tag === "P" && previousSiblingTag === "BLOCKQUOTE") {
948
+ nls = Math.min(nls, 1);
949
+ }
947
950
  var separator = '\n\n'.substring(0, nls);
948
951
 
949
952
  return s1 + separator + s2
@@ -118,7 +118,7 @@ rules.blockquote = {
118
118
  replacement: function (content) {
119
119
  content = content.replace(/^\n+|\n+$/g, '');
120
120
  content = content.replace(/^/gm, '> ');
121
- return '\n\n' + content + '\n\n'
121
+ return '\n\n' + content + '\n'
122
122
  }
123
123
  };
124
124
 
@@ -887,7 +887,7 @@ function process (parentNode) {
887
887
  replacement = replacementForNode.call(self, node);
888
888
  }
889
889
 
890
- return join(output, replacement)
890
+ return join(output, replacement, node.tagName, node.previousElementSibling?.tagName)
891
891
  }, '')
892
892
  }
893
893
 
@@ -939,10 +939,13 @@ function replacementForNode (node) {
939
939
  * @type String
940
940
  */
941
941
 
942
- function join (output, replacement) {
942
+ function join (output, replacement, tag, previousSiblingTag) {
943
943
  var s1 = trimTrailingNewlines(output);
944
944
  var s2 = trimLeadingNewlines(replacement);
945
945
  var nls = Math.max(output.length - s1.length, replacement.length - s2.length);
946
+ if (tag === "P" && previousSiblingTag === "BLOCKQUOTE") {
947
+ nls = Math.min(nls, 1);
948
+ }
946
949
  var separator = '\n\n'.substring(0, nls);
947
950
 
948
951
  return s1 + separator + s2
@@ -116,7 +116,7 @@ rules.blockquote = {
116
116
  replacement: function (content) {
117
117
  content = content.replace(/^\n+|\n+$/g, '');
118
118
  content = content.replace(/^/gm, '> ');
119
- return '\n\n' + content + '\n\n'
119
+ return '\n\n' + content + '\n'
120
120
  }
121
121
  };
122
122
 
@@ -885,7 +885,7 @@ function process (parentNode) {
885
885
  replacement = replacementForNode.call(self, node);
886
886
  }
887
887
 
888
- return join(output, replacement)
888
+ return join(output, replacement, node.tagName, node.previousElementSibling?.tagName)
889
889
  }, '')
890
890
  }
891
891
 
@@ -937,10 +937,13 @@ function replacementForNode (node) {
937
937
  * @type String
938
938
  */
939
939
 
940
- function join (output, replacement) {
940
+ function join (output, replacement, tag, previousSiblingTag) {
941
941
  var s1 = trimTrailingNewlines(output);
942
942
  var s2 = trimLeadingNewlines(replacement);
943
943
  var nls = Math.max(output.length - s1.length, replacement.length - s2.length);
944
+ if (tag === "P" && previousSiblingTag === "BLOCKQUOTE") {
945
+ nls = Math.min(nls, 1);
946
+ }
944
947
  var separator = '\n\n'.substring(0, nls);
945
948
 
946
949
  return s1 + separator + s2
@@ -122,7 +122,7 @@
122
122
  replacement: function (content) {
123
123
  content = content.replace(/^\n+|\n+$/g, '');
124
124
  content = content.replace(/^/gm, '> ');
125
- return '\n\n' + content + '\n\n'
125
+ return '\n\n' + content + '\n'
126
126
  }
127
127
  };
128
128
 
@@ -891,7 +891,7 @@
891
891
  replacement = replacementForNode.call(self, node);
892
892
  }
893
893
 
894
- return join(output, replacement)
894
+ return join(output, replacement, node.tagName, node.previousElementSibling?.tagName)
895
895
  }, '')
896
896
  }
897
897
 
@@ -943,10 +943,13 @@
943
943
  * @type String
944
944
  */
945
945
 
946
- function join (output, replacement) {
946
+ function join (output, replacement, tag, previousSiblingTag) {
947
947
  var s1 = trimTrailingNewlines(output);
948
948
  var s2 = trimLeadingNewlines(replacement);
949
949
  var nls = Math.max(output.length - s1.length, replacement.length - s2.length);
950
+ if (tag === "P" && previousSiblingTag === "BLOCKQUOTE") {
951
+ nls = Math.min(nls, 1);
952
+ }
950
953
  var separator = '\n\n'.substring(0, nls);
951
954
 
952
955
  return s1 + separator + s2
@@ -118,7 +118,7 @@ rules.blockquote = {
118
118
  replacement: function (content) {
119
119
  content = content.replace(/^\n+|\n+$/g, '');
120
120
  content = content.replace(/^/gm, '> ');
121
- return '\n\n' + content + '\n\n'
121
+ return '\n\n' + content + '\n'
122
122
  }
123
123
  };
124
124
 
@@ -863,7 +863,7 @@ function process (parentNode) {
863
863
  replacement = replacementForNode.call(self, node);
864
864
  }
865
865
 
866
- return join(output, replacement)
866
+ return join(output, replacement, node.tagName, node.previousElementSibling?.tagName)
867
867
  }, '')
868
868
  }
869
869
 
@@ -915,10 +915,13 @@ function replacementForNode (node) {
915
915
  * @type String
916
916
  */
917
917
 
918
- function join (output, replacement) {
918
+ function join (output, replacement, tag, previousSiblingTag) {
919
919
  var s1 = trimTrailingNewlines(output);
920
920
  var s2 = trimLeadingNewlines(replacement);
921
921
  var nls = Math.max(output.length - s1.length, replacement.length - s2.length);
922
+ if (tag === "P" && previousSiblingTag === "BLOCKQUOTE") {
923
+ nls = Math.min(nls, 1);
924
+ }
922
925
  var separator = '\n\n'.substring(0, nls);
923
926
 
924
927
  return s1 + separator + s2
@@ -116,7 +116,7 @@ rules.blockquote = {
116
116
  replacement: function (content) {
117
117
  content = content.replace(/^\n+|\n+$/g, '');
118
118
  content = content.replace(/^/gm, '> ');
119
- return '\n\n' + content + '\n\n'
119
+ return '\n\n' + content + '\n'
120
120
  }
121
121
  };
122
122
 
@@ -861,7 +861,7 @@ function process (parentNode) {
861
861
  replacement = replacementForNode.call(self, node);
862
862
  }
863
863
 
864
- return join(output, replacement)
864
+ return join(output, replacement, node.tagName, node.previousElementSibling?.tagName)
865
865
  }, '')
866
866
  }
867
867
 
@@ -913,10 +913,13 @@ function replacementForNode (node) {
913
913
  * @type String
914
914
  */
915
915
 
916
- function join (output, replacement) {
916
+ function join (output, replacement, tag, previousSiblingTag) {
917
917
  var s1 = trimTrailingNewlines(output);
918
918
  var s2 = trimLeadingNewlines(replacement);
919
919
  var nls = Math.max(output.length - s1.length, replacement.length - s2.length);
920
+ if (tag === "P" && previousSiblingTag === "BLOCKQUOTE") {
921
+ nls = Math.min(nls, 1);
922
+ }
920
923
  var separator = '\n\n'.substring(0, nls);
921
924
 
922
925
  return s1 + separator + s2
@@ -122,7 +122,7 @@
122
122
  replacement: function (content) {
123
123
  content = content.replace(/^\n+|\n+$/g, '');
124
124
  content = content.replace(/^/gm, '> ');
125
- return '\n\n' + content + '\n\n'
125
+ return '\n\n' + content + '\n'
126
126
  }
127
127
  };
128
128
 
@@ -867,7 +867,7 @@
867
867
  replacement = replacementForNode.call(self, node);
868
868
  }
869
869
 
870
- return join(output, replacement)
870
+ return join(output, replacement, node.tagName, node.previousElementSibling?.tagName)
871
871
  }, '')
872
872
  }
873
873
 
@@ -919,10 +919,13 @@
919
919
  * @type String
920
920
  */
921
921
 
922
- function join (output, replacement) {
922
+ function join (output, replacement, tag, previousSiblingTag) {
923
923
  var s1 = trimTrailingNewlines(output);
924
924
  var s2 = trimLeadingNewlines(replacement);
925
925
  var nls = Math.max(output.length - s1.length, replacement.length - s2.length);
926
+ if (tag === "P" && previousSiblingTag === "BLOCKQUOTE") {
927
+ nls = Math.min(nls, 1);
928
+ }
926
929
  var separator = '\n\n'.substring(0, nls);
927
930
 
928
931
  return s1 + separator + s2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudrac3r/turndown",
3
3
  "description": "A library that converts HTML to Markdown",
4
- "version": "7.1.4",
4
+ "version": "7.1.5",
5
5
  "author": "Dom Christie",
6
6
  "main": "lib/turndown.cjs.js",
7
7
  "module": "lib/turndown.es.js",