micromark-util-character is a utility package within the micromark ecosystem, providing a collection of pure functions to efficiently check whether a given character code belongs to various predefined groups, such as ASCII alphanumeric, punctuation, or Markdown-specific line endings and spaces. It is currently at version 2.1.1. As part of the larger micromark project, its release cadence is tied to the main project's development. This package is crucial for developers building custom micromark extensions or parsers who need granular control and performant character classification, differentiating itself by offering a specialized, low-level API for fundamental parsing operations rather than general-purpose string manipulation.
npm install micromark-util-characterVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use several utility functions to check character codes for various properties, such as being an ASCII alpha, Markdown line ending, or Unicode punctuation. It also shows a simple custom function combining these utilities.
Migrate your import statements to use ES modules syntax: `import { functionName } from 'micromark-util-character'`.Review any custom micromark extensions that interact closely with character classification, especially for Unicode characters or 'attention' mechanisms, and test thoroughly with the new version.
Always convert characters to their code points using `String.prototype.charCodeAt(0)` before passing them to these utility functions.
Choose the appropriate utility function based on the character set you intend to handle. For broader internationalization, prefer `unicode*` checks where available or implement custom logic.
Change `const { asciiAlpha } = require('micromark-util-character')` to `import { asciiAlpha } from 'micromark-util-character'`.Ensure the input to character utility functions is always a valid number representing a character code. Add checks for `null` or `undefined` if the source of the code is untrustworthy.
Verify the exact name of the imported function and ensure it is correctly destructured from the named exports, e.g., `import { asciiAlpha } from 'micromark-util-character'`.No dependency data recorded yet.