Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String Manipulation Nodes #582

Merged
merged 8 commits into from
Dec 17, 2024
Merged

String Manipulation Nodes #582

merged 8 commits into from
Dec 17, 2024

Conversation

mck
Copy link
Collaborator

@mck mck commented Dec 12, 2024

String Manipulation Nodes Enhancement

This PR adds three new string manipulation nodes to enhance text processing capabilities:

New Nodes

1. Case Convert Node

  • Transforms strings between different case formats:
    • camelCase
    • snake_case
    • kebab-case
    • PascalCase
  • Intelligently handles mixed input formats and consecutive capitals
  • Example: some-mixed_FORMAT testsomeMixedFormatTest

2. Replace Node

  • Simple string replacement without regex
  • Replaces all occurrences of a search string with a replacement string
  • Handles empty strings and cases where search string isn't found
  • Example: hello hello world with search hello and replace hihi hi world

3. Normalize Node

  • String normalization with optional accent removal
  • Supports all Unicode normalization forms (NFC, NFD, NFKC, NFKD)
  • Option to remove diacritical marks while preserving base characters
  • Example: café résumécafe resume

@mck mck self-assigned this Dec 12, 2024
Copy link
Contributor

Failed to generate code suggestions for PR

.replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
.replace(/([a-z\d])([A-Z])/g, '$1 $2')
// Replace common delimiters with spaces
.replace(/[-_.]/g, ' ')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get - and _ as they are used for kebab and snake case but I don't think . should be included tbh

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dot is included to transform from token string to other formats

Copy link

changeset-bot bot commented Dec 17, 2024

🦋 Changeset detected

Latest commit: 3abfe5f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@tokens-studio/graph-engine Minor
@tokens-studio/graph-engine-nodes-audio Major
@tokens-studio/graph-engine-nodes-design-tokens Major
@tokens-studio/graph-engine-nodes-figma Major
@tokens-studio/graph-engine-nodes-fs Major
@tokens-studio/graph-engine-nodes-image Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

.replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
.replace(/([a-z\d])([A-Z])/g, '$1 $2')
// Replace delimiters with spaces using the custom regex
.replace(delimiterRegex, ' ')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is will break as it will only replace the first occurence, so we can rather use replaceAll

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add a test to see it works as expected for multiple occurrences

@mck mck merged commit 1c876a9 into master Dec 17, 2024
2 checks passed
@mck mck deleted the string-nodes branch December 17, 2024 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants