remark-break-line 0.0.10 → 0.0.12
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/lib/index.js +13 -8
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -40,13 +40,13 @@ const elementSize = {
|
|
|
40
40
|
*/
|
|
41
41
|
export default function remarkBreakLongLines({ maxLineLength = 80, removeLinebreaksAndMultipleSpaces = false, mergableElements = [] } = {}) {
|
|
42
42
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
* Transform.
|
|
44
|
+
*
|
|
45
|
+
* @param {Root} tree
|
|
46
|
+
* Tree.
|
|
47
|
+
* @returns {undefined}
|
|
48
|
+
* Nothing.
|
|
49
|
+
*/
|
|
50
50
|
return function (tree) {
|
|
51
51
|
visit(tree, function (node) {
|
|
52
52
|
if (node.type === 'paragraph') {
|
|
@@ -101,6 +101,7 @@ export default function remarkBreakLongLines({ maxLineLength = 80, removeLinebre
|
|
|
101
101
|
first.children.push(middel);
|
|
102
102
|
first.children.push(...last.children);
|
|
103
103
|
n.children.splice(i + 1, 2);
|
|
104
|
+
i--;
|
|
104
105
|
|
|
105
106
|
}
|
|
106
107
|
}
|
|
@@ -228,7 +229,11 @@ export default function remarkBreakLongLines({ maxLineLength = 80, removeLinebre
|
|
|
228
229
|
// we need to split the node
|
|
229
230
|
const current = path[path.length - 1];
|
|
230
231
|
assert(current === 'text');
|
|
231
|
-
|
|
232
|
+
if (lastIndex === -1) {
|
|
233
|
+
return {
|
|
234
|
+
type: 'break-before'
|
|
235
|
+
}
|
|
236
|
+
}
|
|
232
237
|
return {
|
|
233
238
|
type: 'split',
|
|
234
239
|
replaceBy: [{ type: 'text', value: n.value.substring(0, lastIndex) }, { type: 'text', value: n.value.substring(lastIndex + 1) }]
|