{"library":"micromark-util-character","title":"micromark Character Utilities","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install micromark-util-character"],"cli":null},"imports":["import { asciiAlpha } from 'micromark-util-character'","import { markdownLineEnding } from 'micromark-util-character'","import { unicodeWhitespace } from 'micromark-util-character'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { asciiAlpha, markdownLineEnding, unicodePunctuation, asciiDigit } from 'micromark-util-character';\n\nconsole.log('--- Character Checks ---');\n\nconst charA = 65; // 'A'\nconst charNewline = 10; // '\\n'\nconst charAmpersand = 38; // '&'\nconst charDigit = 50; // '2'\nconst charSpace = 32; // ' '\nconst charUnicodePunctuation = 8212; // '—' (em dash)\n\nconsole.log(`Is '${String.fromCharCode(charA)}' an ASCII alpha character? ${asciiAlpha(charA)}`);\nconsole.log(`Is '${String.fromCharCode(charNewline)}' a Markdown line ending? ${markdownLineEnding(charNewline)}`);\nconsole.log(`Is '${String.fromCharCode(charAmpersand)}' a Unicode punctuation character? ${unicodePunctuation(charAmpersand)}`);\nconsole.log(`Is '${String.fromCharCode(charDigit)}' an ASCII digit character? ${asciiDigit(charDigit)}`);\nconsole.log(`Is '${String.fromCharCode(charSpace)}' a Markdown space? ${markdownLineEnding(charSpace)}`);\nconsole.log(`Is '${String.fromCharCode(charUnicodePunctuation)}' a Unicode punctuation character? ${unicodePunctuation(charUnicodePunctuation)}`);\n\n// Demonstrating a common pattern for custom parsers:\nfunction isStartOfWord(code) {\n  return asciiAlpha(code) || asciiDigit(code);\n}\n\nconst testCode = 'H'.charCodeAt(0);\nconsole.log(`Is '${String.fromCharCode(testCode)}' a start of word? ${isStartOfWord(testCode)}`);","lang":"typescript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}