{"library":"micromark-util-classify-character","title":"micromark Character Classifier Utility","description":"The `micromark-util-classify-character` package, currently at version 2.0.1, is a focused utility within the `micromark` ecosystem designed to classify individual Unicode character codes. It categorizes characters into three groups: whitespace, punctuation, or neither. This classification is primarily used in `micromark` extensions, particularly for determining the opening and closing behavior of 'attention' sequences such as emphasis and strong formatting, which depend on the character classes surrounding the sequence. As a part of the actively maintained `micromark` project, its release cadence is tied to the broader library. A key differentiator is its low-level, performance-optimized approach to character classification, directly supporting `micromark`'s parsing algorithms. The package is ESM-only, requiring Node.js version 16 or newer, and ships with complete TypeScript type definitions, making it suitable for modern JavaScript and TypeScript environments.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install micromark-util-classify-character"],"cli":null},"imports":["import { classifyCharacter } from 'micromark-util-classify-character';","import { characterGroupWhitespace } from 'micromark-util-constants';","import type { Code } from 'micromark-util-types';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { classifyCharacter } from 'micromark-util-classify-character';\nimport { characterGroupWhitespace, characterGroupPunctuation } from 'micromark-util-constants';\n\n/**\n * Classify a given character and return its category as a string.\n * @param {string | null} char The character to classify, or null for EOF.\n * @returns {string} The classification result.\n */\nfunction getCharacterCategory(char: string | null): string {\n  const code = char === null ? null : char.charCodeAt(0);\n  const classification = classifyCharacter(code);\n\n  switch (classification) {\n    case characterGroupWhitespace:\n      return `'${char}' (code: ${code}) is classified as WHITESPACE.`;\n    case characterGroupPunctuation:\n      return `'${char}' (code: ${code}) is classified as PUNCTUATION.`;\n    default:\n      return `'${char}' (code: ${code}) is classified as NEITHER.`;\n  }\n}\n\nconsole.log(getCharacterCategory(' ')); // Space character\nconsole.log(getCharacterCategory('\\t')); // Tab character\nconsole.log(getCharacterCategory('.')); // Period character\nconsole.log(getCharacterCategory('!')); // Exclamation mark\nconsole.log(getCharacterCategory('a')); // Letter 'a'\nconsole.log(getCharacterCategory('7')); // Digit '7'\nconsole.log(getCharacterCategory(null)); // End of file (EOF) is treated as whitespace\n","lang":"typescript","description":"This quickstart demonstrates how to import and use the `classifyCharacter` function to determine if a character code represents whitespace, punctuation, or neither. It also shows how to use the constants for comparison.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}