Registry / serialization / micromark-util-normalize-identifier

micromark-util-normalize-identifier

JSON →
library2.0.1jsnpmunverified

micromark-util-normalize-identifier is a dedicated utility package within the `micromark` ecosystem, designed to provide a robust algorithm for normalizing identifiers encountered in markdown, such as those in references and definitions. The current stable version is `2.0.1`, which is compatible with `micromark@3` and requires Node.js 16 or later. As part of the actively developed `micromark` monorepo, it follows a release cadence tied to the broader project's updates. Its key differentiator lies in its specific approach to canonicalizing identifiers: it collapses markdown whitespace, trims, and then performs a precise lower- and uppercase transformation. This two-step case conversion addresses edge cases with certain Unicode characters (e.g., U+03F4 vs. U+03B8 vs. U+0398) to ensure a truly canonical form, while also using uppercase last to prevent collisions with `Object.prototype` properties like `constructor`. It is an ESM-only package.

npm install micromark-util-normalize-identifier
INSTALL
IMPORT
SIG · MICROMARK-UTIL-NOR
M
micromark-util-normalize-identifier
serializationjavascriptv2.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

normalizeIdentifier
import { normalizeIdentifier } from 'micromark-util-normalize-identifier'
const { normalizeIdentifier } = require('micromark-util-normalize-identifier')
This package is ESM-only since its major version 1. CommonJS `require` is not supported.

Demonstrates how to import and use `normalizeIdentifier` with various input strings to show its whitespace collapsing, trimming, and casing behavior.

import { normalizeIdentifier } from 'micromark-util-normalize-identifier'; // Normalize identifiers with various whitespace and casing scenarios console.log(normalizeIdentifier(' a ')); // Expected: 'A' console.log(normalizeIdentifier('a\t\r\nb')); // Expected: 'A B' console.log(normalizeIdentifier('ТОЛПОЙ')); // Expected: 'ТОЛПОЙ' console.log(normalizeIdentifier('Толпой')); // Expected: 'ТОЛПОЙ' console.log(normalizeIdentifier('First Last')); // Expected: 'FIRST LAST' console.log(normalizeIdentifier(' leading and trailing ')); // Expected: 'LEADING AND TRAILING'
Debug
Known issues
breakingThis package is ESM-only since its major version 1. It cannot be imported using CommonJS `require()` syntax.
fix
Migrate your project to use ES modules or use dynamic import() if you need to load this package in a CommonJS context.
affects: >=1.0.0
breakingThis package requires Node.js 16 or higher for compatibility. Older Node.js versions are not supported.
fix
Upgrade your Node.js environment to version 16 or newer.
affects: >=2.0.0
gotchaThe normalization process involves both lowercasing and uppercasing to achieve a canonical form, particularly to handle Unicode character intricacies where simple uppercase might not yield the desired result (e.g., U+03F4 to U+0398 instead of U+03B8).
fix
Be aware of this specific two-step casing process if you have custom identifier handling logic that might conflict with this approach.
affects: >=1.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Attempting to import an ESM-only package (`micromark-util-normalize-identifier`) using CommonJS `require()` in a Node.js environment.
fix
Change `const { normalizeIdentifier } = require('micromark-util-normalize-identifier')` to `import { normalizeIdentifier } from 'micromark-util-normalize-identifier'` and ensure your project is configured for ES modules.
ReferenceError: normalizeIdentifier is not defined
Incorrectly importing `normalizeIdentifier` (e.g., trying to use it before import, or a typo in the named import).
fix
Ensure you have `import { normalizeIdentifier } from 'micromark-util-normalize-identifier';` at the top of your file and the symbol name is correct.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
micromark-util-normalize-identifier — npm install micromark-util-normalize-identifier · libregistry