taraskevizer 9.1.5 → 9.1.7

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 CHANGED
@@ -7,7 +7,7 @@ const printWithPrefix = (msg) => {
7
7
  process.argv.splice(0, 2);
8
8
  const checkForOptions = (options) => process.argv[0] && options.includes(process.argv[0].toLowerCase());
9
9
  if (checkForOptions(['-v', '--version'])) {
10
- printWithPrefix("9.1.5");
10
+ printWithPrefix("9.1.7");
11
11
  process.exit(0);
12
12
  }
13
13
  if (checkForOptions(['-h', '--help'])) {
package/dist/config.d.ts CHANGED
@@ -1,14 +1,12 @@
1
1
  import type { PartialReadonly } from './types';
2
- import { Alphabet } from './dict/alphabets';
3
- import { WrapperDict } from './wrappers';
2
+ import type { Alphabet } from './dict/alphabets';
3
+ import { type WrapperDict } from './wrappers';
4
4
  export type Variation = 'no' | 'first' | 'all';
5
5
  export type OptionJ = 'never' | 'random' | 'always';
6
6
  export declare class TaraskConfig {
7
7
  constructor(options?: PartialReadonly<TaraskConfig>);
8
8
  /**
9
- * Any object that implements the {@link Alphabet} interface.
10
- *
11
- * The set of defined alphabets can be found in {@link dicts.alphabets}.
9
+ * Predefined alphabets are in {@link dicts.alphabets}.
12
10
  *
13
11
  * @default alphabets.cyrillic
14
12
  */
@@ -32,7 +30,14 @@ export declare class TaraskConfig {
32
30
  * @default true
33
31
  */
34
32
  doEscapeCapitalized: boolean;
35
- /** @default null */
33
+ /**
34
+ * Used for wrapping changed parts.
35
+ * Predefined dicts are in {@link wrappers}.
36
+ *
37
+ * If `null`, wrapping changes will be skipped.
38
+ *
39
+ * @default null
40
+ */
36
41
  wrapperDict: null | WrapperDict;
37
42
  /**
38
43
  * Do replace ґ(g) by г(h) in cyrillic alphabet?
@@ -58,7 +63,19 @@ export declare class TaraskConfig {
58
63
  * @default "all"
59
64
  */
60
65
  variations: Variation;
66
+ /**
67
+ * String to replace `"\n"` with.
68
+ *
69
+ * @default "\n"
70
+ * @example "<br>"
71
+ */
61
72
  newLine: string;
73
+ /**
74
+ * String to replace `"<"` with.
75
+ *
76
+ * @default "<"
77
+ * @example "&lt;"
78
+ */
62
79
  leftAngleBracket: string;
63
80
  }
64
81
  /**
@@ -71,8 +88,8 @@ export declare class TaraskConfig {
71
88
  * });
72
89
  */
73
90
  export declare const htmlConfigOptions: {
74
- wrapperDict: Required<WrapperDict>;
75
- g: false;
76
- newLine: string;
77
- leftAngleBracket: string;
91
+ readonly wrapperDict: Required<WrapperDict>;
92
+ readonly g: false;
93
+ readonly newLine: "<br>";
94
+ readonly leftAngleBracket: "&lt";
78
95
  };
package/dist/config.js CHANGED
@@ -20,7 +20,9 @@ export class TaraskConfig {
20
20
  g = true;
21
21
 
22
22
  variations = 'all';
23
+
23
24
  newLine = '\n';
25
+
24
26
  leftAngleBracket = '<';
25
27
  }
26
28
 
@@ -1,4 +1,4 @@
1
- import { OptionJ, Variation } from './config';
1
+ import type { OptionJ, Variation } from './config';
2
2
  /**
3
3
  * @deprecated since 9.1.0. Will be removed in 10.0.0
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { iwords } from './iwords.js';
2
2
  import { dictFrom, toOneLine } from './lib.js';
3
- const ia = (word, words) => ` ${word}(?= \\(?(?:[бвгджзйклмнпрстфцчшў]*[оё]|${toOneLine(words).replace(/\(/g, '(?:')}|i(?:${iwords})))`;
3
+ const ia = (word, words) => ` ${word}(?= \\(?(?:[бвгджзйклмнпрстфцчшўьʼ]*[оё]|${toOneLine(words).replace(/\(/g, '(?:')}|i(?:${iwords})))`;
4
4
  export const iaWords = dictFrom.raw([
5
5
 
6
6
  [
@@ -1,13 +1,17 @@
1
1
  const prepositionPattern = /^(?:а[бд]?|б[ея]зь?|[дз]а|д?ля|дзеля|[нп]ад?|пр[аы]|празь?|у|церазь?)$/;
2
2
  const isSingleVowel = (str) => str.match(/[аеёіоуыэюя]/g)?.length === 1;
3
+ const isFirstSyllabeStressed = (word) => /^[бвгджзйклмнпрстфцчшўьʼ]*.\u0301/.test(word);
3
4
  export const endZSoftenAndNiaBiaz = [
4
5
  [
5
6
  / бе(зь? \S+)/g,
6
- ($0, $1) => (isSingleVowel($1) ? ' бя' + $1 : $0),
7
+ ($0, $1) => isFirstSyllabeStressed($1) || isSingleVowel($1) ? ' бя' + $1 : $0,
7
8
  ],
8
9
  [
9
10
  / не (\S+)/g,
10
- ($0, $1) => isSingleVowel($1) && !prepositionPattern.test($1) ? ' ня ' + $1 : $0,
11
+ ($0, $1) => isFirstSyllabeStressed($1) ||
12
+ (isSingleVowel($1) && !prepositionPattern.test($1))
13
+ ? ' ня ' + $1
14
+ : $0,
11
15
  ],
12
16
  [/ б[ея]з(?= і\S*[ая]ў|ну )/g, ' бязь'],
13
17
  [/( (?:пра|цера)?з)(?= і\S*[ая]ў|ну )/g, (_$0, $1) => $1 + 'ь'],
@@ -1,4 +1,4 @@
1
- import { TaraskStep } from '../steps/types';
1
+ import type { TaraskStep } from '../steps/types';
2
2
  /**
3
3
  * An abstraction for a step that always changes the text.
4
4
  *
@@ -1,8 +1,11 @@
1
1
  import { mutatingStep } from '../lib/index.js';
2
2
 
3
- export const finalize = mutatingStep(({ text, cfg: { newLine } }) => text
4
- .replace(/&#40/g, '(')
5
- .replace(/&nbsp;/g, ' ')
6
- .replace(/ (\p{P}|\p{S}|\d+) /gu, '$1')
7
- .replace(/\n/g, newLine)
8
- .trim());
3
+ export const finalize = mutatingStep(({ text, cfg: { newLine } }) => {
4
+ text = text
5
+ .replace(/&#40/g, '(')
6
+ .replace(/&nbsp;/g, ' ')
7
+ .replace(/ (\p{P}|\p{S}|\d+) /gu, '$1');
8
+ if (newLine !== '\n')
9
+ text = text.replace(/\n/g, newLine);
10
+ return text.trim();
11
+ });
@@ -1,2 +1,2 @@
1
- import { SplittedTextStorage } from './types';
1
+ import type { SplittedTextStorage } from './types';
2
2
  export declare const joinSplittedText: import("./types").TaraskStep<SplittedTextStorage>;
@@ -1,4 +1,4 @@
1
- import { TaraskConfig } from '../config';
1
+ import type { TaraskConfig } from '../config';
2
2
  export type TaraskStep<Storage extends object = {}> = (args: {
3
3
  text: string;
4
4
  storage: Storage;
@@ -1,4 +1,4 @@
1
- import { Variation } from './config';
1
+ import type { Variation } from './config';
2
2
  type TransformString = (content: string) => string;
3
3
  export type VariationWrappers = {
4
4
  [p in Variation]: TransformString;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taraskevizer",
3
- "version": "9.1.5",
3
+ "version": "9.1.7",
4
4
  "author": "GooseOb",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,12 +10,12 @@
10
10
  "module": "dist/index.js",
11
11
  "devDependencies": {
12
12
  "@digitak/esrun": "^3.2.26",
13
- "@types/node": "^20.14.11",
14
- "bun-types": "^1.1.20",
15
- "husky": "^9.1.0",
13
+ "@types/node": "^20.14.14",
14
+ "bun-types": "^1.1.21",
15
+ "husky": "^9.1.4",
16
16
  "prettier": "^3.3.3",
17
17
  "typedoc": "^0.25.13",
18
- "typescript": "^5.5.3"
18
+ "typescript": "^5.5.4"
19
19
  },
20
20
  "bin": {
21
21
  "tarask": "dist/bin.js"