{"library":"micromark-util-decode-numeric-character-reference","title":"micromark Numeric Character Reference Decoder","description":"micromark-util-decode-numeric-character-reference is a focused utility within the micromark ecosystem designed to safely decode numeric character references found in markdown (e.g., `&#x41;` for 'A'). The current stable major version is `2.x.x`, with `2.0.2` being the latest patch. As part of the unified collective, it follows a regular release cadence, often aligned with broader micromark updates. A key differentiator is its robust handling of non-characters and control characters, ensuring safe output by replacing them with the Unicode replacement character. This package is ESM-only and ships with full TypeScript type definitions, making it suitable for modern JavaScript and TypeScript environments, and is compatible with Node.js 16+.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install micromark-util-decode-numeric-character-reference"],"cli":null},"imports":["import { decodeNumericCharacterReference } from 'micromark-util-decode-numeric-character-reference'","import type { decodeNumericCharacterReference } from 'micromark-util-decode-numeric-character-reference'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { decodeNumericCharacterReference } from 'micromark-util-decode-numeric-character-reference';\n\n// Example 1: Basic ASCII character decoding from hexadecimal\nconst charA_hex = decodeNumericCharacterReference('41', 16);\nconsole.log(`Hex '41' (16-base) decodes to: '${charA_hex}'`); // Expected: 'A'\n\n// Example 2: Basic ASCII character decoding from decimal\nconst charA_dec = decodeNumericCharacterReference('65', 10);\nconsole.log(`Dec '65' (10-base) decodes to: '${charA_dec}'`); // Expected: 'A'\n\n// Example 3: Decoding a newline character (common in references)\nconst newline_hex = decodeNumericCharacterReference('A', 16);\nconsole.log(`Hex 'A' (16-base) decodes to: '${JSON.stringify(newline_hex)}' (newline)`); // Expected: '\\n'\n\n// Example 4: Handling control characters (these are replaced with a replacement character)\nconst controlChar_hex = decodeNumericCharacterReference('7F', 16); // DEL character\nconsole.log(`Hex '7F' (16-base) decodes to: '${controlChar_hex}'`); // Expected: '�' (replacement character)\n\n// Example 5: Handling out-of-range Unicode code points\nconst outOfRange_hex = decodeNumericCharacterReference('110000', 16); // Beyond U+10FFFF\nconsole.log(`Hex '110000' (16-base) decodes to: '${outOfRange_hex}'`); // Expected: '�' (replacement character)\n\nconsole.log(\"\\nThis utility ensures safe decoding, replacing invalid or control characters with the Unicode replacement character.\");","lang":"typescript","description":"Demonstrates how to decode various numeric character references, including ASCII, control characters, and out-of-range Unicode points, showcasing the utility's safe decoding behavior.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}