taraskevizer 7.0.0 → 7.0.1
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/bin.js +1 -1
- package/dist/index.cjs +31 -5
- package/dist/index.d.ts +4 -0
- package/dist/index.js +31 -5
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -16,7 +16,7 @@ const printWithPrefix = (msg) => {
|
|
|
16
16
|
process.argv.splice(0, 2);
|
|
17
17
|
const checkForOptions = (options) => process.argv[0] && options.includes(process.argv[0].toLowerCase());
|
|
18
18
|
if (checkForOptions(["-v", "--version"])) {
|
|
19
|
-
printWithPrefix("7.0.
|
|
19
|
+
printWithPrefix("7.0.1");
|
|
20
20
|
process.exit(0);
|
|
21
21
|
}
|
|
22
22
|
if (checkForOptions(["-h", "--help"])) {
|
package/dist/index.cjs
CHANGED
|
@@ -2477,12 +2477,38 @@ var taraskevize = (text) => {
|
|
|
2477
2477
|
// src/steps/whitespaces.ts
|
|
2478
2478
|
var whitespacesToSpaces = (text, { storage }) => {
|
|
2479
2479
|
storage.spaces = [];
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2480
|
+
storage.positions = [];
|
|
2481
|
+
let result = "";
|
|
2482
|
+
let i = 0;
|
|
2483
|
+
while (i < text.length) {
|
|
2484
|
+
if (/\s/.test(text[i])) {
|
|
2485
|
+
let start = i;
|
|
2486
|
+
while (i < text.length && /\s/.test(text[i]))
|
|
2487
|
+
++i;
|
|
2488
|
+
storage.spaces.push(text.slice(start, i));
|
|
2489
|
+
storage.positions.push(result.length);
|
|
2490
|
+
result += " ";
|
|
2491
|
+
} else {
|
|
2492
|
+
result += text[i];
|
|
2493
|
+
++i;
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
return result;
|
|
2497
|
+
};
|
|
2498
|
+
var restoreWhitespaces = (text, { storage }) => {
|
|
2499
|
+
let result = "";
|
|
2500
|
+
let lastIndex = 0;
|
|
2501
|
+
let spaceIndex = 0;
|
|
2502
|
+
for (let i = 0; i < text.length; i++) {
|
|
2503
|
+
if (text[i] === " " && spaceIndex < storage.spaces.length) {
|
|
2504
|
+
result += text.slice(lastIndex, i) + storage.spaces[spaceIndex];
|
|
2505
|
+
lastIndex = i + 1;
|
|
2506
|
+
++spaceIndex;
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
result += text.slice(lastIndex);
|
|
2510
|
+
return result;
|
|
2484
2511
|
};
|
|
2485
|
-
var restoreWhitespaces = (text, { storage }) => text.replace(/ /g, () => storage.spaces.shift());
|
|
2486
2512
|
|
|
2487
2513
|
// src/steps/trim.ts
|
|
2488
2514
|
var trim = (text) => ` ${text.trim()} `;
|
package/dist/index.d.ts
CHANGED
|
@@ -137,6 +137,7 @@ declare const taraskevize: TaraskStep;
|
|
|
137
137
|
|
|
138
138
|
type WhiteSpaceStorage = {
|
|
139
139
|
spaces: string[];
|
|
140
|
+
positions: number[];
|
|
140
141
|
};
|
|
141
142
|
declare const whitespacesToSpaces: TaraskStep<WhiteSpaceStorage>;
|
|
142
143
|
declare const restoreWhitespaces: TaraskStep<WhiteSpaceStorage>;
|
|
@@ -194,6 +195,7 @@ declare const abcOnlyPipeline: (TaraskStep<{
|
|
|
194
195
|
noFixArr: string[];
|
|
195
196
|
}> | TaraskStep<{
|
|
196
197
|
spaces: string[];
|
|
198
|
+
positions: number[];
|
|
197
199
|
}> | ((_: string, { storage, cfg: { general } }: {
|
|
198
200
|
storage: {
|
|
199
201
|
doEscapeCapitalized: boolean;
|
|
@@ -204,11 +206,13 @@ declare const plainTextPipeline: (TaraskStep<SplittedTextStorage> | TaraskStep<{
|
|
|
204
206
|
noFixArr: string[];
|
|
205
207
|
}> | TaraskStep<{
|
|
206
208
|
spaces: string[];
|
|
209
|
+
positions: number[];
|
|
207
210
|
}>)[];
|
|
208
211
|
declare const htmlPipeline: (TaraskStep<SplittedTextStorage> | TaraskStep<{
|
|
209
212
|
noFixArr: string[];
|
|
210
213
|
}> | TaraskStep<{
|
|
211
214
|
spaces: string[];
|
|
215
|
+
positions: number[];
|
|
212
216
|
}>)[];
|
|
213
217
|
|
|
214
218
|
declare const afterTarask: ExtendedDict;
|
package/dist/index.js
CHANGED
|
@@ -2447,12 +2447,38 @@ var taraskevize = (text) => {
|
|
|
2447
2447
|
// src/steps/whitespaces.ts
|
|
2448
2448
|
var whitespacesToSpaces = (text, { storage }) => {
|
|
2449
2449
|
storage.spaces = [];
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2450
|
+
storage.positions = [];
|
|
2451
|
+
let result = "";
|
|
2452
|
+
let i = 0;
|
|
2453
|
+
while (i < text.length) {
|
|
2454
|
+
if (/\s/.test(text[i])) {
|
|
2455
|
+
let start = i;
|
|
2456
|
+
while (i < text.length && /\s/.test(text[i]))
|
|
2457
|
+
++i;
|
|
2458
|
+
storage.spaces.push(text.slice(start, i));
|
|
2459
|
+
storage.positions.push(result.length);
|
|
2460
|
+
result += " ";
|
|
2461
|
+
} else {
|
|
2462
|
+
result += text[i];
|
|
2463
|
+
++i;
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
return result;
|
|
2467
|
+
};
|
|
2468
|
+
var restoreWhitespaces = (text, { storage }) => {
|
|
2469
|
+
let result = "";
|
|
2470
|
+
let lastIndex = 0;
|
|
2471
|
+
let spaceIndex = 0;
|
|
2472
|
+
for (let i = 0; i < text.length; i++) {
|
|
2473
|
+
if (text[i] === " " && spaceIndex < storage.spaces.length) {
|
|
2474
|
+
result += text.slice(lastIndex, i) + storage.spaces[spaceIndex];
|
|
2475
|
+
lastIndex = i + 1;
|
|
2476
|
+
++spaceIndex;
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
result += text.slice(lastIndex);
|
|
2480
|
+
return result;
|
|
2454
2481
|
};
|
|
2455
|
-
var restoreWhitespaces = (text, { storage }) => text.replace(/ /g, () => storage.spaces.shift());
|
|
2456
2482
|
|
|
2457
2483
|
// src/steps/trim.ts
|
|
2458
2484
|
var trim = (text) => ` ${text.trim()} `;
|