remark-break-line 0.0.14 → 0.0.16
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.d.ts +4 -4
- package/lib/index.js +12 -5
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
* Turn gemoji shortcodes (`:+1:`) into emoji (`👍`).
|
|
3
3
|
* @param {Object} [param0={}]
|
|
4
4
|
* @param {number} [param0.maxLineLength=80]
|
|
5
|
-
* @param {boolean} [param0.
|
|
5
|
+
* @param {boolean} [param0.removeLinebreaksAndMultipleSpaces=false]
|
|
6
6
|
* @param {string[]} [param0.mergableElements=[]]
|
|
7
7
|
* @param {boolean}[param0.removeMultpleSpaces=false]
|
|
8
8
|
* @returns
|
|
9
9
|
* Transform.
|
|
10
10
|
*/
|
|
11
|
-
export default function remarkBreakLongLines({ maxLineLength,
|
|
11
|
+
export default function remarkBreakLongLines({ maxLineLength, removeLinebreaksAndMultipleSpaces, mergableElements }?: {
|
|
12
12
|
maxLineLength?: number | undefined;
|
|
13
|
-
|
|
13
|
+
removeLinebreaksAndMultipleSpaces?: boolean | undefined;
|
|
14
14
|
mergableElements?: string[] | undefined;
|
|
15
15
|
removeMultpleSpaces?: boolean | undefined;
|
|
16
|
-
}
|
|
16
|
+
}): (tree: Root) => undefined;
|
|
17
17
|
export type Root = import("mdast").Root;
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* @typedef {import('mdast').Root} Root
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { assert } from 'console'
|
|
6
5
|
import { text } from 'stream/consumers'
|
|
7
6
|
import { visit } from 'unist-util-visit'
|
|
8
7
|
|
|
@@ -130,7 +129,9 @@ export default function remarkBreakLongLines({ maxLineLength = 80, removeLinebre
|
|
|
130
129
|
if (path.some(x => x != 'text')) {
|
|
131
130
|
// we need to split the node
|
|
132
131
|
const current = path[path.length - 1];
|
|
133
|
-
|
|
132
|
+
if (current !== 'text') {
|
|
133
|
+
throw new Error('This should not happen');
|
|
134
|
+
}
|
|
134
135
|
|
|
135
136
|
n.value = n.value.trimStart();
|
|
136
137
|
|
|
@@ -157,7 +158,9 @@ export default function remarkBreakLongLines({ maxLineLength = 80, removeLinebre
|
|
|
157
158
|
if (path.some(x => x != 'text')) {
|
|
158
159
|
// we need to split the node
|
|
159
160
|
const current = path[path.length - 1];
|
|
160
|
-
|
|
161
|
+
if (current !== 'text') {
|
|
162
|
+
throw new Error('This should not happen');
|
|
163
|
+
}
|
|
161
164
|
|
|
162
165
|
return {
|
|
163
166
|
type: 'split',
|
|
@@ -187,7 +190,9 @@ export default function remarkBreakLongLines({ maxLineLength = 80, removeLinebre
|
|
|
187
190
|
if (path.some(x => x != 'text')) {
|
|
188
191
|
// we need to split the node
|
|
189
192
|
const current = path[path.length - 1];
|
|
190
|
-
|
|
193
|
+
if (current !== 'text') {
|
|
194
|
+
throw new Error('This should not happen');
|
|
195
|
+
}
|
|
191
196
|
|
|
192
197
|
|
|
193
198
|
if (lastIndex === -1) {
|
|
@@ -233,7 +238,9 @@ export default function remarkBreakLongLines({ maxLineLength = 80, removeLinebre
|
|
|
233
238
|
if (path.some(x => x != 'text')) {
|
|
234
239
|
// we need to split the node
|
|
235
240
|
const current = path[path.length - 1];
|
|
236
|
-
|
|
241
|
+
if (current !== 'text') {
|
|
242
|
+
throw new Error('This should not happen');
|
|
243
|
+
}
|
|
237
244
|
if (lastIndex === -1) {
|
|
238
245
|
return {
|
|
239
246
|
type: 'break-before'
|