{"id":11280,"library":"mdast-comment-marker","title":"mdast Comment Marker Parser","description":"mdast-comment-marker is a utility for parsing structured markers from comments within an mdast (Markdown Abstract Syntax Tree) document. It's currently at version 3.0.0 and follows a release cadence tied to major ecosystem updates like Node.js versions and mdast/MDX specifications. This package differentiates itself by providing a robust way to extract 'processing instructions' or metadata embedded in HTML or MDX comments, such as `<!-- lint disable -->` or `/* zone foo */`. It handles various parameter types including booleans, numbers, and strings, making it suitable for tools like remark-lint or mdast-zone, which utilize these markers for configuration or content manipulation. It is ESM-only and requires Node.js 16 or later.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/syntax-tree/mdast-comment-marker","tags":["javascript","unist","mdast","mdast-util","util","utility","marker","comment","typescript"],"install":[{"cmd":"npm install mdast-comment-marker","lang":"bash","label":"npm"},{"cmd":"yarn add mdast-comment-marker","lang":"bash","label":"yarn"},{"cmd":"pnpm add mdast-comment-marker","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"mdast-comment-marker is an ESM-only package since v2.0.0, requiring `import` syntax.","wrong":"const { commentMarker } = require('mdast-comment-marker')","symbol":"commentMarker","correct":"import { commentMarker } from 'mdast-comment-marker'"},{"note":"Type import for the `Marker` interface, representing the parsed comment structure.","symbol":"Marker","correct":"import type { Marker } from 'mdast-comment-marker'"},{"note":"Type import for the `MarkerParameters` interface, detailing the parsed key-value attributes.","symbol":"MarkerParameters","correct":"import type { MarkerParameters } from 'mdast-comment-marker'"}],"quickstart":{"code":"import { commentMarker } from 'mdast-comment-marker';\n\n// Example 1: Basic HTML comment marker\nconsole.log(commentMarker({ type: 'html', value: '<!--foo-->' }));\n\n// Example 2: HTML comment marker with various parameters\nconsole.log(commentMarker({\n  type: 'html',\n  value: '<!--foo bar baz=12.4 qux=\"test test\" quux=\\'false\\'-->'\n}));\n\n// Example 3: MDX Flow Expression comment marker\nconsole.log(commentMarker({\n  type: 'mdxFlowExpression',\n  value: '/* lint disable heading-style */'\n}));\n\n// Example 4: A comment that does not parse as a marker\nconsole.log(commentMarker({ type: 'html', value: '<!doctype html>' }));","lang":"typescript","description":"This quickstart demonstrates how to use `commentMarker` to parse different types of comment nodes (HTML and MDX) into structured marker objects, including handling various parameter types."},"warnings":[{"fix":"Ensure your Node.js environment is at version 16 or newer. Update Node.js if necessary.","message":"Version 3.0.0 changed the minimum Node.js requirement to Node.js 16 or higher.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Migrate your codebase to use ES Module `import` syntax. If in a CommonJS environment, consider a bundler or `import()` dynamic imports.","message":"The package transitioned to ESM only (ES Modules) starting from version 2.0.0. CommonJS `require()` is no longer supported.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Update your MDX tooling to MDX 2 or later, and ensure your comment syntax adheres to MDX 2 conventions.","message":"Version 3.0.0 removed support for MDX 1 comments. If you were parsing MDX 1 specific comment syntax, this will no longer work.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Update your code to check for `undefined` instead of `null` when evaluating the return value of `commentMarker`.","message":"The `commentMarker` function now returns `undefined` instead of `null` when no valid marker is found in the input node.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Run `npm install @types/mdast@latest` or `yarn add @types/mdast@latest` to update your type definitions.","message":"Version 3.0.0 updated its dependency on `@types/mdast`. You might need to update `@types/mdast` in your project to ensure compatibility.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Always use the public API paths as documented. Avoid importing from deep paths within the package unless explicitly exported.","message":"Version 3.0.0 started using the `exports` field in `package.json`. This can break direct imports of non-exported (private) API paths.","severity":"breaking","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change `const { commentMarker } = require('mdast-comment-marker');` to `import { commentMarker } from 'mdast-comment-marker';`.","cause":"Attempting to use `require()` with an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ...mdast-comment-marker/index.js from ... not supported."},{"fix":"Ensure you are using a named import: `import { commentMarker } from 'mdast-comment-marker';`","cause":"Incorrect import statement (e.g., default import instead of named) or attempting to use a CommonJS default import after the ESM transition.","error":"TypeError: commentMarker is not a function"}],"ecosystem":"npm"}