Registry / web-framework / micromark-util-symbol

micromark-util-symbol

JSON →
library2.0.1jsnpmunverified

micromark-util-symbol is a core utility package within the unified collective's `micromark` ecosystem, specifically designed to provide a consistent set of constants. These constants include character codes, common character values, internal token types, and general numeric constants, all crucial for developers building extensions for `micromark`. As of version 2.0.1, the package maintains compatibility with Node.js 16+ and `micromark@3`. While individual utility packages within `micromark` don't adhere to a strict, predictable release cadence, the broader `micromark` project sees regular updates. This package's key differentiator is its provision of named constants that `micromark-build` compiles away for production, encouraging safer, more readable development code without incurring runtime overhead in optimized builds.

npm install micromark-util-symbol
INSTALL
IMPORT
SIG · MICROMARK-UTIL-SYM
M
micromark-util-symbol
web-frameworkjavascriptv2.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.

codes
import { codes } from 'micromark-util-symbol'
const codes = require('micromark-util-symbol').codes
This package is ESM-only since v1; CommonJS `require` is not supported. Use named imports.
constants
import { constants } from 'micromark-util-symbol'
import constants from 'micromark-util-symbol'
The package has no default export. All exports are named.
types
import { types } from 'micromark-util-symbol'
Imports internal token types as strings, useful for matching in `micromark` extensions.
* as symbol
import * as symbol from 'micromark-util-symbol'
Imports all named exports into a single namespace object, useful for brevity.

Demonstrates importing and using the `codes`, `constants`, `types`, and `values` objects to access common Markdown-related symbols and internal types.

import { codes, constants, types, values } from 'micromark-util-symbol'; // Demonstrate various character codes console.log('Character codes:'); console.log(` At sign (@): ${codes.atSign}`); // Expected: 64 console.log(` Line feed (\n): ${codes.lineFeed}`); // Expected: 10 console.log(` Space ( ): ${codes.space}`); // Expected: 32 console.log(` Exclamation mark (!): ${codes.exclamationMark}`); // Expected: 33 // Demonstrate constants related to Markdown parsing limits or specifics console.log('\nParsing constants:'); console.log(` Max character reference named size: ${constants.characterReferenceNamedSizeMax}`); // Expected: 31 console.log(` Max auto-link scheme size: ${constants.autoLinkSchemeSizeMax}`); // Expected: 32 // Demonstrate internal token types used by micromark's state machine console.log('\nMicromark internal types:'); console.log(` Definition destination raw: '${types.definitionDestinationRaw}'`); // Expected: 'definitionDestinationRaw' console.log(` Image reference: '${types.imageReference}'`); // Expected: 'imageReference' // Demonstrate common character string values console.log('\nCharacter values:'); console.log(` At sign value: '${values.atSign}'`); // Expected: '@' console.log(` Tab value: '${values.tab}'`); // Expected: '\t' console.log(` Space value: '${values.space}'`); // Expected: ' ' // This utility package provides a centralized and typed way to refer to // fundamental symbols, making it essential for robust micromark extension development.
Debug
Known issues
breakingThis package is ESM-only since v1.0.0. Attempting to `require()` it in a CommonJS context will result in an error.
fix
Ensure your project is configured for ESM, or use dynamic `import()` for CJS projects.
affects: >=1.0.0
breakingMajor versions of `micromark-util-symbol` drop support for unmaintained Node.js versions. Version 2.x requires Node.js 16 or higher.
fix
Upgrade your Node.js environment to version 16 or newer to ensure compatibility.
affects: >=2.0.0
gotcha`micromark-util-symbol@2` is designed to work with `micromark@3`. Using it with older or incompatible `micromark` core versions may lead to unexpected parsing behavior or errors within your extensions.
fix
Always check the compatibility matrix between `micromark` core and its utilities. Ensure `micromark@3` is installed if using `micromark-util-symbol@2`.
affects: >=2.0.0
gotchaWhen `micromark-util-symbol` is used with `micromark-build` for production, the constants it provides are compiled away. This is an optimization, but means their values are not directly inspectable or present in the final bundle in the same way, which can impact debugging or direct runtime introspection if not understood.
fix
Be aware that optimized builds might strip these constants. For debugging, inspect source maps or run in a development environment without `micromark-build` optimizations.
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: Cannot use import statement outside a module
Attempting to use an ESM `import` statement in a CommonJS file or an environment not configured for ESM.
fix
Ensure your `package.json` has `"type": "module"` or change the file extension to `.mjs`. If using Node.js, ensure your environment supports ESM.
ReferenceError: require is not defined
Attempting to use CommonJS `require()` in an ESM module context (e.g., in a file with `"type": "module"` in `package.json` or `.mjs` extension).
fix
Replace `require()` calls with `import` statements for `micromark-util-symbol`.
TypeError: Cannot read properties of undefined (reading 'atSign')
This usually indicates that the named import `codes` (or `constants`, `types`, `values`) was not correctly imported, often due to trying to use a default import for a package with only named exports.
fix
Ensure you are using named imports: `import { codes } from 'micromark-util-symbol'`.
Error: `micromark-util-symbol` requires Node.js 16 or higher
Running the package in an unsupported Node.js environment.
fix
Upgrade your Node.js installation to version 16 or a later supported version.
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