@nkardaz/typography-rules 1.0.0
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/LICENSE +21 -0
- package/README.md +911 -0
- package/dist/api/blacklist.d.ts +72 -0
- package/dist/api/htmlNodes.d.ts +30 -0
- package/dist/api/index.d.ts +6 -0
- package/dist/api/newRule.d.ts +51 -0
- package/dist/api/registerRule.d.ts +27 -0
- package/dist/api/rulesInit.d.ts +49 -0
- package/dist/functions/chemNotation.d.ts +10 -0
- package/dist/functions/clearSpaces.d.ts +16 -0
- package/dist/functions/index.cjs +514 -0
- package/dist/functions/index.d.ts +8 -0
- package/dist/functions/index.mjs +491 -0
- package/dist/functions/rubyText.d.ts +11 -0
- package/dist/functions/runt.d.ts +3 -0
- package/dist/functions/smartNumberGrouping.d.ts +25 -0
- package/dist/functions/smartQuotes.d.ts +29 -0
- package/dist/functions/wrapWithTag.d.ts +42 -0
- package/dist/glyphs/index.cjs +737 -0
- package/dist/glyphs/index.d.ts +53 -0
- package/dist/glyphs/index.mjs +714 -0
- package/dist/glyphs/proto.d.ts +11 -0
- package/dist/glyphs/registry.d.ts +728 -0
- package/dist/glyphs/types.d.ts +151 -0
- package/dist/helpers/index.cjs +268 -0
- package/dist/helpers/index.d.ts +133 -0
- package/dist/helpers/index.mjs +245 -0
- package/dist/helpers/types.d.ts +71 -0
- package/dist/index.cjs +985 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +977 -0
- package/dist/style/index.d.ts +2 -0
- package/dist/style/main.css +16 -0
- package/dist/types.d.ts +223 -0
- package/dist/typography/aliases.d.ts +129 -0
- package/dist/typography/expressions/common.d.ts +29 -0
- package/dist/typography/expressions/en.d.ts +25 -0
- package/dist/typography/expressions/ru.d.ts +29 -0
- package/dist/typography/markup/common.d.ts +17 -0
- package/dist/typography/markup/en.d.ts +3 -0
- package/dist/typography/markup/index.d.ts +4 -0
- package/dist/typography/markup/ru.d.ts +3 -0
- package/dist/typography/sets/ang.d.ts +3 -0
- package/dist/typography/sets/common.d.ts +17 -0
- package/dist/typography/sets/en.d.ts +14 -0
- package/dist/typography/sets/index.d.ts +5 -0
- package/dist/typography/sets/ru.d.ts +16 -0
- package/dist/typography/store.d.ts +63 -0
- package/package.json +92 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* src/style/main.css */
|
|
2
|
+
.\@nkardaz-typography-ruby {
|
|
3
|
+
&.--alternate {
|
|
4
|
+
-webkit-ruby-position: alternate;
|
|
5
|
+
ruby-position: alternate;
|
|
6
|
+
}
|
|
7
|
+
&.--over {
|
|
8
|
+
-webkit-ruby-position: over;
|
|
9
|
+
ruby-position: over;
|
|
10
|
+
}
|
|
11
|
+
&.--under {
|
|
12
|
+
-webkit-ruby-position: under;
|
|
13
|
+
ruby-position: under;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/*# sourceMappingURL=main.css.map */
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import type { Spaces } from '@/glyphs';
|
|
2
|
+
/**
|
|
3
|
+
* Base configuration for all typography rules.
|
|
4
|
+
*
|
|
5
|
+
* Provides shared properties such as execution priority.
|
|
6
|
+
*
|
|
7
|
+
* @property weight - Optional execution weight used for sorting rules.
|
|
8
|
+
* Lower values are executed earlier.
|
|
9
|
+
*/
|
|
10
|
+
export interface BaseRule {
|
|
11
|
+
label: string;
|
|
12
|
+
weight?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Typography rule that performs direct string replacement using RegExp.
|
|
16
|
+
*
|
|
17
|
+
* Matches a pattern and replaces it with a static string value.
|
|
18
|
+
*
|
|
19
|
+
* @property kind - Rule type identifier ("replace")
|
|
20
|
+
* @property rule - Regular expression used for matching text
|
|
21
|
+
* @property replacement - Replacement string applied to matches
|
|
22
|
+
*/
|
|
23
|
+
export type RegExpReplaceRule = BaseRule & {
|
|
24
|
+
kind: 'replace';
|
|
25
|
+
rule: RegExp;
|
|
26
|
+
replacement: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Typography rule that transforms matched RegExp results dynamically.
|
|
30
|
+
*
|
|
31
|
+
* Unlike replace rules, transformation logic is computed per match.
|
|
32
|
+
*
|
|
33
|
+
* @property kind - Rule type identifier ("transform")
|
|
34
|
+
* @property rule - Regular expression used for matching text
|
|
35
|
+
* @property transform - Function that returns replacement string for each match
|
|
36
|
+
*/
|
|
37
|
+
export type RegExpTransformRule = BaseRule & {
|
|
38
|
+
kind: 'transform';
|
|
39
|
+
rule: RegExp;
|
|
40
|
+
transform: (match: RegExpExecArray) => string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Typography rule based on a custom processing function.
|
|
44
|
+
*
|
|
45
|
+
* Used for complex transformations that cannot be expressed with RegExp.
|
|
46
|
+
*
|
|
47
|
+
* @property label - Descriptive name of the function rule
|
|
48
|
+
* @property kind - Rule type identifier ("function")
|
|
49
|
+
* @property rule - Function applied to full text input
|
|
50
|
+
* @property args - Optional arguments passed to the rule function
|
|
51
|
+
*/
|
|
52
|
+
export type FunctionRule<TArgs extends unknown[] = unknown[], TFn extends (text: string, ...args: TArgs) => string = (text: string, ...args: TArgs) => string> = BaseRule & {
|
|
53
|
+
label: string;
|
|
54
|
+
kind: 'function';
|
|
55
|
+
rule: TFn;
|
|
56
|
+
args: TArgs;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Typography rule that transforms RegExp matches into DOM/Tree nodes.
|
|
60
|
+
*
|
|
61
|
+
* @property label - Descriptive name of the node rule
|
|
62
|
+
* @property kind - Rule type identifier ("node")
|
|
63
|
+
* @property rule - Regular expression used for matching text
|
|
64
|
+
* @property nodes - Function that maps a RegExp match to a Node structure
|
|
65
|
+
*/
|
|
66
|
+
export type NodeFunctionRule = BaseRule & {
|
|
67
|
+
label: string;
|
|
68
|
+
kind: 'node';
|
|
69
|
+
rule: RegExp;
|
|
70
|
+
nodes: (match: RegExpExecArray) => Node;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Generic typography processing function signature.
|
|
74
|
+
*
|
|
75
|
+
* Accepts a text input and optional additional arguments,
|
|
76
|
+
* and returns a transformed string or a set of nodes.
|
|
77
|
+
*/
|
|
78
|
+
export type RuleFunction = (text: string, ...args: never[]) => string | Node[];
|
|
79
|
+
/**
|
|
80
|
+
* Union type representing all available typography rule variants.
|
|
81
|
+
*
|
|
82
|
+
* Includes:
|
|
83
|
+
* - RegExp-based replacement rules
|
|
84
|
+
* - RegExp-based transform rules
|
|
85
|
+
* - Function-based rules
|
|
86
|
+
* - Node-based rules
|
|
87
|
+
*/
|
|
88
|
+
export type Rule = RegExpReplaceRule | RegExpTransformRule | FunctionRule | NodeFunctionRule;
|
|
89
|
+
/**
|
|
90
|
+
* Represents a basic text leaf node in the document structure.
|
|
91
|
+
*
|
|
92
|
+
* @property type - Node discriminator ("text")
|
|
93
|
+
* @property value - The raw text content
|
|
94
|
+
*/
|
|
95
|
+
export interface TextNode {
|
|
96
|
+
type: 'text';
|
|
97
|
+
value: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Represents an element node containing children in the document structure.
|
|
101
|
+
*
|
|
102
|
+
* @property type - The element tag or identifier
|
|
103
|
+
* @property className - Optional CSS class for the element
|
|
104
|
+
* @property attrs - Optional key-value map of HTML attributes
|
|
105
|
+
* @property children - Array of child nodes
|
|
106
|
+
*/
|
|
107
|
+
export interface ElementNode {
|
|
108
|
+
type: string;
|
|
109
|
+
className?: string;
|
|
110
|
+
attrs?: Record<string, string>;
|
|
111
|
+
children: Node[];
|
|
112
|
+
data?: Record<string, boolean | string | number>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Union type representing a node within the document tree.
|
|
116
|
+
*/
|
|
117
|
+
export type Node = TextNode | ElementNode;
|
|
118
|
+
/**
|
|
119
|
+
* Configuration for smart quote transformation.
|
|
120
|
+
*
|
|
121
|
+
* Defines outer and inner quotation marks used during nesting.
|
|
122
|
+
*
|
|
123
|
+
* @property outer - Primary quote pair [opening, closing]
|
|
124
|
+
* @property inner - Nested quote pair [opening, closing]
|
|
125
|
+
*/
|
|
126
|
+
export interface QuoteSettings {
|
|
127
|
+
outer?: [string, string];
|
|
128
|
+
inner?: [string, string];
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Configuration for numeric spacing rules.
|
|
132
|
+
*
|
|
133
|
+
* Controls how spacing is applied inside numeric expressions.
|
|
134
|
+
*
|
|
135
|
+
* @property minLength - Minimum digit length required to apply spacing
|
|
136
|
+
* @property separateFloat - Whether to format fractional parts separately
|
|
137
|
+
* @property separator - Character used as a spacing separator
|
|
138
|
+
*/
|
|
139
|
+
export interface NumberSpaceSettings {
|
|
140
|
+
minLength?: number;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Configuration for space removal rules.
|
|
144
|
+
*
|
|
145
|
+
* @property spaces - Array of space characters to remove
|
|
146
|
+
*/
|
|
147
|
+
export interface ClearSpacesSettings {
|
|
148
|
+
spaces?: Spaces[] | string[];
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Configuration for runt handling.
|
|
152
|
+
*
|
|
153
|
+
* @property threshold - Threshold value for runt detection
|
|
154
|
+
* @property space - Space character used for runt replacement
|
|
155
|
+
* @property minLineLength - Minimum line length for runt detection
|
|
156
|
+
*/
|
|
157
|
+
export interface RuntSettings {
|
|
158
|
+
threshold?: number;
|
|
159
|
+
space?: Spaces | string;
|
|
160
|
+
minLineLength?: number;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Configuration for rules that convert text matches into HTML structures.
|
|
164
|
+
*
|
|
165
|
+
* @property expression - RegExp used to identify target text
|
|
166
|
+
* @property nodes - Factory function to generate Node structures from matches
|
|
167
|
+
*/
|
|
168
|
+
export interface HtmlNodeSettings {
|
|
169
|
+
expression?: RegExp;
|
|
170
|
+
nodes?: (match: RegExpExecArray) => Node;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Base configuration for text wrappers.
|
|
174
|
+
*
|
|
175
|
+
* @property marker - String used to identify the wrap boundaries
|
|
176
|
+
* @property wrapper - The opening and closing strings to wrap text with
|
|
177
|
+
*/
|
|
178
|
+
export interface WrapperBaseSettings {
|
|
179
|
+
marker?: string;
|
|
180
|
+
wrapper?: [string, string];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Settings for wrapping text within specific HTML tags.
|
|
184
|
+
*
|
|
185
|
+
* @property tag - The HTML tag to use for wrapping
|
|
186
|
+
*/
|
|
187
|
+
export interface WrapWithTagsSettings extends WrapperBaseSettings {
|
|
188
|
+
tag?: string;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Settings for wrapping text matched by a custom RegExp into an HTML tag.
|
|
192
|
+
*
|
|
193
|
+
* @property expression - RegExp used to identify target text
|
|
194
|
+
* @property tag - The HTML tag to use for wrapping
|
|
195
|
+
* @property placement - Optional template string defining where the tag is inserted.
|
|
196
|
+
* Uses `$1`, `$2`, etc. as capture group references and `<TAG>...</TAG>` to mark
|
|
197
|
+
* the wrapped region. When omitted, the entire match is wrapped.
|
|
198
|
+
* Example: `'$1<TAG>$2</TAG>'` wraps only the second capture group.
|
|
199
|
+
*/
|
|
200
|
+
export interface WrapWithTagExpressionSettings {
|
|
201
|
+
expression: RegExp;
|
|
202
|
+
tag?: string;
|
|
203
|
+
placement?: string;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Settings for ruby annotation text formatting.
|
|
207
|
+
*/
|
|
208
|
+
export type RubyTextSettings = WrapperBaseSettings;
|
|
209
|
+
/**
|
|
210
|
+
* Settings for chemical notation formatting.
|
|
211
|
+
*/
|
|
212
|
+
export type ChemNotationSettings = WrapperBaseSettings;
|
|
213
|
+
/**
|
|
214
|
+
* General configuration for HTML tag output.
|
|
215
|
+
*
|
|
216
|
+
* @property className - CSS class to apply to the generated tag
|
|
217
|
+
* @property attrs - Additional HTML attributes for the generated tag
|
|
218
|
+
*/
|
|
219
|
+
export interface TagSettings {
|
|
220
|
+
className?: string;
|
|
221
|
+
attrs?: Record<string, string>;
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a normalized alias map with utility methods.
|
|
3
|
+
* All keys and values are automatically lowercased on creation.
|
|
4
|
+
*
|
|
5
|
+
* @param map - An object where each key is a root alias and its value is an array of alternative names.
|
|
6
|
+
* @returns A Proxy object providing direct key access and alias resolution methods.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const ALIAS = createAlias({
|
|
10
|
+
* en: ['en-US', 'English'],
|
|
11
|
+
* ru: ['ru-RU', 'Russian'],
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* ALIAS.en // ['en-us', 'english']
|
|
15
|
+
* ALIAS.resolve('English') // 'en'
|
|
16
|
+
* ALIAS.has('ru-RU') // true
|
|
17
|
+
*/
|
|
18
|
+
export declare function createAlias<T extends Record<string, string[]>>(map: T): {
|
|
19
|
+
/**
|
|
20
|
+
* Checks whether an alias exists in the map,
|
|
21
|
+
* either as a root key or as an alternative name.
|
|
22
|
+
*
|
|
23
|
+
* @param alias - The alias to look up (case-insensitive).
|
|
24
|
+
* @returns `true` if the alias is found, `false` otherwise.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ALIAS.has('English') // true
|
|
28
|
+
* ALIAS.has('fr') // false
|
|
29
|
+
*/
|
|
30
|
+
has(alias: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Resolves an alias to its root key.
|
|
33
|
+
*
|
|
34
|
+
* @param alias - The alias to resolve (case-insensitive).
|
|
35
|
+
* @returns The root key if found, `undefined` otherwise.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ALIAS.resolve('Russian') // 'ru'
|
|
39
|
+
* ALIAS.resolve('ru-RU') // 'ru'
|
|
40
|
+
* ALIAS.resolve('fr') // undefined
|
|
41
|
+
*/
|
|
42
|
+
resolve(alias: string): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Adds one or more alternative names to an existing or new root key.
|
|
45
|
+
* All values are automatically lowercased.
|
|
46
|
+
*
|
|
47
|
+
* @param root - The root key to add aliases to.
|
|
48
|
+
* @param aliases - One or more alternative names to register.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ALIAS.push('ru', 'Рус', 'ру')
|
|
52
|
+
* ALIAS.ru // ['ru-ru', 'russian', 'русский', 'рус', 'ру']
|
|
53
|
+
*/
|
|
54
|
+
push(root: string, ...aliases: string[]): void;
|
|
55
|
+
/**
|
|
56
|
+
* Normalizes one or more strings to lowercase.
|
|
57
|
+
*
|
|
58
|
+
* @param alias - One or more strings to normalize.
|
|
59
|
+
* @returns An array of lowercased strings.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ALIAS.normalize('English', 'RU-RU') // ['english', 'ru-ru']
|
|
63
|
+
*/
|
|
64
|
+
normalize(...alias: string[]): string[];
|
|
65
|
+
} & { [K in keyof T]: string[]; };
|
|
66
|
+
/**
|
|
67
|
+
* Global alias map for supported locales.
|
|
68
|
+
*
|
|
69
|
+
* Provides normalized access to locale identifiers and their alternatives.
|
|
70
|
+
* All lookups are case-insensitive.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ALIAS.ru // ['ru-ru', 'russian', 'русский']
|
|
74
|
+
* ALIAS.resolve('Русский') // 'ru'
|
|
75
|
+
* ALIAS.has('Old English') // true
|
|
76
|
+
*/
|
|
77
|
+
export declare const ALIAS: {
|
|
78
|
+
/**
|
|
79
|
+
* Checks whether an alias exists in the map,
|
|
80
|
+
* either as a root key or as an alternative name.
|
|
81
|
+
*
|
|
82
|
+
* @param alias - The alias to look up (case-insensitive).
|
|
83
|
+
* @returns `true` if the alias is found, `false` otherwise.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ALIAS.has('English') // true
|
|
87
|
+
* ALIAS.has('fr') // false
|
|
88
|
+
*/
|
|
89
|
+
has(alias: string): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Resolves an alias to its root key.
|
|
92
|
+
*
|
|
93
|
+
* @param alias - The alias to resolve (case-insensitive).
|
|
94
|
+
* @returns The root key if found, `undefined` otherwise.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ALIAS.resolve('Russian') // 'ru'
|
|
98
|
+
* ALIAS.resolve('ru-RU') // 'ru'
|
|
99
|
+
* ALIAS.resolve('fr') // undefined
|
|
100
|
+
*/
|
|
101
|
+
resolve(alias: string): string | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Adds one or more alternative names to an existing or new root key.
|
|
104
|
+
* All values are automatically lowercased.
|
|
105
|
+
*
|
|
106
|
+
* @param root - The root key to add aliases to.
|
|
107
|
+
* @param aliases - One or more alternative names to register.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ALIAS.push('ru', 'Рус', 'ру')
|
|
111
|
+
* ALIAS.ru // ['ru-ru', 'russian', 'русский', 'рус', 'ру']
|
|
112
|
+
*/
|
|
113
|
+
push(root: string, ...aliases: string[]): void;
|
|
114
|
+
/**
|
|
115
|
+
* Normalizes one or more strings to lowercase.
|
|
116
|
+
*
|
|
117
|
+
* @param alias - One or more strings to normalize.
|
|
118
|
+
* @returns An array of lowercased strings.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ALIAS.normalize('English', 'RU-RU') // ['english', 'ru-ru']
|
|
122
|
+
*/
|
|
123
|
+
normalize(...alias: string[]): string[];
|
|
124
|
+
} & {
|
|
125
|
+
ru: string[];
|
|
126
|
+
en: string[];
|
|
127
|
+
ang: string[];
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=aliases.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const PARTS: {
|
|
2
|
+
readonly numerals: string;
|
|
3
|
+
readonly interNumber: string;
|
|
4
|
+
readonly walletSymbols: string;
|
|
5
|
+
readonly walletISO: string;
|
|
6
|
+
readonly leftBrackets: string;
|
|
7
|
+
readonly rightBrackets: string;
|
|
8
|
+
readonly percentLike: string;
|
|
9
|
+
readonly expressivePunctuation: string;
|
|
10
|
+
readonly number: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const EXPRESSIONS: {
|
|
13
|
+
readonly plusMinus: RegExp;
|
|
14
|
+
readonly minusPlus: RegExp;
|
|
15
|
+
readonly sectionNumeral: RegExp;
|
|
16
|
+
readonly percentValue: RegExp;
|
|
17
|
+
readonly numeralsRange: RegExp;
|
|
18
|
+
readonly ellipsisRange: RegExp;
|
|
19
|
+
readonly multipleEllipsis: RegExp;
|
|
20
|
+
readonly walletSymbolBeforeValue: RegExp;
|
|
21
|
+
readonly walletSymbolAfterValue: RegExp;
|
|
22
|
+
readonly walletISOBeforeValue: RegExp;
|
|
23
|
+
readonly walletISOAfterValue: RegExp;
|
|
24
|
+
readonly expressiveAposiopesis: RegExp;
|
|
25
|
+
readonly backwardsExpressiveAposiopesis: RegExp;
|
|
26
|
+
readonly temperature: RegExp;
|
|
27
|
+
};
|
|
28
|
+
export default EXPRESSIONS;
|
|
29
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const EXPRESSIONS: {
|
|
2
|
+
readonly numberNumeral: RegExp;
|
|
3
|
+
readonly invalidPunctuationSpacing: RegExp;
|
|
4
|
+
readonly siUnitMul: RegExp;
|
|
5
|
+
readonly siUnitDiv: RegExp;
|
|
6
|
+
readonly siUnitBase: RegExp;
|
|
7
|
+
readonly siUnitPowAfterNum: RegExp;
|
|
8
|
+
readonly siUnitPow: RegExp;
|
|
9
|
+
readonly plusMinus: RegExp;
|
|
10
|
+
readonly minusPlus: RegExp;
|
|
11
|
+
readonly sectionNumeral: RegExp;
|
|
12
|
+
readonly percentValue: RegExp;
|
|
13
|
+
readonly numeralsRange: RegExp;
|
|
14
|
+
readonly ellipsisRange: RegExp;
|
|
15
|
+
readonly multipleEllipsis: RegExp;
|
|
16
|
+
readonly walletSymbolBeforeValue: RegExp;
|
|
17
|
+
readonly walletSymbolAfterValue: RegExp;
|
|
18
|
+
readonly walletISOBeforeValue: RegExp;
|
|
19
|
+
readonly walletISOAfterValue: RegExp;
|
|
20
|
+
readonly expressiveAposiopesis: RegExp;
|
|
21
|
+
readonly backwardsExpressiveAposiopesis: RegExp;
|
|
22
|
+
readonly temperature: RegExp;
|
|
23
|
+
};
|
|
24
|
+
export default EXPRESSIONS;
|
|
25
|
+
//# sourceMappingURL=en.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare const EXPRESSIONS: {
|
|
2
|
+
readonly numeroNumeral: RegExp;
|
|
3
|
+
readonly invalidPunctuationSpacing: RegExp;
|
|
4
|
+
readonly dialogEmDash: RegExp;
|
|
5
|
+
readonly attributionEmDash: RegExp;
|
|
6
|
+
readonly subjectPredicateEmDash: RegExp;
|
|
7
|
+
readonly siUnitMul: RegExp;
|
|
8
|
+
readonly siUnitDiv: RegExp;
|
|
9
|
+
readonly siUnitBase: RegExp;
|
|
10
|
+
readonly siUnitPowAfterNum: RegExp;
|
|
11
|
+
readonly siUnitPow: RegExp;
|
|
12
|
+
readonly date: RegExp;
|
|
13
|
+
readonly plusMinus: RegExp;
|
|
14
|
+
readonly minusPlus: RegExp;
|
|
15
|
+
readonly sectionNumeral: RegExp;
|
|
16
|
+
readonly percentValue: RegExp;
|
|
17
|
+
readonly numeralsRange: RegExp;
|
|
18
|
+
readonly ellipsisRange: RegExp;
|
|
19
|
+
readonly multipleEllipsis: RegExp;
|
|
20
|
+
readonly walletSymbolBeforeValue: RegExp;
|
|
21
|
+
readonly walletSymbolAfterValue: RegExp;
|
|
22
|
+
readonly walletISOBeforeValue: RegExp;
|
|
23
|
+
readonly walletISOAfterValue: RegExp;
|
|
24
|
+
readonly expressiveAposiopesis: RegExp;
|
|
25
|
+
readonly backwardsExpressiveAposiopesis: RegExp;
|
|
26
|
+
readonly temperature: RegExp;
|
|
27
|
+
};
|
|
28
|
+
export default EXPRESSIONS;
|
|
29
|
+
//# sourceMappingURL=ru.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared markup rules applied across all locales.
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - whitespace normalization
|
|
6
|
+
* - dash normalization (hyphens, en/em dashes)
|
|
7
|
+
* - ellipsis conversion
|
|
8
|
+
* - math symbol normalization
|
|
9
|
+
* - number spacing rules
|
|
10
|
+
* - apostrophe normalization
|
|
11
|
+
*
|
|
12
|
+
* This layer forms the base typography pipeline
|
|
13
|
+
* before locale-specific transformations.
|
|
14
|
+
*/
|
|
15
|
+
declare const _default: import("../..").Rule[];
|
|
16
|
+
export default _default;
|
|
17
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared typography rules applied across all locales.
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - whitespace normalization
|
|
6
|
+
* - dash normalization (hyphens, en/em dashes)
|
|
7
|
+
* - ellipsis conversion
|
|
8
|
+
* - math symbol normalization
|
|
9
|
+
* - number spacing rules
|
|
10
|
+
* - apostrophe normalization
|
|
11
|
+
*
|
|
12
|
+
* This layer forms the base typography pipeline
|
|
13
|
+
* before locale-specific transformations.
|
|
14
|
+
*/
|
|
15
|
+
declare const _default: import("../..").Rule[];
|
|
16
|
+
export default _default;
|
|
17
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* English typography ruleset.
|
|
3
|
+
*
|
|
4
|
+
* Includes:
|
|
5
|
+
* - smart quote replacement (US style)
|
|
6
|
+
* - ligature substitution (fi, fl, ffi, ffl)
|
|
7
|
+
* - currency formatting normalization
|
|
8
|
+
* - spacing cleanup for punctuation
|
|
9
|
+
*
|
|
10
|
+
* Designed for Latin-script typography processing.
|
|
11
|
+
*/
|
|
12
|
+
declare const _default: import("../..").Rule[];
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=en.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Russian typography ruleset.
|
|
3
|
+
*
|
|
4
|
+
* Extends common rules with:
|
|
5
|
+
* - Russian-style smart quotes
|
|
6
|
+
* - spacing normalization for punctuation
|
|
7
|
+
* - em-dash formatting rules
|
|
8
|
+
* - currency formatting (RUB and others)
|
|
9
|
+
* - abbreviation spacing rules
|
|
10
|
+
* - grammatical particle spacing rules
|
|
11
|
+
*
|
|
12
|
+
* Designed for Cyrillic-script normalization.
|
|
13
|
+
*/
|
|
14
|
+
declare const _default: import("../..").Rule[];
|
|
15
|
+
export default _default;
|
|
16
|
+
//# sourceMappingURL=ru.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Rule } from '@/types';
|
|
2
|
+
/**
|
|
3
|
+
* Global typography rule registry.
|
|
4
|
+
*
|
|
5
|
+
* Stores rule pipelines grouped by locale key.
|
|
6
|
+
*
|
|
7
|
+
* Structure:
|
|
8
|
+
* — "common": rules applied to all locales
|
|
9
|
+
* — "[locale]": locale-specific rule overrides
|
|
10
|
+
*
|
|
11
|
+
* Each entry contains a list of transformation rules
|
|
12
|
+
* executed during typography processing.
|
|
13
|
+
*
|
|
14
|
+
* Direct assignment (e.g. typographyRules['en'] = [...]) automatically
|
|
15
|
+
* invalidates the weighted rules cache for the affected locale.
|
|
16
|
+
*/
|
|
17
|
+
export declare const typographyRules: Record<string, Rule[] | undefined>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a merged and weight-sorted rule pipeline.
|
|
20
|
+
*
|
|
21
|
+
* Combines:
|
|
22
|
+
* — common rules
|
|
23
|
+
* — locale-specific rules
|
|
24
|
+
*
|
|
25
|
+
* Result is cached per locale and invalidated automatically
|
|
26
|
+
* when rules are registered or reset for that locale.
|
|
27
|
+
*
|
|
28
|
+
* Sorting:
|
|
29
|
+
* — rules are ordered by `weight` (ascending)
|
|
30
|
+
* — rules without weight default to 0
|
|
31
|
+
* — stable order is preserved for equal weights
|
|
32
|
+
*
|
|
33
|
+
* @param locale — Target locale key
|
|
34
|
+
* @returns Flattened and sorted rule pipeline
|
|
35
|
+
*/
|
|
36
|
+
export declare function getWeightedRules(locale: string): Rule[];
|
|
37
|
+
/**
|
|
38
|
+
* Resets all typography rules in the registry.
|
|
39
|
+
*
|
|
40
|
+
* Clears all locale-specific pipelines including "common".
|
|
41
|
+
* After reset, all rule groups become empty arrays.
|
|
42
|
+
*
|
|
43
|
+
* Useful for:
|
|
44
|
+
* — testing
|
|
45
|
+
* — reinitialization
|
|
46
|
+
* — dynamic rule reloading
|
|
47
|
+
*/
|
|
48
|
+
export declare function resetTypographyRules(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Checks if a locale-specific rule pipeline exists.
|
|
51
|
+
*
|
|
52
|
+
* @param locale — Target locale key
|
|
53
|
+
* @returns `true` if pipeline exists and non-empty, `false` otherwise
|
|
54
|
+
*/
|
|
55
|
+
export declare function rulesHas(locale: string): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the number of rules in a locale-specific rule pipeline.
|
|
58
|
+
*
|
|
59
|
+
* @param locale — Target locale key
|
|
60
|
+
* @returns Number of rules in the pipeline
|
|
61
|
+
*/
|
|
62
|
+
export declare function rulesCount(locale: string): number;
|
|
63
|
+
//# sourceMappingURL=store.d.ts.map
|