feat: add Escape Smart Characters operation#2391
Open
HarelKatz wants to merge 1 commit into
Open
Conversation
Converts smart (typographic) Unicode characters (smart quotes, em/en dashes, ellipses, ©, ®, ™, arrows, guillemets, common math symbols) into ASCII equivalents. Characters with no ASCII mapping are handled via a user option: Include (default), Remove, or Replace with '.'. Closes gchq#419
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a new "Escape Smart Characters" operation that converts typographic Unicode characters into their plain ASCII equivalents — smart quotes, em/en dashes, ellipses, ©, ®, ™, arrows, guillemets, and common math symbols.
Characters with no obvious ASCII mapping are handled via an "Unmappable characters" option:
Include(default) — pass through unchangedRemove— drop themReplace with '.'— substitute with a periodLives in the Default module (pure JS, no new dependencies) and sits in the Data format category next to "Normalise Unicode".
Existing Issue
Closes #419. (Prior attempt #1291 was closed for inactivity after the maintainer asked for a rebase; this is a fresh implementation against current
master.)Screenshots
N/A — no visual changes; this is a pure data-transformation operation.
AI disclosure
I used Claude Code to assist with implementation: drafting the character map, writing the test cases, and verifying the lint/test/build workflow. I have reviewed all code being submitted and can answer questions about it.
Test Coverage
11 new tests in
tests/operations/tests/EscapeSmartCharacters.mjscovering: smart quotes, dashes & ellipsis, trademark symbols, arrows & guillemets, math symbols, NBSP, all three "Unmappable" modes (Include / Remove / Replace), ASCII passthrough, and empty input.npm run lint,npm test, andnpm run testnodeconsumerall pass locally.