remark-break-line 0.0.13 → 0.0.15
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 +15 -6
- package/package.json +1 -1
- package/index.d.ts +0 -1
- package/lib/index.d.ts +0 -17
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) {
|
|
@@ -206,13 +211,15 @@ export default function remarkBreakLongLines({ maxLineLength = 80, removeLinebre
|
|
|
206
211
|
// We need to increase i because we increase the text
|
|
207
212
|
i++
|
|
208
213
|
n.value = '\n' + n.value
|
|
214
|
+
currentLine = i - lastIndex
|
|
209
215
|
} else if (currentLine + additionalCharacters == maxLineLength - baseIndention) {
|
|
210
216
|
n.value = replaceAt(n.value, i, '\n')
|
|
217
|
+
currentLine = 0;
|
|
211
218
|
|
|
212
219
|
} else {
|
|
213
220
|
n.value = replaceAt(n.value, lastIndex, '\n')
|
|
221
|
+
currentLine = i - lastIndex
|
|
214
222
|
}
|
|
215
|
-
currentLine = i - lastIndex
|
|
216
223
|
}
|
|
217
224
|
}
|
|
218
225
|
|
|
@@ -231,7 +238,9 @@ export default function remarkBreakLongLines({ maxLineLength = 80, removeLinebre
|
|
|
231
238
|
if (path.some(x => x != 'text')) {
|
|
232
239
|
// we need to split the node
|
|
233
240
|
const current = path[path.length - 1];
|
|
234
|
-
|
|
241
|
+
if (current !== 'text') {
|
|
242
|
+
throw new Error('This should not happen');
|
|
243
|
+
}
|
|
235
244
|
if (lastIndex === -1) {
|
|
236
245
|
return {
|
|
237
246
|
type: 'break-before'
|
package/package.json
CHANGED
package/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./lib/index.js";
|
package/lib/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Turn gemoji shortcodes (`:+1:`) into emoji (`👍`).
|
|
3
|
-
* @param {Object} [param0={}]
|
|
4
|
-
* @param {number} [param0.maxLineLength=80]
|
|
5
|
-
* @param {boolean} [param0.removeLinebreaks=false]
|
|
6
|
-
* @param {string[]} [param0.mergableElements=[]]
|
|
7
|
-
* @param {boolean}[param0.removeMultpleSpaces=false]
|
|
8
|
-
* @returns
|
|
9
|
-
* Transform.
|
|
10
|
-
*/
|
|
11
|
-
export default function remarkBreakLongLines({ maxLineLength, removeLinebreaks: removeLinebreaksAndMultipleSpaces, mergableElements }?: {
|
|
12
|
-
maxLineLength?: number | undefined;
|
|
13
|
-
removeLinebreaks?: boolean | undefined;
|
|
14
|
-
mergableElements?: string[] | undefined;
|
|
15
|
-
removeMultpleSpaces?: boolean | undefined;
|
|
16
|
-
} | undefined): (tree: Root) => undefined;
|
|
17
|
-
export type Root = import("mdast").Root;
|