Skip to content

Commit

Permalink
Merge pull request #11 from lublak/normalize
Browse files Browse the repository at this point in the history
add normalize #10
  • Loading branch information
lublak authored Jun 12, 2024
2 parents b05e65e + 7c3725c commit f911e73
Show file tree
Hide file tree
Showing 4 changed files with 341 additions and 185 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Features:
- Length
- Repeat
- Times
- Normalize

## Install

Expand Down
57 changes: 57 additions & 0 deletions nodes/TextManipulation/TextManipulation.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,12 @@ export class TextManipulation implements INodeType {
description: 'Upper and lowercase letters in a string',
action: 'Upper and lowercase letters in a string',
},
{
name: 'Normalize',
value: 'normalize',
description: 'Normalize a string',
action: 'Normalize a string',
},
{
name: 'Pad',
value: 'pad',
Expand Down Expand Up @@ -528,6 +534,41 @@ export class TextManipulation implements INodeType {
],
default: 'letterCase',
},
{
displayName: 'Normalize Form',
name: 'normalizeForm',
displayOptions: {
show: {
action: ['normalize'],
},
},
type: 'options',
options: [
{
name: 'NFC',
value: 'nfc',
description:
'Canonical Decomposition, followed by Canonical Composition',
},
{
name: 'NFD',
value: 'nfd',
description: 'Canonical Decomposition',
},
{
name: 'NFKC',
value: 'nfkc',
description:
'Compatibility Decomposition, followed by Canonical Composition',
},
{
name: 'NFKD',
value: 'nfkd',
description: 'Compatibility Decomposition',
},
],
default: 'nfc',
},
{
displayName: 'Case Type',
name: 'caseType',
Expand Down Expand Up @@ -1603,6 +1644,22 @@ export class TextManipulation implements INodeType {
);
}
break;
case 'normalize':
switch (manipulation.normalizeForm) {
case 'nfc':
text = text.normalize('NFC');
break;
case 'nfd':
text = text.normalize('NFD');
break;
case 'nfkc':
text = text.normalize('NFKC');
break;
case 'nfkd':
text = text.normalize('NFKD');
break;
}
break;
case 'replace':
switch (manipulation.replaceMode) {
case 'substring':
Expand Down
Loading

0 comments on commit f911e73

Please sign in to comment.