{"id":11316,"library":"micromark-util-normalize-identifier","title":"Micromark Normalize Identifier Utility","description":"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.","status":"active","version":"2.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/micromark/micromark#main","tags":["javascript","micromark","util","utility","normalize","id","identifier","typescript"],"install":[{"cmd":"npm install micromark-util-normalize-identifier","lang":"bash","label":"npm"},{"cmd":"yarn add micromark-util-normalize-identifier","lang":"bash","label":"yarn"},{"cmd":"pnpm add micromark-util-normalize-identifier","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is ESM-only since its major version 1. CommonJS `require` is not supported.","wrong":"const { normalizeIdentifier } = require('micromark-util-normalize-identifier')","symbol":"normalizeIdentifier","correct":"import { normalizeIdentifier } from 'micromark-util-normalize-identifier'"}],"quickstart":{"code":"import { normalizeIdentifier } from 'micromark-util-normalize-identifier';\n\n// Normalize identifiers with various whitespace and casing scenarios\nconsole.log(normalizeIdentifier(' a ')); // Expected: 'A'\nconsole.log(normalizeIdentifier('a\\t\\r\\nb')); // Expected: 'A B'\nconsole.log(normalizeIdentifier('ТОЛПОЙ')); // Expected: 'ТОЛПОЙ'\nconsole.log(normalizeIdentifier('Толпой')); // Expected: 'ТОЛПОЙ'\nconsole.log(normalizeIdentifier('First Last')); // Expected: 'FIRST LAST'\nconsole.log(normalizeIdentifier('  leading and trailing  ')); // Expected: 'LEADING AND TRAILING'\n","lang":"typescript","description":"Demonstrates how to import and use `normalizeIdentifier` with various input strings to show its whitespace collapsing, trimming, and casing behavior."},"warnings":[{"fix":"Migrate your project to use ES modules or use dynamic import() if you need to load this package in a CommonJS context.","message":"This package is ESM-only since its major version 1. It cannot be imported using CommonJS `require()` syntax.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade your Node.js environment to version 16 or newer.","message":"This package requires Node.js 16 or higher for compatibility. Older Node.js versions are not supported.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Be aware of this specific two-step casing process if you have custom identifier handling logic that might conflict with this approach.","message":"The 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).","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'+03':116,120 '+0398':124 '16':53 '2.0.1':43 '3':49 'activ':60 'address':107 'algorithm':24 'also':132 'approach':83 'b8':121 'broader':72 'cadenc':68 'canon':129 'canonic':85 'case':105,109 'certain':111 'charact':113 'collaps':88 'collis':138 'compat':46 'constructor':143 'convers':106 'current':39 'dedic':12 'definit':37 'design':19 'develop':61 'differenti':78 'e.g':114 'ecosystem':18 'edg':108 'encount':28 'ensur':126 'esm':148 'esm-on':147 'f4':117 'follow':65 'form':130 'id':156 'identifi':3,9,27,86,157 'javascript':151 'key':77 'last':135 'later':55 'lie':79 'like':142 'lower':97 'markdown':30,89 'micromark':1,6,17,48,62,152 'micromark-util-normalize-identifi':5 'monorepo':63 'node.js':52 'normal':2,8,26,155 'object.prototype':140 'packag':14,150 'part':57 'perform':94 'precis':96 'prevent':137 'project':73 'properti':141 'provid':21 'refer':35 'releas':67 'requir':51 'robust':23 'specif':82 'stabl':40 'step':104 'tie':69 'transform':100 'trim':91 'truli':128 'two':103 'two-step':102 'typescript':158 'u':115,119,123 'unicod':112 'updat':75 'uppercas':99,134 'use':133 'util':4,7,13,153,154 'version':41 'vs':118,122 'whitespac':90 'within':15","created_at":"2026-04-19T13:37:21.440686+00:00","updated_at":"2026-04-19T13:37:21.440686+00:00","problems":[{"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.","cause":"Attempting to import an ESM-only package (`micromark-util-normalize-identifier`) using CommonJS `require()` in a Node.js environment.","error":"ERR_REQUIRE_ESM"},{"fix":"Ensure you have `import { normalizeIdentifier } from 'micromark-util-normalize-identifier';` at the top of your file and the symbol name is correct.","cause":"Incorrectly importing `normalizeIdentifier` (e.g., trying to use it before import, or a typo in the named import).","error":"ReferenceError: normalizeIdentifier is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/micromark/micromark.git#main","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/micromark-util-normalize-identifier","openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}