micromark HTML Tag Names Utility
micromark-util-html-tag-name is a low-level utility package within the `micromark` ecosystem, providing curated lists of HTML tag names relevant for CommonMark-compliant Markdown parsing. Specifically, it exports `htmlBlockNames` and `htmlRawNames`, which are used by `micromark` to apply specific parsing rules for HTML (flow) constructs. The `htmlBlockNames` array aids in determining when more relaxed parsing rules apply, based on CommonMark's condition 6, while `htmlRawNames` guides the parser on when HTML content can include lines without exiting until a matching closing tag is found (CommonMark's condition 1). This package is currently in its stable version 2.0.1 and is actively maintained as part of the `micromark` monorepo, which generally sees frequent updates, often with performance enhancements, and drops support for unmaintained Node.js versions with new major releases. It's designed for developers building or extending `micromark` itself, rather than for general HTML tag lookup.
Common errors
-
TypeError: require is not a function
cause Attempting to import the ESM-only package using CommonJS `require()` syntax.fixUpdate your import statement to `import { htmlBlockNames, htmlRawNames } from 'micromark-util-html-tag-name';` and ensure your environment supports ES modules. -
SyntaxError: Named export 'htmlTagNames' not found. The requested module 'micromark-util-html-tag-name' does not provide an export named 'htmlTagNames'
cause Incorrectly trying to import a non-existent default export or an aggregation that doesn't exist.fixCorrect the import to explicitly use the named exports `htmlBlockNames` and `htmlRawNames`: `import { htmlBlockNames, htmlRawNames } from 'micromark-util-html-tag-name';`.
Warnings
- breaking This package is ESM-only since its v2 release. Projects must use ES module import syntax (`import`) and a Node.js version that supports ESM.
- breaking Major versions of `micromark` packages, including this utility, drop support for unmaintained Node.js versions. Version 2.x requires Node.js 16 or higher.
- gotcha The exported lists (`htmlBlockNames`, `htmlRawNames`) are specific to `micromark`'s CommonMark parsing implementation. They are not intended as general-purpose, exhaustive lists for all HTML tags or for arbitrary HTML validation/manipulation.
- gotcha The contents of `htmlBlockNames` and `htmlRawNames` can change with updates to the CommonMark specification. For example, 'search' was added to `htmlBlockNames` in CommonMark@0.31, and 'textarea' was added to `htmlRawNames` in CommonMark@0.30.
Install
-
npm install micromark-util-html-tag-name -
yarn add micromark-util-html-tag-name -
pnpm add micromark-util-html-tag-name
Imports
- htmlBlockNames
const htmlBlockNames = require('micromark-util-html-tag-name').htmlBlockNamesimport { htmlBlockNames } from 'micromark-util-html-tag-name' - htmlRawNames
const htmlRawNames = require('micromark-util-html-tag-name').htmlRawNamesimport { htmlRawNames } from 'micromark-util-html-tag-name' - all tag names
import htmlTagNames from 'micromark-util-html-tag-name'
import { htmlBlockNames, htmlRawNames } from 'micromark-util-html-tag-name'
Quickstart
import { htmlBlockNames, htmlRawNames } from 'micromark-util-html-tag-name';
console.log('--- HTML Block Names (CommonMark Condition 6) ---');
console.log('These tags allow more relaxed parsing rules within micromark.');
console.log('Examples:', htmlBlockNames.slice(0, 5).join(', ') + '...');
console.log(`Total block tags: ${htmlBlockNames.length}`);
console.log('\n--- HTML Raw Names (CommonMark Condition 1) ---');
console.log('Content within these tags is treated as raw HTML, without further Markdown parsing, until a closing tag is found.');
console.log('Examples:', htmlRawNames.slice(0, 3).join(', ') + '...');
console.log(`Total raw tags: ${htmlRawNames.length}`);
// This utility package primarily provides these lists for use within the micromark parser.
// It is not intended for general-purpose HTML tag validation or manipulation outside of micromark's context.
// Developers building custom micromark extensions or alternatives might directly consume these lists.