micromark-util-encode is a focused utility package within the micromark ecosystem, designed specifically for encoding dangerous HTML characters to ensure text is safe for embedding in HTML documents. Its current stable version is 2.0.1, part of the 2.x release line which maintains compatibility with Node.js 16 and higher. As a component of the unified collective, it follows a pragmatic release cadence often aligned with major micromark and Node.js version updates. This package differentiates itself by providing a robust, performant, and standards-compliant algorithm for HTML escaping, specifically tailored for the needs of markdown processors and related text transformation tools, where correctness and minimal overhead are critical. It is fully typed with TypeScript, ensuring good developer experience for static analysis and type safety.
npm install micromark-util-encodeVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use the `encode` function to escape common HTML special characters for safe embedding.
Migrate your project to use ES modules (`import`) or ensure you're using a bundler/transpiler that handles ESM correctly. For Node.js, ensure your package.json specifies `"type": "module"` or use `.mjs` files.
Upgrade your Node.js environment to version 16 or newer. For projects requiring older Node.js compatibility, consider pinning to `micromark-util-encode@1.x` if available and compatible with your `micromark` version.
Always understand the specific scope of encoding. For broader security, combine with other sanitization libraries or consider a full templating engine that handles auto-escaping.
Change `const { encode } = require('micromark-util-encode')` to `import { encode } from 'micromark-util-encode'` and ensure your project is configured for ES modules.Ensure you are using named imports: `import { encode } from 'micromark-util-encode'`.No dependency data recorded yet.